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
,
387 static const IID
* const styleelem_iids
[] = {
389 &IID_IHTMLStyleElement
,
390 &IID_IConnectionPointContainer
,
394 static const IID
* const generic_iids
[] = {
396 &IID_IHTMLGenericElement
,
397 &IID_IConnectionPointContainer
,
401 static const IID
* const style_iids
[] = {
412 static const IID
* const cstyle_iids
[] = {
416 &IID_IHTMLCurrentStyle
,
417 &IID_IHTMLCurrentStyle2
,
418 &IID_IHTMLCurrentStyle3
,
422 static const IID
* const img_factory_iids
[] = {
426 &IID_IHTMLImageElementFactory
,
436 static const elem_type_info_t elem_type_infos
[] = {
437 {"", none_iids
, NULL
},
438 {"HTML", elem_iids
, NULL
},
439 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
440 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
441 {"BODY", body_iids
, &DIID_DispHTMLBody
},
442 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
443 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
444 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
445 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
446 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
447 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
448 {"BLOCKQUOTE",elem_iids
, NULL
},
449 {"P", elem_iids
, NULL
},
450 {"BR", elem_iids
, NULL
},
451 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
452 {"TBODY", elem_iids
, NULL
},
453 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
454 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
455 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
456 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
457 {"IMG", img_iids
, &DIID_DispHTMLImg
},
458 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
459 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
460 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
461 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
462 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
463 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
464 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
465 {"DIV", elem_iids
, NULL
},
466 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
467 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
468 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
469 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
470 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
473 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
476 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
477 return lstrcmpA(stra
, buf
);
480 static BSTR
a2bstr(const char *str
)
488 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
489 ret
= SysAllocStringLen(NULL
, len
);
490 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
495 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
497 IUnknown
*unk1
, *unk2
;
502 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
503 IUnknown_Release(unk1
);
504 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
505 IUnknown_Release(unk2
);
510 static IHTMLDocument2
*create_document(void)
513 IHTMLDocument5
*doc5
;
516 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
517 &IID_IHTMLDocument2
, (void**)&doc
);
518 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
522 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
524 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
525 IHTMLDocument2_Release(doc
);
529 IHTMLDocument5_Release(doc5
);
533 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
534 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
539 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
540 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
544 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
545 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
547 const IID
* const *piid
;
551 for(piid
= iids
; *piid
; piid
++) {
552 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
553 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
555 IUnknown_Release(unk
);
559 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
560 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
565 unk
= (void*)0xdeadbeef;
566 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
567 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
568 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
571 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
572 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
574 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
581 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
582 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
583 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
585 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
586 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
588 if(SUCCEEDED(hres
)) {
591 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
592 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
594 *iid
= type_attr
->guid
;
598 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
599 ITypeInfo_Release(typeinfo
);
602 IDispatchEx_Release(dispex
);
606 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
607 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
609 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
610 DISPPARAMS dp
= {NULL
,NULL
,0,0};
615 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
616 IDispatchEx_Release(dispex
);
617 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
619 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
620 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
624 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
625 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
629 if(_test_get_dispid(line
, unk
, &iid
))
630 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
633 _test_disp_value(line
, unk
, val
);
636 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
637 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
641 if(_test_get_dispid(line
, unk
, &iid
))
642 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
643 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
646 _test_disp_value(line
, unk
, val
);
649 #define test_class_info(u) _test_class_info(__LINE__,u)
650 static void _test_class_info(unsigned line
, IUnknown
*unk
)
652 IProvideClassInfo
*classinfo
;
657 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
658 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
662 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
663 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
666 IProvideClassInfo_Release(classinfo
);
670 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
671 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
674 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
675 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
676 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
677 "unexpected typekind %d\n", type_attr
->typekind
);
678 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
681 ITypeInfo_Release(typeinfo
);
682 IProvideClassInfo_Release(classinfo
);
685 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
686 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
688 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
689 DISPPARAMS dp
= {val
, NULL
, 1, 0};
696 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
698 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
700 memset(&ei
, 0, sizeof(ei
));
701 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
702 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
706 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
707 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
712 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
713 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
717 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
718 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
723 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
724 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
728 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
729 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
734 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
735 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
739 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
740 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
745 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
746 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
750 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
751 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
753 IHTMLDocument3
*doc3
;
756 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
757 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
762 #define get_node_iface(u) _get_node_iface(__LINE__,u)
763 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
768 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
769 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
773 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
774 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
779 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
780 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
784 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
785 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
790 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
791 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
795 #define get_img_iface(u) _get_img_iface(__LINE__,u)
796 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
798 IHTMLImgElement
*img
;
801 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
802 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
806 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
807 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
809 IHTMLAnchorElement
*anchor
;
812 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
813 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
817 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
818 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
820 IHTMLTextAreaElement
*textarea
;
823 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
824 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
828 #define get_select_iface(u) _get_select_iface(__LINE__,u)
829 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
831 IHTMLSelectElement
*select
;
834 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
835 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
839 #define get_form_iface(u) _get_form_iface(__LINE__,u)
840 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
842 IHTMLFormElement
*form
;
845 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
846 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
850 #define get_text_iface(u) _get_text_iface(__LINE__,u)
851 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
853 IHTMLDOMTextNode
*text
;
856 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
857 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
861 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
862 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
864 IHTMLCommentElement
*comment
;
867 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
868 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
872 #define get_object_iface(u) _get_object_iface(__LINE__,u)
873 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
875 IHTMLObjectElement
*obj
;
878 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
879 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
883 #define get_style_iface(u) _get_style_iface(__LINE__,u)
884 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
886 IHTMLStyleElement
*obj
;
889 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
890 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
894 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
895 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
897 IHTMLMetaElement
*ret
;
900 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
901 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
905 #define get_link_iface(u) _get_link_iface(__LINE__,u)
906 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
908 IHTMLLinkElement
*ret
;
911 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
916 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
917 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
919 IHTMLIFrameElement2
*ret
;
922 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
927 #define get_button_iface(u) _get_button_iface(__LINE__,u)
928 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
930 IHTMLButtonElement
*ret
;
933 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
934 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
938 #define get_label_iface(u) _get_label_iface(__LINE__,u)
939 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
941 IHTMLLabelElement
*ret
;
944 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
945 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
949 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
950 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
952 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
956 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
957 IHTMLDOMNode_Release(node
);
958 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
959 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
964 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
965 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
967 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
968 IDispatch
*disp
= (void*)0xdeadbeef;
969 IHTMLDocument2
*doc
= NULL
;
972 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
973 IHTMLDOMNode2_Release(node
);
974 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
977 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
978 IDispatch_Release(disp
);
979 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
985 #define get_doc_window(d) _get_doc_window(__LINE__,d)
986 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
988 IHTMLWindow2
*window
;
992 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
993 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
994 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
999 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1000 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1002 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1003 IHTMLDOMNode
*ret
= NULL
;
1006 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1007 IHTMLDOMNode_Release(node
);
1008 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1009 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1015 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1016 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1018 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1022 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1023 IHTMLElement_Release(elem
);
1024 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1025 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1030 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1031 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1033 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1034 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1036 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1037 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1040 #define get_node_type(n) _get_node_type(__LINE__,n)
1041 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1043 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1047 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1048 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1050 IHTMLDOMNode_Release(node
);
1055 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1056 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1058 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1059 IHTMLDOMChildrenCollection
*col
= NULL
;
1063 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1064 IHTMLDOMNode_Release(node
);
1065 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1069 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1070 IDispatch_Release(disp
);
1071 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1076 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1077 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1079 IHTMLDOMNode
*node
= NULL
;
1083 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1084 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1086 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1087 IDispatch_Release(disp
);
1092 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1093 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1099 VariantInit(&value
);
1102 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1104 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1107 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1108 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1110 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1113 VariantClear(&value
);
1116 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1117 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1119 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1120 IHTMLElement
*off_parent
;
1124 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1125 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1127 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1128 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1130 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1131 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1133 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1134 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1136 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1139 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1140 IHTMLElement_Release(off_parent
);
1142 IHTMLElement_Release(elem
);
1145 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1146 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1148 LONG l
= 0xdeadbeef;
1151 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1152 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1153 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1156 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1157 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1159 IHTMLWindow2
*window
;
1160 IHTMLDocument2
*ret
;
1163 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1164 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1166 hres
= IHTMLWindow2_get_document(window
, &ret
);
1167 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1168 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1173 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1174 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1179 hres
= IHTMLWindow2_get_name(window
, &name
);
1180 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1182 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1184 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1185 SysFreeString(name
);
1188 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1189 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1195 hres
= IHTMLWindow2_put_name(window
, str
);
1197 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1199 _test_window_name(line
, window
, name
);
1202 #define test_window_status(d) _test_window_status(__LINE__,d)
1203 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1208 status
= (void*)0xdeadbeef;
1209 hres
= IHTMLWindow2_get_status(window
, &status
);
1210 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1211 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1212 SysFreeString(status
);
1215 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1216 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1221 str
= a2bstr(status
);
1222 hres
= IHTMLWindow2_put_status(window
, str
);
1224 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1227 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1228 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1233 hres
= IHTMLWindow2_get_length(window
, &length
);
1234 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1235 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1238 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1239 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1241 IHTMLFrameBase2
*base2
;
1242 IHTMLWindow2
*window
;
1245 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1246 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1249 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1250 IHTMLFrameBase2_Release(base2
);
1251 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1252 ok(window
!= NULL
, "contentWindow = NULL\n");
1257 static void test_get_set_attr(IHTMLDocument2
*doc
)
1260 IHTMLDocument3
*doc3
;
1265 /* grab an element to test with */
1266 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1267 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1269 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1270 IHTMLDocument3_Release(doc3
);
1271 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1273 /* get a non-present attribute */
1274 bstr
= a2bstr("notAnAttribute");
1275 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1276 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1277 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1279 SysFreeString(bstr
);
1281 /* get a present attribute */
1282 bstr
= a2bstr("scrollHeight");
1283 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1284 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1285 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1287 SysFreeString(bstr
);
1289 /* create a new BSTR attribute */
1290 bstr
= a2bstr("newAttribute");
1292 V_VT(&val
) = VT_BSTR
;
1293 V_BSTR(&val
) = a2bstr("the value");
1294 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1295 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1298 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1299 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1300 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1301 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
)));
1304 /* overwrite the attribute with a BOOL */
1305 V_VT(&val
) = VT_BOOL
;
1306 V_BOOL(&val
) = VARIANT_TRUE
;
1307 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1308 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1311 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1312 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1313 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1314 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1317 SysFreeString(bstr
);
1319 /* case-insensitive */
1320 bstr
= a2bstr("newattribute");
1321 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1322 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1323 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1324 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1326 SysFreeString(bstr
);
1328 IHTMLElement_Release(elem
);
1331 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1332 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1335 IHTMLDocument3
*doc3
;
1338 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1339 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1340 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1341 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1342 IHTMLDocument3_Release(doc3
);
1347 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1348 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1350 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1354 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1355 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1356 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1359 _test_disp_value(line
, unk
, exhref
);
1362 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1363 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1365 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1369 str
= a2bstr(exhref
);
1370 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1371 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1374 _test_disp_value(line
, unk
, exhref
);
1377 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1378 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1380 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1384 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1385 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1387 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1389 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1393 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1394 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1396 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1400 str
= a2bstr(exrel
);
1401 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1402 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1406 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1407 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1409 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1413 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1414 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1416 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1418 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1422 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1423 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1425 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1429 str
= target
? a2bstr(target
) : NULL
;
1430 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1431 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1435 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1436 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1438 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1442 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1443 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1445 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1447 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1451 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1452 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1454 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1458 str
= name
? a2bstr(name
) : NULL
;
1459 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1460 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1463 _test_anchor_name(line
, unk
, name
);
1466 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1467 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1469 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1473 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1474 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1476 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1478 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1482 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1483 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1485 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1489 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1490 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1491 if ( ! str
&& allowbroken
)
1492 win_skip("skip ie6 incorrect behavior\n");
1494 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1496 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1500 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1501 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1503 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1507 str
= search
? a2bstr(search
) : NULL
;
1508 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1509 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1513 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1514 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1516 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1520 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1521 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1523 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1525 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1529 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1530 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1535 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1536 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1537 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1538 SysFreeString(bstr
);
1541 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1542 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1547 bstr
= a2bstr(text
);
1548 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1549 SysFreeString(bstr
);
1550 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1552 _test_option_text(line
, option
, text
);
1555 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1556 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1561 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1562 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1563 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1564 SysFreeString(bstr
);
1567 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1568 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1573 bstr
= a2bstr(value
);
1574 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1575 SysFreeString(bstr
);
1576 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1578 _test_option_value(line
, option
, value
);
1581 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1582 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1584 VARIANT_BOOL b
= 0x100;
1587 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1588 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1589 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1592 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1593 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1597 hres
= IHTMLOptionElement_put_selected(option
, b
);
1598 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1599 _test_option_selected(line
, option
, b
);
1602 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1603 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1605 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1606 BSTR value
= (void*)0xdeadbeef;
1609 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1610 IHTMLTextAreaElement_Release(textarea
);
1611 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1613 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1615 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1616 SysFreeString(value
);
1619 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1620 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1622 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1623 BSTR tmp
= a2bstr(value
);
1626 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1627 IHTMLTextAreaElement_Release(textarea
);
1628 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1631 _test_textarea_value(line
, unk
, value
);
1634 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1635 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1637 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1638 VARIANT_BOOL b
= 0x100;
1641 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1642 IHTMLTextAreaElement_Release(textarea
);
1643 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1644 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1647 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1648 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1650 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1653 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1654 IHTMLTextAreaElement_Release(textarea
);
1655 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1657 _test_textarea_readonly(line
, unk
, b
);
1660 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1661 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1663 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1664 BSTR type
= (void*)0xdeadbeef;
1667 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1668 IHTMLTextAreaElement_Release(textarea
);
1669 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1670 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1671 SysFreeString(type
);
1674 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1675 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1677 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1681 text
= a2bstr(extext
);
1682 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1683 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1684 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1686 IHTMLCommentElement_Release(comment
);
1687 SysFreeString(text
);
1690 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1691 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1693 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1694 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1695 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1696 IHTMLDOMAttribute
*attr
;
1697 BSTR name
= a2bstr("test");
1701 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1702 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1703 ok(attr
== NULL
, "attr != NULL\n");
1707 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1708 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1710 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1711 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1712 ok(attr
!= NULL
, "attr == NULL\n");
1714 IHTMLDOMAttribute_Release(attr
);
1715 IHTMLCommentElement_Release(comment
);
1716 IHTMLElement_Release(elem
);
1717 IHTMLElement4_Release(elem4
);
1718 SysFreeString(name
);
1721 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1722 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1724 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1729 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1730 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1731 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1732 IHTMLObjectElement_Release(object
);
1735 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
1736 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
1738 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1742 str
= (void*)0xdeadbeef;
1743 hres
= IHTMLObjectElement_get_name(object
, &str
);
1744 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1746 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
1748 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
1750 IHTMLObjectElement_Release(object
);
1753 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
1754 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
1756 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1761 hres
= IHTMLObjectElement_put_name(object
, str
);
1762 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1764 IHTMLObjectElement_Release(object
);
1766 _test_object_name(line
, elem
, name
);
1769 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1770 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1771 const char *txt
, const char *val
)
1773 IHTMLOptionElementFactory
*factory
;
1774 IHTMLOptionElement
*option
;
1775 IHTMLWindow2
*window
;
1776 VARIANT text
, value
, empty
;
1779 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1780 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1782 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1783 IHTMLWindow2_Release(window
);
1784 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1786 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
1788 V_VT(&text
) = VT_BSTR
;
1789 V_BSTR(&text
) = a2bstr(txt
);
1790 V_VT(&value
) = VT_BSTR
;
1791 V_BSTR(&value
) = a2bstr(val
);
1792 V_VT(&empty
) = VT_EMPTY
;
1794 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1795 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1797 IHTMLOptionElementFactory_Release(factory
);
1798 VariantClear(&text
);
1799 VariantClear(&value
);
1801 _test_option_text(line
, option
, txt
);
1802 _test_option_value(line
, option
, val
);
1803 _test_option_selected(line
, option
, VARIANT_FALSE
);
1808 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1809 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1814 hres
= IHTMLImgElement_get_width(img
, &found
);
1815 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1816 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1819 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1820 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1824 hres
= IHTMLImgElement_put_width(img
, width
);
1825 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1827 _test_img_width(line
, img
, width
);
1830 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1831 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1836 hres
= IHTMLImgElement_get_height(img
, &found
);
1837 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1838 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1841 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1842 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1846 hres
= IHTMLImgElement_put_height(img
, height
);
1847 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1849 _test_img_height(line
, img
, height
);
1852 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1853 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1854 LONG wdth
, LONG hght
)
1856 IHTMLImageElementFactory
*factory
;
1857 IHTMLImgElement
*img
;
1858 IHTMLWindow2
*window
;
1859 VARIANT width
, height
;
1863 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1864 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1866 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1867 IHTMLWindow2_Release(window
);
1868 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1870 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1871 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1874 snprintf(buf
, 16, "%d", wdth
);
1875 V_VT(&width
) = VT_BSTR
;
1876 V_BSTR(&width
) = a2bstr(buf
);
1878 V_VT(&width
) = VT_EMPTY
;
1883 snprintf(buf
, 16, "%d", hght
);
1884 V_VT(&height
) = VT_BSTR
;
1885 V_BSTR(&height
) = a2bstr(buf
);
1887 V_VT(&height
) = VT_EMPTY
;
1891 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1892 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1894 IHTMLImageElementFactory_Release(factory
);
1895 VariantClear(&width
);
1896 VariantClear(&height
);
1898 if(SUCCEEDED(hres
)) {
1899 _test_img_width(line
, img
, wdth
);
1900 _test_img_height(line
, img
, hght
);
1907 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1908 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1910 LONG len
= 0xdeadbeef;
1913 hres
= IHTMLSelectElement_get_length(select
, &len
);
1914 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1915 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1918 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1919 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1921 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1924 hres
= IHTMLSelectElement_put_length(select
, length
);
1925 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1926 _test_select_length(line
, select
, length
);
1927 IHTMLSelectElement_Release(select
);
1930 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1931 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1933 LONG idx
= 0xdeadbeef;
1936 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1937 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1938 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1941 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1942 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1946 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1947 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1948 _test_select_selidx(line
, select
, index
);
1951 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1952 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1957 hres
= IHTMLSelectElement_get_value(select
, &val
);
1958 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1960 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1962 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1966 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1967 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1973 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1974 SysFreeString(bstr
);
1975 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1978 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1979 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1984 hres
= IHTMLSelectElement_get_type(select
, &type
);
1985 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1986 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1987 SysFreeString(type
);
1990 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
1991 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
1993 VARIANT_BOOL b
= 100;
1996 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
1997 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
1998 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2001 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2002 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2006 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2007 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2009 _test_select_multiple(line
, select
, val
);
2012 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2013 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2018 hres
= IHTMLTxtRange_get_text(range
, &text
);
2019 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2022 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2023 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2025 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2028 SysFreeString(text
);
2032 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2033 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2037 hres
= IHTMLTxtRange_collapse(range
, b
);
2038 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2039 _test_range_text(line
, range
, NULL
);
2042 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2043 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2044 VARIANT_BOOL exb
, const char *extext
)
2046 VARIANT_BOOL b
= 0xe0e0;
2049 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2050 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2051 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2052 _test_range_text(line
, range
, extext
);
2055 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2056 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2058 LONG c
= 0xdeadbeef;
2061 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2062 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2063 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2064 _test_range_text(line
, range
, NULL
);
2067 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2068 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2069 LPWSTR unit
, LONG cnt
, LONG excnt
)
2071 LONG c
= 0xdeadbeef;
2074 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2075 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2076 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2079 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2080 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2082 LONG c
= 0xdeadbeef;
2085 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2086 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2087 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2090 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2091 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2094 BSTR bstr
= a2bstr(text
);
2096 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2097 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2098 SysFreeString(bstr
);
2099 _test_range_text(line
, range
, NULL
);
2102 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2103 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2109 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2110 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2111 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2114 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2115 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2121 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2122 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2123 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2126 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2127 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2128 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2131 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2132 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2136 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2137 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2142 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2143 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2145 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2147 IHTMLElement_Release(elem
);
2150 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2151 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2153 VARIANT name
, index
;
2158 V_VT(&index
) = VT_EMPTY
;
2159 V_VT(&name
) = VT_I4
;
2161 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2162 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2163 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2165 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2166 IDispatch_Release(disp
);
2170 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2171 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2172 const elem_type_t
*elem_types
, LONG exlen
)
2174 IHTMLElementCollection
*col
;
2175 IEnumVARIANT
*enum_var
;
2180 VARIANT name
, index
, v
, vs
[5];
2181 IDispatch
*disp
, *disp2
;
2184 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2185 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2187 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2189 hres
= IHTMLElementCollection_get_length(col
, &len
);
2190 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2191 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2196 V_VT(&index
) = VT_EMPTY
;
2198 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2199 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2201 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2202 IUnknown_Release(enum_unk
);
2203 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2205 for(i
=0; i
<len
; i
++) {
2206 V_VT(&name
) = VT_I4
;
2208 disp
= (void*)0xdeadbeef;
2209 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2210 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2211 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2212 if(FAILED(hres
) || !disp
)
2215 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2218 V_VT(&name
) = VT_UINT
;
2220 disp2
= (void*)0xdeadbeef;
2221 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2222 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2223 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2225 IDispatch_Release(disp2
);
2229 V_VT(&v
) = VT_ERROR
;
2230 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2231 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2233 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2234 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2235 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2236 IDispatch_Release(V_DISPATCH(&v
));
2238 IDispatch_Release(disp
);
2241 fetched
= 0xdeadbeef;
2243 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2244 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2245 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2246 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2248 hres
= IEnumVARIANT_Reset(enum_var
);
2249 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2251 fetched
= 0xdeadbeef;
2253 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2254 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2255 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2256 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2258 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2259 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2261 memset(vs
, 0, sizeof(vs
));
2263 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2264 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2265 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2267 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2268 IDispatch_Release(V_DISPATCH(vs
));
2271 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2272 IDispatch_Release(V_DISPATCH(vs
+1));
2275 hres
= IEnumVARIANT_Reset(enum_var
);
2276 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2278 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2279 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2281 IEnumVARIANT_Release(enum_var
);
2283 V_VT(&name
) = VT_I4
;
2285 disp
= (void*)0xdeadbeef;
2286 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2287 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2288 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2290 V_VT(&name
) = VT_I4
;
2292 disp
= (void*)0xdeadbeef;
2293 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2294 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2295 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2297 IHTMLElementCollection_Release(col
);
2300 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2301 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2303 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2307 hres
= IHTMLElement_get_all(elem
, &disp
);
2308 IHTMLElement_Release(elem
);
2309 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2311 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2312 IDispatch_Release(disp
);
2315 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2316 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2318 IHTMLElementCollection
*col
;
2321 hres
= IHTMLDocument2_get_all(doc
, &col
);
2322 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2324 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2325 IHTMLElementCollection_Release(col
);
2328 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2329 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2331 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2332 IHTMLElementCollection
*col
= NULL
;
2333 elem_type_t
*types
= NULL
;
2338 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2339 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2341 IHTMLElement2_Release(elem
);
2342 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2343 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2346 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2347 for(i
=0; i
<exlen
; i
++)
2351 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2353 HeapFree(GetProcessHeap(), 0, types
);
2356 *ret
= get_elem_col_item_idx(col
, 0);
2357 IHTMLElementCollection_Release(col
);
2360 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2361 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2366 hres
= IHTMLElement_get_innerText(elem
, &text
);
2367 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2369 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2370 wine_dbgstr_w(text
), extext
);
2372 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2373 SysFreeString(text
);
2376 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2377 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2379 IHTMLDOMChildrenCollection
*col
;
2384 hres
= IHTMLElement_put_innerText(elem
, str
);
2385 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2388 _test_elem_innertext(line
, elem
, text
);
2391 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2392 ok(col
!= NULL
, "col == NULL\n");
2394 LONG length
= 0, type
;
2397 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2398 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2399 ok(length
== 1, "length = %d\n", length
);
2401 node
= _get_child_item(line
, col
, 0);
2402 ok(node
!= NULL
, "node == NULL\n");
2404 type
= _get_node_type(line
, (IUnknown
*)node
);
2405 ok(type
== 3, "type=%d\n", type
);
2406 IHTMLDOMNode_Release(node
);
2409 IHTMLDOMChildrenCollection_Release(col
);
2414 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2415 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2417 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2421 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2422 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2424 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2426 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2428 IHTMLElement_Release(elem
);
2429 SysFreeString(html
);
2432 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2433 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2435 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2439 html
= a2bstr(inner_html
);
2440 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2441 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2443 IHTMLElement_Release(elem
);
2444 SysFreeString(html
);
2447 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2448 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2450 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2454 html
= a2bstr(outer_html
);
2455 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2456 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2458 IHTMLElement_Release(elem
);
2459 SysFreeString(html
);
2462 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2463 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2465 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2469 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2470 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2471 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2473 IHTMLElement_Release(elem
);
2474 SysFreeString(html
);
2477 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2478 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2484 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2485 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2486 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2489 #define get_first_child(n) _get_first_child(__LINE__,n)
2490 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2492 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2493 IHTMLDOMNode
*child
= NULL
;
2496 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2497 IHTMLDOMNode_Release(node
);
2498 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2503 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2504 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2506 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2507 VARIANT_BOOL b
= 0xdead;
2510 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2511 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2512 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2514 IHTMLDOMNode_Release(node
);
2517 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2518 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2520 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2521 IHTMLDOMNode
*parent
;
2524 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2525 IHTMLDOMNode_Release(node
);
2526 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2531 #define node_get_next(u) _node_get_next(__LINE__,u)
2532 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2534 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2538 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2539 IHTMLDOMNode_Release(node
);
2540 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2545 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2546 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2548 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2552 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2553 IHTMLDOMNode_Release(node
);
2554 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2559 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2560 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2562 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2563 IHTMLElement
*parent
;
2566 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2567 IHTMLElement_Release(elem
);
2568 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2573 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2574 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2576 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2577 VARIANT_BOOL disabled
= 100;
2581 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2582 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2583 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2584 IHTMLElement3_Release(elem3
);
2587 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2588 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2590 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2594 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2595 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2597 IHTMLElement3_Release(elem3
);
2598 _test_elem3_get_disabled(line
, unk
, b
);
2601 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2602 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2604 VARIANT_BOOL disabled
= 100;
2607 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2608 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2609 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2611 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2614 static void test_select_remove(IHTMLSelectElement
*select
)
2618 hres
= IHTMLSelectElement_remove(select
, 3);
2619 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
2620 test_select_length(select
, 2);
2622 hres
= IHTMLSelectElement_remove(select
, -1);
2624 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
2625 test_select_length(select
, 2);
2627 hres
= IHTMLSelectElement_remove(select
, 0);
2628 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
2629 test_select_length(select
, 1);
2632 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2633 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
2635 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2639 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
2640 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2641 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
2642 IHTMLDOMTextNode_Release(text
);
2645 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
2646 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
2648 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2652 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
2653 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2654 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
2655 IHTMLDOMTextNode_Release(text
);
2659 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
2660 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
2662 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2663 BSTR str
= a2bstr(data
);
2666 hres
= IHTMLDOMTextNode_put_data(text
, str
);
2667 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2668 IHTMLDOMTextNode_Release(text
);
2672 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2673 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
2677 hres
= IHTMLSelectElement_put_disabled(select
, b
);
2678 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2680 _test_select_get_disabled(line
, select
, b
);
2683 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2684 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
2686 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2687 IHTMLTextContainer
*txtcont
;
2688 LONG l
= -1, l2
= -1;
2691 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
2692 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
2693 IHTMLElement2_Release(elem
);
2695 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2696 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2698 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
2699 IHTMLTextContainer_Release(txtcont
);
2700 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
2701 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
2706 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2707 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
2709 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2710 IHTMLTextContainer
*txtcont
;
2711 LONG l
= -1, l2
= -1;
2714 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
2715 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
2716 IHTMLElement2_Release(elem
);
2718 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2719 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2721 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
2722 IHTMLTextContainer_Release(txtcont
);
2723 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
2724 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
2729 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2730 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
2732 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2733 IHTMLTextContainer
*txtcont
;
2734 LONG l
= -1, l2
= -1;
2737 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
2738 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2739 IHTMLElement2_Release(elem
);
2741 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2742 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2744 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
2745 IHTMLTextContainer_Release(txtcont
);
2746 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
2747 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2752 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2753 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2755 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2756 IHTMLTextContainer
*txtcont
;
2757 LONG l
= -1, l2
= -1;
2760 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2761 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2763 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2764 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2765 IHTMLElement2_Release(elem
);
2767 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2768 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2770 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2771 IHTMLTextContainer_Release(txtcont
);
2772 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2773 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2776 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2777 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
2779 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2783 hres
= IHTMLImgElement_get_src(img
, &src
);
2784 IHTMLImgElement_Release(img
);
2785 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2786 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
2787 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2791 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2792 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2794 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2799 hres
= IHTMLImgElement_put_src(img
, tmp
);
2800 IHTMLImgElement_Release(img
);
2802 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2805 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2806 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2808 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2812 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2813 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2815 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2817 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2821 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2822 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2824 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2829 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2830 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2833 _test_img_alt(line
, unk
, alt
);
2836 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
2837 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
2839 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2843 tmp
= a2bstr(align
);
2844 hres
= IHTMLImgElement_put_align(img
, tmp
);
2845 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2848 hres
= IHTMLImgElement_get_align(img
, &tmp
);
2849 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2850 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
2854 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2855 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2857 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2861 hres
= IHTMLImgElement_get_name(img
, &sName
);
2862 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2863 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2864 IHTMLImgElement_Release(img
);
2865 SysFreeString(sName
);
2868 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
2869 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
2871 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
2872 VARIANT_BOOL b
= 100;
2875 hres
= IHTMLImgElement_get_complete(img
, &b
);
2876 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
2877 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
2878 IHTMLImgElement_Release(img
);
2881 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
2882 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
2884 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2885 VARIANT_BOOL b
= 100;
2888 hres
= IHTMLImgElement_put_isMap(img
, v
);
2889 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
2891 hres
= IHTMLImgElement_get_isMap(img
, &b
);
2892 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
2893 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
2895 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
2896 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
2897 IHTMLImgElement_Release(img
);
2900 static void test_dynamic_properties(IHTMLElement
*elem
)
2902 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
2903 IDispatchEx
*dispex
;
2904 BSTR name
, attr1
= SysAllocString(attr1W
);
2908 DISPID id
= DISPID_STARTENUM
;
2911 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2912 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2914 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
2915 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
2916 ok(succ
, "removeAttribute set succ to FALSE\n");
2919 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2920 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
2924 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
2925 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
2927 if(!strcmp_wa(name
, "attr1"))
2928 ok(0, "attr1 should be removed\n");
2929 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
2931 SysFreeString(name
);
2933 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
2934 IDispatchEx_Release(dispex
);
2936 V_VT(&val
) = VT_BSTR
;
2937 V_BSTR(&val
) = attr1
;
2938 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
2939 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2940 SysFreeString(attr1
);
2943 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
2944 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
2949 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
2950 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
2951 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
2955 static void test_attr_collection_disp(IDispatch
*disp
)
2957 IDispatchEx
*dispex
;
2958 IHTMLDOMAttribute
*attr
;
2959 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
2966 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
2967 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2970 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2971 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2972 SysFreeString(bstr
);
2975 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2976 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2977 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2978 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2981 bstr
= a2bstr("attr1");
2982 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2983 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2984 SysFreeString(bstr
);
2987 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2988 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2989 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2990 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2991 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
2992 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2994 test_attr_node_name(attr
, "attr1");
2996 IHTMLDOMAttribute_Release(attr
);
2999 IDispatchEx_Release(dispex
);
3002 static void test_attr_collection(IHTMLElement
*elem
)
3004 static const WCHAR testW
[] = {'t','e','s','t',0};
3007 IDispatch
*disp
, *attr
;
3008 IHTMLDOMAttribute
*dom_attr
;
3009 IHTMLAttributeCollection
*attr_col
;
3010 BSTR name
= SysAllocString(testW
);
3012 LONG i
, len
, checked
;
3015 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3016 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3018 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3019 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3021 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3022 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3023 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3024 IDispatch_Release(attr
);
3025 IHTMLDOMNode_Release(node
);
3027 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3028 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3030 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3031 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3035 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3036 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3037 SysFreeString(name
);
3039 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3040 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3041 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3044 for(i
=0; i
<len
; i
++) {
3047 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3048 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3050 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3051 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3052 IDispatch_Release(attr
);
3054 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3055 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3057 if(!strcmp_wa(name
, "id")) {
3059 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3060 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3061 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3062 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3063 } else if(!strcmp_wa(name
, "attr1")) {
3065 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3066 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3067 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3068 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3069 } else if(!strcmp_wa(name
, "attr2")) {
3071 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3072 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3073 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3074 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3075 } else if(!strcmp_wa(name
, "attr3")) {
3077 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3078 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3079 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3080 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3081 } else if(!strcmp_wa(name
, "test")) {
3083 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3084 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3085 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3086 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3089 IHTMLDOMAttribute_Release(dom_attr
);
3090 SysFreeString(name
);
3093 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3096 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3097 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3099 V_VT(&id
) = VT_BSTR
;
3100 V_BSTR(&id
) = a2bstr("nonexisting");
3101 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3102 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3105 test_attr_collection_disp(disp
);
3107 IDispatch_Release(disp
);
3108 IHTMLAttributeCollection_Release(attr_col
);
3111 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
3112 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
3114 VARIANT_BOOL specified
;
3117 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
3118 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
3119 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
3122 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3123 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3125 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3126 BSTR id
= (void*)0xdeadbeef;
3129 hres
= IHTMLElement_get_id(elem
, &id
);
3130 IHTMLElement_Release(elem
);
3131 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3134 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3136 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3141 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3142 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3144 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3145 BSTR tmp
= a2bstr(new_id
);
3148 hres
= IHTMLElement_put_id(elem
, tmp
);
3149 IHTMLElement_Release(elem
);
3151 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3153 _test_elem_id(line
, unk
, new_id
);
3156 static void test_contenteditable(IUnknown
*unk
)
3158 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3160 BSTR str
, strDefault
;
3162 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3163 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3165 str
= a2bstr("true");
3166 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3167 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3169 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3170 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3171 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3173 /* Restore origin contentEditable */
3174 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3175 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3176 SysFreeString(strDefault
);
3178 IHTMLElement3_Release(elem3
);
3181 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3182 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3187 hres
= IHTMLInputElement_get_type(input
, &type
);
3188 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3189 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3190 SysFreeString(type
);
3193 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3194 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3196 BSTR name
= (BSTR
)0xdeadbeef;
3199 hres
= IHTMLInputElement_get_name(input
, &name
);
3200 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3202 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3204 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3205 SysFreeString(name
);
3208 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3209 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3211 BSTR tmp
= a2bstr(name
);
3214 hres
= IHTMLInputElement_put_name(input
, tmp
);
3215 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3218 _test_input_name(line
, input
, name
);
3221 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3222 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3224 VARIANT_BOOL disabled
= 100;
3227 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3228 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3229 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3231 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3234 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3235 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3239 hres
= IHTMLInputElement_put_disabled(input
, b
);
3240 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3242 _test_input_get_disabled(line
, input
, b
);
3245 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3246 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3248 VARIANT_BOOL checked
= 100;
3251 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3252 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3253 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3256 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3257 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3261 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3262 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3264 _test_input_get_defaultchecked(line
, input
, b
);
3267 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3268 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3270 VARIANT_BOOL checked
= 100;
3273 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3274 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3275 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3278 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3279 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3283 hres
= IHTMLInputElement_put_checked(input
, b
);
3284 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3286 _test_input_get_checked(line
, input
, b
);
3289 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3290 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3292 LONG maxlength
= 0xdeadbeef;
3295 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3297 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3300 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3301 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3305 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3306 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3308 _test_input_maxlength(line
, input
, l
);
3311 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3312 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3314 IHTMLInputElement
*input
;
3318 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3319 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3323 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3324 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3326 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3328 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3329 SysFreeString(bstr
);
3330 IHTMLInputElement_Release(input
);
3333 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3334 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3336 IHTMLInputElement
*input
;
3337 IHTMLFormElement
*form
;
3341 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3342 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3343 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3344 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3345 if(FAILED(hres
) || input
== NULL
)
3348 hres
= IHTMLInputElement_get_form(input
, &form
);
3349 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3350 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3351 if(FAILED(hres
) || form
== NULL
){
3352 IHTMLInputElement_Release(input
);
3356 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3357 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3358 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3359 if(FAILED(hres
) || elem
== NULL
){
3360 IHTMLInputElement_Release(input
);
3361 IHTMLFormElement_Release(form
);
3365 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3367 IHTMLInputElement_Release(input
);
3368 IHTMLFormElement_Release(form
);
3369 IHTMLElement_Release(elem
);
3372 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3373 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3375 IHTMLInputElement
*input
;
3379 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3380 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3385 hres
= IHTMLInputElement_put_value(input
, bstr
);
3386 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3387 SysFreeString(bstr
);
3388 IHTMLInputElement_Release(input
);
3390 _test_input_value(line
, unk
, val
);
3393 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3394 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3396 IHTMLInputElement
*input
;
3400 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3401 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3405 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3406 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3408 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3410 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3412 IHTMLInputElement_Release(input
);
3415 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3416 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3418 IHTMLInputElement
*input
;
3422 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3423 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3428 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3429 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3431 IHTMLInputElement_Release(input
);
3433 _test_input_defaultValue(line
, unk
, val
);
3436 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
3437 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
3442 hres
= IHTMLInputElement_get_src(input
, &src
);
3443 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3445 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3447 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
3451 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
3452 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
3458 hres
= IHTMLInputElement_put_src(input
, tmp
);
3460 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3462 _test_input_src(line
, input
, src
);
3465 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
3466 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
3470 hres
= IHTMLInputElement_put_size(input
, size
);
3471 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
3474 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
3475 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
3480 hres
= IHTMLInputElement_get_size(input
, &size
);
3481 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
3482 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
3484 hres
= IHTMLInputElement_get_size(input
, NULL
);
3485 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
3488 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
3489 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
3492 VARIANT_BOOL b
= 100;
3494 hres
= IHTMLInputElement_put_readOnly(input
, v
);
3495 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
3497 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
3498 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
3499 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
3502 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
3503 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
3505 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3506 BSTR
class = (void*)0xdeadbeef;
3509 hres
= IHTMLElement_get_className(elem
, &class);
3510 IHTMLElement_Release(elem
);
3511 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
3513 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
3515 ok_(__FILE__
,line
) (!class, "class != NULL\n");
3516 SysFreeString(class);
3519 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
3520 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
3522 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3526 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
3527 IHTMLElement2_Release(elem2
);
3528 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3529 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
3532 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
3533 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
3535 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3538 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
3539 IHTMLElement2_Release(elem2
);
3540 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3542 _test_elem_tabindex(line
, unk
, index
);
3545 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
3546 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
3548 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3552 hres
= IHTMLStyleElement_get_media(style
, &media
);
3553 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
3555 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
3557 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
3559 IHTMLStyleElement_Release(style
);
3560 SysFreeString(media
);
3563 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
3564 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
3566 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3570 str
= a2bstr(media
);
3571 hres
= IHTMLStyleElement_put_media(style
, str
);
3572 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
3573 IHTMLStyleElement_Release(style
);
3576 _test_style_media(line
, unk
, media
);
3579 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
3580 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
3582 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3586 hres
= IHTMLStyleElement_get_type(style
, &type
);
3587 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3589 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
3591 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
3593 IHTMLStyleElement_Release(style
);
3594 SysFreeString(type
);
3597 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
3598 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
3600 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3605 hres
= IHTMLStyleElement_put_type(style
, str
);
3606 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
3607 IHTMLStyleElement_Release(style
);
3610 _test_style_type(line
, unk
, type
);
3613 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
3614 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
3616 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3618 IHTMLFiltersCollection
*filters
;
3620 hres
= IHTMLElement_get_filters(elem
, &filters
);
3621 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
3622 "get_filters failed: %08x\n", hres
);
3626 IDispatchEx
*dispex
;
3628 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
3629 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
3630 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
3632 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
3633 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
3634 "Could not get IDispatchEx interface: %08x\n", hres
);
3635 if(SUCCEEDED(hres
)) {
3636 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
3637 IDispatchEx_Release(dispex
);
3640 IHTMLFiltersCollection_Release(filters
);
3643 IHTMLElement_Release(elem
);
3646 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
3647 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
3649 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3653 tmp
= class ? a2bstr(class) : NULL
;
3654 hres
= IHTMLElement_put_className(elem
, tmp
);
3655 IHTMLElement_Release(elem
);
3656 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
3659 _test_elem_class(line
, unk
, class);
3662 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
3663 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
3665 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3669 hres
= IHTMLElement_get_title(elem
, &title
);
3670 IHTMLElement_Release(elem
);
3671 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3673 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
3675 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
3677 SysFreeString(title
);
3680 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
3681 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
3683 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3687 tmp
= a2bstr(title
);
3688 hres
= IHTMLElement_put_title(elem
, tmp
);
3689 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3691 IHTMLElement_Release(elem
);
3695 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
3696 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
3698 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3702 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
3703 IHTMLDOMNode_Release(node
);
3704 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3707 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
3708 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
3710 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
3716 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
3717 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
3719 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3723 V_VT(&var
) = VT_BSTR
;
3724 V_BSTR(&var
) = a2bstr(val
);
3726 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
3727 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3728 IHTMLDOMNode_Release(node
);
3732 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
3733 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
3735 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3739 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
3740 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
3741 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
3742 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
3744 IHTMLElement2_Release(elem
);
3747 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
3748 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
3750 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3754 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
3755 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
3756 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
3758 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
3759 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
3760 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
3762 IHTMLElement2_Release(elem
);
3765 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
3766 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
3768 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3769 LONG len
= 0xdeadbeef;
3772 hres
= IHTMLFormElement_get_length(form
, &len
);
3773 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3774 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
3776 IHTMLFormElement_Release(form
);
3779 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
3780 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
3782 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3783 BSTR action
= (void*)0xdeadbeef;
3786 hres
= IHTMLFormElement_get_action(form
, &action
);
3787 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
3789 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
3791 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
3793 SysFreeString(action
);
3794 IHTMLFormElement_Release(form
);
3797 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
3798 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
3800 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3801 BSTR tmp
= a2bstr(action
);
3804 hres
= IHTMLFormElement_put_action(form
, tmp
);
3805 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
3807 IHTMLFormElement_Release(form
);
3809 _test_form_action(line
, unk
, action
);
3812 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
3813 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
3815 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3816 BSTR method
= (void*)0xdeadbeef;
3819 hres
= IHTMLFormElement_get_method(form
, &method
);
3820 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
3822 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
3824 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
3826 SysFreeString(method
);
3827 IHTMLFormElement_Release(form
);
3830 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
3831 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
3833 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3834 BSTR tmp
= a2bstr(method
);
3837 hres
= IHTMLFormElement_put_method(form
, tmp
);
3838 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
3840 IHTMLFormElement_Release(form
);
3842 if(exp_hres
== S_OK
)
3843 _test_form_method(line
, unk
, method
);
3846 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
3847 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
3849 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3850 BSTR name
= (void*)0xdeadbeef;
3853 hres
= IHTMLFormElement_get_name(form
, &name
);
3854 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3856 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
3858 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
3860 SysFreeString(name
);
3861 IHTMLFormElement_Release(form
);
3864 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
3865 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
3867 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3868 BSTR tmp
= a2bstr(name
);
3871 hres
= IHTMLFormElement_put_name(form
, tmp
);
3872 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
3874 IHTMLFormElement_Release(form
);
3876 _test_form_name(line
, unk
, name
);
3879 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
3880 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
3882 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3883 BSTR encoding
= (void*)0xdeadbeef;
3886 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
3887 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
3889 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
3891 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
3893 SysFreeString(encoding
);
3894 IHTMLFormElement_Release(form
);
3897 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
3898 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
3900 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3901 BSTR tmp
= a2bstr(encoding
);
3904 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
3905 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
3907 IHTMLFormElement_Release(form
);
3909 if(exp_hres
== S_OK
)
3910 _test_form_encoding(line
, unk
, encoding
);
3913 #define test_form_elements(a) _test_form_elements(__LINE__,a)
3914 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
3916 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3921 hres
= IHTMLFormElement_get_elements(form
, &disp
);
3922 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
3923 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
3924 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
3926 IDispatch_Release(disp
);
3927 IHTMLFormElement_Release(form
);
3930 #define test_form_reset(a) _test_form_reset(__LINE__,a)
3931 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
3933 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3936 hres
= IHTMLFormElement_reset(form
);
3937 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
3939 IHTMLFormElement_Release(form
);
3942 static void test_form_target(IUnknown
*unk
)
3944 IHTMLFormElement
*form
= get_form_iface(unk
);
3947 static const char target
[] = "_blank";
3949 str
= a2bstr(target
);
3950 hres
= IHTMLFormElement_put_target(form
, str
);
3951 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
3954 hres
= IHTMLFormElement_get_target(form
, &str
);
3955 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
3956 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
3959 IHTMLFormElement_Release(form
);
3962 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
3963 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
3965 IHTMLMetaElement
*meta
;
3969 meta
= _get_metaelem_iface(line
, unk
);
3970 hres
= IHTMLMetaElement_get_name(meta
, &name
);
3971 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3972 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
3973 SysFreeString(name
);
3974 IHTMLMetaElement_Release(meta
);
3977 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
3978 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
3980 IHTMLMetaElement
*meta
;
3981 BSTR content
= NULL
;
3984 meta
= _get_metaelem_iface(line
, unk
);
3985 hres
= IHTMLMetaElement_get_content(meta
, &content
);
3986 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
3987 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
3988 SysFreeString(content
);
3989 IHTMLMetaElement_Release(meta
);
3992 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
3993 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
3995 IHTMLMetaElement
*meta
;
3999 meta
= _get_metaelem_iface(line
, unk
);
4000 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4001 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4002 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4004 IHTMLMetaElement_Release(meta
);
4007 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4008 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4010 IHTMLMetaElement
*meta
;
4014 meta
= _get_metaelem_iface(line
, unk
);
4015 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4016 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4018 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4020 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4022 IHTMLMetaElement_Release(meta
);
4025 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4026 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4028 BSTR val
= a2bstr(vala
);
4029 IHTMLMetaElement
*meta
;
4032 meta
= _get_metaelem_iface(line
, unk
);
4033 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4034 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4036 IHTMLMetaElement_Release(meta
);
4038 _test_meta_charset(line
, unk
, vala
);
4041 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4042 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4044 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4048 str
= a2bstr(exval
);
4049 hres
= IHTMLLinkElement_put_media(link
, str
);
4050 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4053 hres
= IHTMLLinkElement_get_media(link
, &str
);
4054 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4055 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4057 IHTMLLinkElement_Release(link
);
4060 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4061 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4063 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4064 VARIANT_BOOL b
= 10;
4067 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4068 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4069 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4071 IHTMLLinkElement_Release(link
);
4074 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4075 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4077 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4080 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4081 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4082 IHTMLLinkElement_Release(link
);
4083 _test_link_disabled(line
, elem
, v
);
4086 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4087 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4089 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4093 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4094 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4096 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4098 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4100 IHTMLLinkElement_Release(link
);
4103 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4104 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4106 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4107 BSTR str
= a2bstr(v
);
4110 hres
= IHTMLLinkElement_put_rel(link
, str
);
4111 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4113 IHTMLLinkElement_Release(link
);
4114 _test_link_rel(line
, elem
, v
);
4117 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4118 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4120 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4124 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4125 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4127 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4129 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4131 IHTMLLinkElement_Release(link
);
4134 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4135 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4137 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4138 BSTR str
= a2bstr(v
);
4141 hres
= IHTMLLinkElement_put_rev(link
, str
);
4142 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4144 IHTMLLinkElement_Release(link
);
4145 _test_link_rev(line
, elem
, v
);
4148 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4149 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4151 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4155 hres
= IHTMLLinkElement_get_type(link
, &type
);
4156 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4158 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4160 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4162 IHTMLLinkElement_Release(link
);
4165 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4166 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4171 str
= (void*)0xdeadbeef;
4172 hres
= IHTMLScriptElement_get_text(script
, &str
);
4173 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4174 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4178 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4179 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4181 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4182 BSTR str
= a2bstr(v
);
4185 hres
= IHTMLLinkElement_put_type(link
, str
);
4186 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4188 IHTMLLinkElement_Release(link
);
4189 _test_link_type(line
, elem
, v
);
4192 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4193 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4195 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4199 hres
= IHTMLLinkElement_get_href(link
, &href
);
4200 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4202 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4204 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4206 IHTMLLinkElement_Release(link
);
4209 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4210 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4212 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4213 BSTR str
= a2bstr(v
);
4216 hres
= IHTMLLinkElement_put_href(link
, str
);
4217 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4219 IHTMLLinkElement_Release(link
);
4220 _test_link_href(line
, elem
, v
);
4223 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4224 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4226 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4227 IHTMLDocument2
*doc
;
4232 hres
= IHTMLElement_get_document(elem
, &disp
);
4233 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4234 ok(disp
!= NULL
, "disp == NULL\n");
4236 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4237 IDispatch_Release(disp
);
4238 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4243 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4244 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4246 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4247 BSTR str
= a2bstr(attr_name
);
4248 IHTMLDOMAttribute
*attr
;
4251 attr
= (void*)0xdeadbeef;
4252 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4253 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4255 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4257 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4259 IHTMLElement4_Release(elem
);
4264 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4265 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4269 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4270 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4271 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4274 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4275 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4279 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4280 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4283 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4284 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4286 IHTMLDocument2
*doc
;
4290 hres
= IHTMLWindow2_get_document(window
, &doc
);
4291 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4292 ok(doc
!= NULL
, "disp == NULL\n");
4297 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4298 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4303 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4304 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4305 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4310 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4311 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4313 IHTMLElement
*elem
= NULL
;
4318 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4319 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4320 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4326 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4327 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4329 IHTMLDocument3
*doc3
;
4330 IHTMLDOMNode
*node
= NULL
;
4334 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4335 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4338 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4339 IHTMLDocument3_Release(doc3
);
4341 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4342 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4347 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4348 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4350 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4351 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4352 IHTMLDOMNode
*new_child
= NULL
;
4355 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4356 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4357 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4358 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4360 IHTMLDOMNode_Release(node
);
4361 IHTMLDOMNode_Release(child
);
4366 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4367 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4369 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4370 IHTMLDOMNode
*new_child
= NULL
;
4373 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4374 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4375 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4376 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4378 IHTMLDOMNode_Release(node
);
4383 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4384 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4386 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4387 IHTMLDOMNode
*new_node
= NULL
;
4390 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
4391 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
4392 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
4393 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
4395 IHTMLDOMNode_Release(node
);
4396 IHTMLDOMNode_Release(new_node
);
4399 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
4400 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
4405 hres
= IHTMLDocument2_get_title(doc
, &title
);
4406 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4407 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4408 SysFreeString(title
);
4411 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
4412 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
4417 tmp
= a2bstr(title
);
4418 hres
= IHTMLDocument2_put_title(doc
, tmp
);
4419 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4423 static void test_elem_bounding_client_rect(IUnknown
*unk
)
4425 IHTMLRect
*rect
, *rect2
;
4426 IHTMLElement2
*elem2
;
4430 elem2
= get_elem2_iface(unk
);
4431 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
4432 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4433 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
4434 IHTMLElement2_Release(elem2
);
4435 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4436 ok(rect
!= NULL
, "rect == NULL\n");
4437 ok(rect
!= rect2
, "rect == rect2\n");
4438 IHTMLRect_Release(rect2
);
4440 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
4443 hres
= IHTMLRect_get_top(rect
, &l
);
4444 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4445 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4448 hres
= IHTMLRect_get_left(rect
, &l
);
4449 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4450 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4453 hres
= IHTMLRect_get_bottom(rect
, &l
);
4454 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4455 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4458 hres
= IHTMLRect_get_right(rect
, &l
);
4459 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4460 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4462 IHTMLRect_Release(rect
);
4465 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
4466 const elem_type_t
*elem_types
, LONG len
)
4469 VARIANT name
, index
;
4473 V_VT(&index
) = VT_EMPTY
;
4474 V_VT(&name
) = VT_BSTR
;
4475 V_BSTR(&name
) = a2bstr(n
);
4477 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4478 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4480 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
4481 IDispatch_Release(disp
);
4483 V_VT(&index
) = VT_I4
;
4485 for(i
=0; i
<len
; i
++) {
4487 disp
= (void*)0xdeadbeef;
4488 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4489 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4490 ok(disp
!= NULL
, "disp == NULL\n");
4491 if(FAILED(hres
) || !disp
)
4494 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
4496 IDispatch_Release(disp
);
4500 disp
= (void*)0xdeadbeef;
4501 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4502 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4503 ok(disp
== NULL
, "disp != NULL\n");
4506 disp
= (void*)0xdeadbeef;
4507 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4508 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4509 ok(disp
== NULL
, "disp != NULL\n");
4511 SysFreeString(V_BSTR(&name
));
4514 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
4516 IHTMLElementCollection
*col
;
4518 IDispatch
*disp
= (void*)0xdeadbeef;
4519 VARIANT name
, index
;
4522 hres
= IHTMLDocument2_get_all(doc
, &col
);
4523 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
4524 ok(col
!= NULL
, "col == NULL\n");
4525 if(FAILED(hres
) || !col
)
4528 V_VT(&index
) = VT_EMPTY
;
4529 V_VT(&name
) = VT_BSTR
;
4530 V_BSTR(&name
) = a2bstr(id
);
4532 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4533 IHTMLElementCollection_Release(col
);
4534 SysFreeString(V_BSTR(&name
));
4535 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4536 if(!expect_success
) {
4537 ok(disp
== NULL
, "disp != NULL\n");
4541 ok(disp
!= NULL
, "disp == NULL\n");
4545 elem
= get_elem_iface((IUnknown
*)disp
);
4546 IDispatch_Release(disp
);
4551 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
4553 IHTMLDocument3
*doc3
;
4558 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4559 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
4562 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
4564 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
4566 IHTMLDocument3_Release(doc3
);
4571 static void test_select_elem(IHTMLSelectElement
*select
)
4573 IDispatch
*disp
, *disp2
;
4574 VARIANT name
, index
;
4577 test_select_type(select
, "select-one");
4578 test_select_length(select
, 2);
4579 test_select_selidx(select
, 0);
4580 test_select_put_selidx(select
, 1);
4582 test_select_set_value(select
, "val1");
4583 test_select_value(select
, "val1");
4585 test_select_get_disabled(select
, VARIANT_FALSE
);
4586 test_select_set_disabled(select
, VARIANT_TRUE
);
4587 test_select_set_disabled(select
, VARIANT_FALSE
);
4590 hres
= IHTMLSelectElement_get_options(select
, &disp
);
4591 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
4592 ok(disp
!= NULL
, "options == NULL\n");
4593 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
4594 IDispatch_Release(disp
);
4596 V_VT(&index
) = VT_EMPTY
;
4597 V_VT(&name
) = VT_I4
;
4599 disp
= (void*)0xdeadbeef;
4600 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4601 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4602 ok(!disp
, "disp = %p\n", disp
);
4605 disp
= (void*)0xdeadbeef;
4606 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4607 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4608 ok(!disp
, "disp = %p\n", disp
);
4611 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
4612 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
4615 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4616 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4617 ok(disp
!= NULL
, "disp = NULL\n");
4618 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
4620 V_VT(&index
) = VT_I4
;
4623 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
4624 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4625 ok(disp2
!= NULL
, "disp = NULL\n");
4626 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4627 IDispatch_Release(disp2
);
4628 IDispatch_Release(disp
);
4630 test_select_multiple(select
, VARIANT_FALSE
);
4631 test_select_set_multiple(select
, VARIANT_TRUE
);
4632 test_select_remove(select
);
4635 static void test_form_item(IHTMLElement
*elem
)
4637 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
4638 IDispatch
*disp
, *disp2
;
4639 VARIANT name
, index
;
4642 V_VT(&index
) = VT_EMPTY
;
4643 V_VT(&name
) = VT_I4
;
4645 disp
= (void*)0xdeadbeef;
4646 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4647 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4648 ok(!disp
, "disp = %p\n", disp
);
4651 disp
= (void*)0xdeadbeef;
4652 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4653 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4654 ok(!disp
, "disp = %p\n", disp
);
4657 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
4658 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4661 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4662 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4663 ok(disp
!= NULL
, "disp = NULL\n");
4664 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
4666 V_VT(&index
) = VT_I4
;
4669 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
4670 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4671 ok(disp2
!= NULL
, "disp = NULL\n");
4672 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4673 IDispatch_Release(disp2
);
4674 IDispatch_Release(disp
);
4677 static void test_create_option_elem(IHTMLDocument2
*doc
)
4679 IHTMLOptionElement
*option
;
4681 option
= create_option_elem(doc
, "test text", "test value");
4683 test_option_put_text(option
, "new text");
4684 test_option_put_value(option
, "new value");
4685 test_option_put_selected(option
, VARIANT_TRUE
);
4686 test_option_put_selected(option
, VARIANT_FALSE
);
4688 IHTMLOptionElement_Release(option
);
4691 static void test_create_img_elem(IHTMLDocument2
*doc
)
4693 IHTMLImgElement
*img
;
4695 img
= create_img_elem(doc
, 10, 15);
4698 test_img_put_width(img
, 5);
4699 test_img_put_height(img
, 20);
4701 IHTMLImgElement_Release(img
);
4705 img
= create_img_elem(doc
, -1, -1);
4708 test_img_put_width(img
, 5);
4709 test_img_put_height(img
, 20);
4711 IHTMLImgElement_Release(img
);
4715 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
4716 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
4718 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
4719 IHTMLElement
*ret_elem
= NULL
;
4720 BSTR str
= a2bstr(where
);
4723 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
4724 IHTMLElement2_Release(elem2
);
4726 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
4727 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
4728 IHTMLElement_Release(ret_elem
);
4731 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
4733 IHTMLElement
*elem
, *elem2
;
4735 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
4736 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
4738 elem
= test_create_elem(doc
, "BR");
4739 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
4740 IHTMLElement_Release(elem
);
4742 test_elem_all((IUnknown
*)parent
, br_br
, 1);
4744 elem
= test_create_elem(doc
, "BR");
4745 insert_adjacent_elem(parent
, "beforeend", elem
);
4747 test_elem_all((IUnknown
*)parent
, br_br
, 2);
4749 elem2
= test_create_elem(doc
, "DIV");
4750 insert_adjacent_elem(elem
, "beforebegin", elem2
);
4751 IHTMLElement_Release(elem2
);
4752 IHTMLElement_Release(elem
);
4754 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
4757 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
4759 IHTMLBodyElement
*body
;
4760 IHTMLTxtRange
*range
;
4764 elem
= doc_get_body(doc
);
4765 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
4766 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
4767 IHTMLElement_Release(elem
);
4769 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
4770 IHTMLBodyElement_Release(body
);
4771 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
4776 static void test_txtrange(IHTMLDocument2
*doc
)
4778 IHTMLTxtRange
*body_range
, *range
, *range2
;
4779 IHTMLSelectionObject
*selection
;
4780 IDispatch
*disp_range
;
4783 body_range
= test_create_body_range(doc
);
4785 test_range_text(body_range
, "test abc 123\r\nit's text");
4787 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4788 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4790 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
4791 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4792 test_range_isequal(range
, range2
, VARIANT_TRUE
);
4794 test_range_text(range
, "test abc 123\r\nit's text");
4795 test_range_text(body_range
, "test abc 123\r\nit's text");
4797 test_range_collapse(range
, TRUE
);
4798 test_range_isequal(range
, range2
, VARIANT_FALSE
);
4799 test_range_inrange(range
, range2
, VARIANT_FALSE
);
4800 test_range_inrange(range2
, range
, VARIANT_TRUE
);
4801 IHTMLTxtRange_Release(range2
);
4803 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4804 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
4805 test_range_move(range
, characterW
, 2, 2);
4806 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4808 test_range_collapse(range
, FALSE
);
4809 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
4811 test_range_collapse(range
, FALSE
);
4812 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4813 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
4814 test_range_move(range
, characterW
, 2, 2);
4815 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4816 test_range_moveend(range
, characterW
, -5, -5);
4817 test_range_text(range
, NULL
);
4818 test_range_moveend(range
, characterW
, 3, 3);
4819 test_range_text(range
, "c 1");
4820 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
4821 test_range_collapse(range
, TRUE
);
4822 test_range_move(range
, characterW
, 4, 4);
4823 test_range_moveend(range
, characterW
, 1, 1);
4824 test_range_text(range
, " ");
4825 test_range_move(range
, wordW
, 1, 1);
4826 test_range_moveend(range
, characterW
, 2, 2);
4827 test_range_text(range
, "ab");
4829 IHTMLTxtRange_Release(range
);
4831 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4832 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4834 test_range_text(range
, "test abc 123\r\nit's text");
4835 test_range_move(range
, characterW
, 3, 3);
4836 test_range_moveend(range
, characterW
, 1, 1);
4837 test_range_text(range
, "t");
4838 test_range_moveend(range
, characterW
, 3, 3);
4839 test_range_text(range
, "t ab");
4840 test_range_moveend(range
, characterW
, -2, -2);
4841 test_range_text(range
, "t ");
4842 test_range_move(range
, characterW
, 6, 6);
4843 test_range_moveend(range
, characterW
, 3, 3);
4844 test_range_text(range
, "123");
4845 test_range_moveend(range
, characterW
, 2, 2);
4846 test_range_text(range
, "123\r\ni");
4848 IHTMLTxtRange_Release(range
);
4850 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4851 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4853 test_range_move(range
, wordW
, 1, 1);
4854 test_range_moveend(range
, characterW
, 2, 2);
4855 test_range_text(range
, "ab");
4857 test_range_move(range
, characterW
, -2, -2);
4858 test_range_moveend(range
, characterW
, 2, 2);
4859 test_range_text(range
, "t ");
4861 test_range_move(range
, wordW
, 3, 3);
4862 test_range_move(range
, wordW
, -2, -2);
4863 test_range_moveend(range
, characterW
, 2, 2);
4864 test_range_text(range
, "ab");
4866 test_range_move(range
, characterW
, -6, -5);
4867 test_range_moveend(range
, characterW
, -1, 0);
4868 test_range_moveend(range
, characterW
, -6, 0);
4869 test_range_move(range
, characterW
, 2, 2);
4870 test_range_moveend(range
, characterW
, 2, 2);
4871 test_range_text(range
, "st");
4872 test_range_moveend(range
, characterW
, -6, -4);
4873 test_range_moveend(range
, characterW
, 2, 2);
4875 IHTMLTxtRange_Release(range
);
4877 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4878 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4880 test_range_move(range
, wordW
, 2, 2);
4881 test_range_moveend(range
, characterW
, 2, 2);
4882 test_range_text(range
, "12");
4884 test_range_move(range
, characterW
, 15, 14);
4885 test_range_move(range
, characterW
, -2, -2);
4886 test_range_moveend(range
, characterW
, 3, 2);
4887 test_range_text(range
, "t");
4888 test_range_moveend(range
, characterW
, -1, -1);
4889 test_range_text(range
, "t");
4890 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
4891 test_range_move(range
, characterW
, -2, -2);
4892 test_range_moveend(range
, characterW
, 2, 2);
4893 test_range_text(range
, "s ");
4894 test_range_move(range
, characterW
, 100, 7);
4895 test_range_move(range
, wordW
, 1, 0);
4896 test_range_move(range
, characterW
, -2, -2);
4897 test_range_moveend(range
, characterW
, 3, 2);
4898 test_range_text(range
, "t");
4900 IHTMLTxtRange_Release(range
);
4902 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4903 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4905 test_range_collapse(range
, TRUE
);
4906 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4907 test_range_put_text(range
, "word");
4908 test_range_text(body_range
, "wordabc 123\r\nit's text");
4909 test_range_text(range
, NULL
);
4910 test_range_moveend(range
, characterW
, 3, 3);
4911 test_range_text(range
, "abc");
4912 test_range_movestart(range
, characterW
, -2, -2);
4913 test_range_text(range
, "rdabc");
4914 test_range_movestart(range
, characterW
, 3, 3);
4915 test_range_text(range
, "bc");
4916 test_range_movestart(range
, characterW
, 4, 4);
4917 test_range_text(range
, NULL
);
4918 test_range_movestart(range
, characterW
, -3, -3);
4919 test_range_text(range
, "c 1");
4920 test_range_movestart(range
, characterW
, -7, -6);
4921 test_range_text(range
, "wordabc 1");
4922 test_range_movestart(range
, characterW
, 100, 22);
4923 test_range_text(range
, NULL
);
4925 IHTMLTxtRange_Release(range
);
4926 IHTMLTxtRange_Release(body_range
);
4928 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4929 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
4931 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
4932 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
4933 IHTMLSelectionObject_Release(selection
);
4935 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
4936 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
4937 IDispatch_Release(disp_range
);
4939 test_range_text(range
, NULL
);
4940 test_range_moveend(range
, characterW
, 3, 3);
4941 test_range_text(range
, "wor");
4942 test_range_parent(range
, ET_BODY
);
4943 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4944 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4945 test_range_move(range
, characterW
, 3, 3);
4946 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
4947 test_range_moveend(range
, characterW
, -4, -4);
4948 test_range_put_text(range
, "abc def ");
4949 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
4950 test_range_move(range
, wordW
, 1, 1);
4951 test_range_movestart(range
, characterW
, -1, -1);
4952 test_range_text(range
, " ");
4953 test_range_move(range
, wordW
, 1, 1);
4954 test_range_moveend(range
, characterW
, 3, 3);
4955 test_range_text(range
, "def");
4956 test_range_put_text(range
, "xyz");
4957 test_range_moveend(range
, characterW
, 1, 1);
4958 test_range_move(range
, wordW
, 1, 1);
4959 test_range_moveend(range
, characterW
, 2, 2);
4960 test_range_text(range
, "ab");
4962 IHTMLTxtRange_Release(range
);
4965 static void test_txtrange2(IHTMLDocument2
*doc
)
4967 IHTMLTxtRange
*range
;
4969 range
= test_create_body_range(doc
);
4971 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
4972 test_range_move(range
, characterW
, 5, 5);
4973 test_range_moveend(range
, characterW
, 1, 1);
4974 test_range_text(range
, "2");
4975 test_range_move(range
, characterW
, -3, -3);
4976 test_range_moveend(range
, characterW
, 3, 3);
4977 test_range_text(range
, "c\r\n\r\n1");
4978 test_range_collapse(range
, VARIANT_FALSE
);
4979 test_range_moveend(range
, characterW
, 4, 4);
4980 test_range_text(range
, "23");
4981 test_range_moveend(range
, characterW
, 1, 1);
4982 test_range_text(range
, "23\r\n\r\n\r\nd");
4983 test_range_moveend(range
, characterW
, -1, -1);
4984 test_range_text(range
, "23");
4985 test_range_moveend(range
, characterW
, -1, -1);
4986 test_range_text(range
, "23");
4987 test_range_moveend(range
, characterW
, -2, -2);
4988 test_range_text(range
, "2");
4990 IHTMLTxtRange_Release(range
);
4993 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
4994 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
4996 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5000 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5001 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5002 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5004 IHTMLDocument5_Release(doc
);
5007 static void test_location(IHTMLDocument2
*doc
)
5009 IHTMLLocation
*location
, *location2
;
5010 IHTMLWindow2
*window
;
5015 hres
= IHTMLDocument2_get_location(doc
, &location
);
5016 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5018 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5019 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5021 ok(location
== location2
, "location != location2\n");
5022 IHTMLLocation_Release(location2
);
5024 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5025 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5027 hres
= IHTMLWindow2_get_location(window
, &location2
);
5028 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5029 ok(location
== location2
, "location != location2\n");
5030 IHTMLLocation_Release(location2
);
5032 test_ifaces((IUnknown
*)location
, location_iids
);
5033 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5035 hres
= IHTMLLocation_get_pathname(location
, &str
);
5036 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5037 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5040 hres
= IHTMLLocation_get_href(location
, NULL
);
5041 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5043 hres
= IHTMLLocation_get_href(location
, &str
);
5044 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5045 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5048 ref
= IHTMLLocation_Release(location
);
5049 ok(!ref
, "location chould be destroyed here\n");
5052 static void test_plugins_col(IHTMLDocument2
*doc
)
5054 IHTMLPluginsCollection
*col
, *col2
;
5055 IHTMLWindow2
*window
;
5061 window
= get_doc_window(doc
);
5062 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5063 IHTMLWindow2_Release(window
);
5065 hres
= IOmNavigator_get_plugins(nav
, &col
);
5066 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5068 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5069 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5070 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5071 IHTMLPluginsCollection_Release(col2
);
5073 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5076 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5077 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5078 ok(!len
, "length = %d\n", len
);
5080 ref
= IHTMLPluginsCollection_Release(col
);
5081 ok(!ref
, "ref=%d\n", ref
);
5083 IOmNavigator_Release(nav
);
5086 static void test_mime_types_col(IOmNavigator
*nav
)
5088 IHTMLMimeTypesCollection
*col
, *col2
;
5093 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5094 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5096 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5097 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5098 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5099 IHTMLMimeTypesCollection_Release(col2
);
5101 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5103 length
= 0xdeadbeef;
5104 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5105 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5106 ok(!length
, "length = %d\n", length
);
5108 ref
= IHTMLMimeTypesCollection_Release(col
);
5109 ok(!ref
, "ref=%d\n", ref
);
5112 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5113 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5115 BSTR str
= (void*)0xdeadbeef;
5116 IHTMLFrameBase
*fbase
;
5119 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5120 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5122 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5123 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5125 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5127 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5130 IHTMLFrameBase_Release(fbase
);
5133 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5134 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5136 IHTMLFrameBase
*fbase
;
5140 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5141 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5143 str
= name
? a2bstr(name
) : NULL
;
5144 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5145 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5148 _test_framebase_name(line
, elem
, name
);
5149 IHTMLFrameBase_Release(fbase
);
5152 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5153 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5158 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5159 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5160 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5162 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5164 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5168 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5169 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5175 V_BSTR(&v
) = a2bstr(val
);
5176 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5177 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5181 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5182 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5187 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5188 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5189 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5191 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5193 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5197 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5198 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5204 V_BSTR(&v
) = a2bstr(val
);
5205 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5206 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5210 static void test_framebase(IUnknown
*unk
)
5212 IHTMLFrameBase
*fbase
;
5216 /* get/put scrolling */
5217 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5218 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5220 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5221 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5222 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5226 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5227 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5230 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5231 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5232 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5235 str
= a2bstr("junk");
5236 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5237 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5238 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5241 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5242 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5243 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5246 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5247 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5248 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
5251 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
5252 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
5255 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5256 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5257 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
5259 test_framebase_marginheight(fbase
, NULL
);
5260 set_framebase_marginheight(fbase
, "1px");
5261 test_framebase_marginheight(fbase
, "1");
5263 test_framebase_marginwidth(fbase
, NULL
);
5264 set_framebase_marginwidth(fbase
, "2px");
5265 test_framebase_marginwidth(fbase
, "2");
5267 IHTMLFrameBase_Release(fbase
);
5270 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
5271 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
5276 if(pLCIDToLocaleName
) {
5277 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
5278 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
5279 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
5281 win_skip("LCIDToLocaleName not available, unable to test language string\n");
5282 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
5286 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
5287 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
5289 IHTMLElementCollection
*col
;
5293 hres
= IHTMLTable_get_rows(table
, &col
);
5294 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5295 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
5296 if (hres
!= S_OK
|| col
== NULL
)
5298 hres
= IHTMLElementCollection_get_length(col
, &len
);
5299 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5300 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
5302 IHTMLElementCollection_Release(col
);
5305 static void test_navigator(IHTMLDocument2
*doc
)
5307 IHTMLWindow2
*window
;
5308 IOmNavigator
*navigator
, *navigator2
;
5316 static const WCHAR v40
[] = {'4','.','0'};
5318 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5319 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
5321 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
5322 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5323 ok(navigator
!= NULL
, "navigator == NULL\n");
5324 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
5326 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
5327 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5328 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
5330 IHTMLWindow2_Release(window
);
5331 IOmNavigator_Release(navigator2
);
5333 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
5334 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
5335 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5336 SysFreeString(bstr
);
5339 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
5340 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
5341 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5342 SysFreeString(bstr
);
5345 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
5346 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
5347 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
5348 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
5349 SysFreeString(bstr
);
5352 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
5353 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
5354 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
5355 SysFreeString(bstr
);
5358 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5359 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5360 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
5361 SysFreeString(bstr
);
5364 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
5365 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
5366 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
5367 SysFreeString(bstr
);
5369 if (pGetUserDefaultUILanguage
)
5372 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
5373 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
5374 test_language_string(bstr
, pGetUserDefaultUILanguage());
5375 SysFreeString(bstr
);
5378 win_skip("GetUserDefaultUILanguage not available\n");
5381 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
5382 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
5383 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
5384 SysFreeString(bstr
);
5386 hres
= IOmNavigator_toString(navigator
, NULL
);
5387 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5390 hres
= IOmNavigator_toString(navigator
, &bstr
);
5391 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5392 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
5393 SysFreeString(bstr
);
5396 hres
= IOmNavigator_get_onLine(navigator
, &b
);
5397 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
5398 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
5401 hres
= ObtainUserAgentString(0, buf
, &size
);
5402 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
5405 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
5406 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
5407 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
5408 SysFreeString(bstr
);
5410 if(!strncmp(buf
, "Mozilla/", 8)) {
5412 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5413 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5414 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
5415 SysFreeString(bstr
);
5417 skip("nonstandard user agent\n");
5421 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
5422 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
5423 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
5424 SysFreeString(bstr
);
5426 test_mime_types_col(navigator
);
5428 ref
= IOmNavigator_Release(navigator
);
5429 ok(!ref
, "navigator should be destroyed here\n");
5432 static void test_screen(IHTMLWindow2
*window
)
5434 IHTMLScreen
*screen
, *screen2
;
5435 IDispatchEx
*dispex
;
5442 hres
= IHTMLWindow2_get_screen(window
, &screen
);
5443 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5444 ok(screen
!= NULL
, "screen == NULL\n");
5447 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
5448 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5449 ok(screen2
!= NULL
, "screen == NULL\n");
5450 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
5451 IHTMLScreen_Release(screen2
);
5453 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
5454 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
5455 if(SUCCEEDED(hres
)) {
5456 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
5457 IDispatchEx_Release(dispex
);
5460 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
5462 exl
= GetDeviceCaps(hdc
, HORZRES
);
5464 hres
= IHTMLScreen_get_width(screen
, &l
);
5465 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
5466 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
5468 exl
= GetDeviceCaps(hdc
, VERTRES
);
5470 hres
= IHTMLScreen_get_height(screen
, &l
);
5471 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5472 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5474 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
5476 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
5477 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5478 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5482 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
5485 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
5486 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
5487 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
5490 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
5491 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
5492 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
5494 IHTMLScreen_Release(screen
);
5497 static void test_default_selection(IHTMLDocument2
*doc
)
5499 IHTMLSelectionObject
*selection
;
5500 IHTMLTxtRange
*range
;
5505 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5506 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5508 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5509 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5510 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
5513 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
5514 IHTMLSelectionObject_Release(selection
);
5515 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
5517 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
5518 IDispatch_Release(disp
);
5519 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
5521 test_range_text(range
, NULL
);
5522 IHTMLTxtRange_Release(range
);
5525 static void test_doc_elem(IHTMLDocument2
*doc
)
5527 IHTMLDocument2
*doc_node
, *owner_doc
;
5529 IHTMLDocument3
*doc3
;
5533 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5534 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
5536 hres
= IHTMLDocument2_toString(doc
, &bstr
);
5537 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5538 ok(!strcmp_wa(bstr
, "[object]"),
5539 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
5540 SysFreeString(bstr
);
5542 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
5543 IHTMLDocument3_Release(doc3
);
5544 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
5546 test_node_name((IUnknown
*)elem
, "HTML");
5547 test_elem_tag((IUnknown
*)elem
, "HTML");
5549 doc_node
= get_doc_node(doc
);
5550 owner_doc
= get_owner_doc((IUnknown
*)elem
);
5551 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
5552 IHTMLDocument2_Release(owner_doc
);
5554 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
5555 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5556 IHTMLDocument2_Release(doc_node
);
5558 test_elem_client_rect((IUnknown
*)elem
);
5560 IHTMLElement_Release(elem
);
5563 static void test_default_body(IHTMLBodyElement
*body
)
5570 bstr
= (void*)0xdeadbeef;
5571 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
5572 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
5573 ok(bstr
== NULL
, "bstr != NULL\n");
5575 l
= elem_get_scroll_height((IUnknown
*)body
);
5576 ok(l
!= -1, "scrollHeight == -1\n");
5577 l
= elem_get_scroll_width((IUnknown
*)body
);
5578 ok(l
!= -1, "scrollWidth == -1\n");
5579 l
= elem_get_scroll_top((IUnknown
*)body
);
5580 ok(!l
, "scrollTop = %d\n", l
);
5581 elem_get_scroll_left((IUnknown
*)body
);
5583 /* get_text tests */
5584 hres
= IHTMLBodyElement_get_text(body
, &v
);
5585 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5586 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5587 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
5589 /* get_text - Invalid Text */
5591 V_BSTR(&v
) = a2bstr("Invalid");
5592 hres
= IHTMLBodyElement_put_text(body
, v
);
5593 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5597 hres
= IHTMLBodyElement_get_text(body
, &v
);
5598 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5599 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5600 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
5603 /* get_text - Valid Text */
5605 V_BSTR(&v
) = a2bstr("#FF0000");
5606 hres
= IHTMLBodyElement_put_text(body
, v
);
5607 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5611 hres
= IHTMLBodyElement_get_text(body
, &v
);
5612 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5613 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5614 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
5618 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
5619 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
5624 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
5625 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
5626 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
5630 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
5631 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
5633 BSTR str
= a2bstr(val
);
5636 hres
= IHTMLBodyElement_put_scroll(body
, str
);
5637 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
5640 _test_body_scroll(line
, body
, val
);
5643 static void test_body_funs(IHTMLBodyElement
*body
)
5645 VARIANT vbg
, vDefaultbg
;
5648 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5649 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5650 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5651 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5653 V_VT(&vbg
) = VT_BSTR
;
5654 V_BSTR(&vbg
) = a2bstr("red");
5655 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5656 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5659 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5660 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5661 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
5662 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5665 /* Restore Originial */
5666 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5667 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5668 VariantClear(&vDefaultbg
);
5670 test_body_scroll(body
, NULL
);
5671 set_body_scroll(body
, "yes");
5672 set_body_scroll(body
, "no");
5673 set_body_scroll(body
, "auto");
5676 static void test_history(IHTMLWindow2
*window
)
5678 IOmHistory
*history
, *history2
;
5682 hres
= IHTMLWindow2_get_history(window
, &history
);
5683 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5684 ok(history
!= NULL
, "history = NULL\n");
5686 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
5689 hres
= IHTMLWindow2_get_history(window
, &history2
);
5690 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5691 ok(history2
!= NULL
, "history2 = NULL\n");
5692 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
5694 IOmHistory_Release(history2
);
5695 IOmHistory_Release(history
);
5698 static void test_window(IHTMLDocument2
*doc
)
5700 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
5701 IHTMLDocument2
*doc2
= NULL
;
5708 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5709 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5710 test_ifaces((IUnknown
*)window
, window_iids
);
5711 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
5713 IUnknown_Release(unk
);
5715 win_skip("IID_ITravelLogClient not supported\n");
5717 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5719 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5720 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5721 ok(doc2
!= NULL
, "doc2 == NULL\n");
5723 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5724 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5725 test_class_info((IUnknown
*)doc2
);
5727 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5728 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
5729 test_class_info((IUnknown
*)doc
);
5731 unk
= (void*)0xdeadbeef;
5732 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5733 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5734 ok(!unk
, "unk = %p\n", unk
);
5736 IHTMLDocument2_Release(doc2
);
5738 hres
= IHTMLWindow2_get_window(window
, &window2
);
5739 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5740 ok(window2
!= NULL
, "window2 == NULL\n");
5742 hres
= IHTMLWindow2_get_self(window
, &self
);
5743 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5744 ok(window2
!= NULL
, "self == NULL\n");
5746 ok(self
== window2
, "self != window2\n");
5748 IHTMLWindow2_Release(window2
);
5751 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5752 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5753 ok(disp
== (void*)window
, "disp != window\n");
5754 IDispatch_Release(disp
);
5756 hres
= IHTMLWindow2_toString(window
, NULL
);
5757 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5760 hres
= IHTMLWindow2_toString(window
, &str
);
5761 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5762 ok(!strcmp_wa(str
, "[object]") ||
5763 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
5766 V_VT(&v
) = VT_ERROR
;
5767 hres
= IHTMLWindow2_get_opener(window
, &v
);
5768 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
5769 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
5772 hres
= IHTMLWindow2_get_parent(window
, &parent
);
5773 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
5774 ok(parent
!= NULL
, "parent == NULL\n");
5775 ok(parent
== self
, "parent != window\n");
5776 IHTMLWindow2_Release(parent
);
5777 IHTMLWindow2_Release(self
);
5779 test_window_name(window
, NULL
);
5780 set_window_name(window
, "test");
5781 test_window_length(window
, 0);
5782 test_screen(window
);
5783 test_window_status(window
);
5784 set_window_status(window
, "Test!");
5785 test_history(window
);
5787 IHTMLWindow2_Release(window
);
5790 static void test_dom_implementation(IHTMLDocument2
*doc
)
5792 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
5793 IHTMLDOMImplementation
*dom_implementation
;
5799 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
5800 IHTMLDocument5_Release(doc5
);
5801 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
5802 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
5804 str
= a2bstr("test");
5806 V_BSTR(&v
) = a2bstr("1.0");
5808 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
5811 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
5812 ok(!b
, "hasFeature returned %x\n", b
);
5814 IHTMLDOMImplementation_Release(dom_implementation
);
5817 static void test_defaults(IHTMLDocument2
*doc
)
5819 IHTMLStyleSheetsCollection
*stylesheetcol
;
5820 IHTMLCurrentStyle
*cstyle
;
5821 IHTMLBodyElement
*body
;
5822 IHTMLElement2
*elem2
;
5828 IHTMLElementCollection
*collection
;
5830 elem
= doc_get_body(doc
);
5832 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5833 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5835 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5836 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5839 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5840 IHTMLElementCollection_Release(collection
);
5843 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5844 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5846 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5847 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5850 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5851 IHTMLElementCollection_Release(collection
);
5854 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5855 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5857 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5858 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5861 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5862 IHTMLElementCollection_Release(collection
);
5865 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5866 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5868 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5869 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5872 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5873 IHTMLElementCollection_Release(collection
);
5876 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5877 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5879 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5880 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5883 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5884 IHTMLElementCollection_Release(collection
);
5887 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5888 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5889 test_default_body(body
);
5890 test_body_funs(body
);
5891 IHTMLBodyElement_Release(body
);
5893 hres
= IHTMLElement_get_style(elem
, &style
);
5894 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5896 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
5897 test_ifaces((IUnknown
*)style
, style_iids
);
5898 IHTMLStyle_Release(style
);
5901 hres
= IHTMLDocument2_get_charset(doc
, &str
);
5902 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
5903 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
5907 test_compatmode(doc
, "BackCompat");
5909 test_navigator(doc
);
5910 test_plugins_col(doc
);
5912 elem2
= get_elem2_iface((IUnknown
*)elem
);
5913 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5914 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5915 if(SUCCEEDED(hres
)) {
5918 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
5919 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
5921 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
5923 IUnknown_Release(unk
);
5926 /*IE6 doesn't have interface */
5927 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
5930 IHTMLCurrentStyle_Release(cstyle
);
5932 IHTMLElement2_Release(elem2
);
5934 IHTMLElement_Release(elem
);
5936 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5937 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5940 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5941 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5942 ok(l
== 0, "length = %d\n", l
);
5944 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5946 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5947 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5949 test_default_selection(doc
);
5950 test_doc_title(doc
, "");
5951 test_dom_implementation(doc
);
5954 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
5955 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
5957 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
5961 str
= (void*)0xdeadbeef;
5962 hres
= IHTMLButtonElement_get_name(button
, &str
);
5963 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
5965 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
5967 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5969 IHTMLButtonElement_Release(button
);
5972 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
5973 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5975 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
5976 BSTR str
= a2bstr(name
);
5979 hres
= IHTMLButtonElement_put_name(button
, str
);
5980 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
5982 IHTMLButtonElement_Release(button
);
5984 _test_button_name(line
, elem
, name
);
5987 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
5988 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
5990 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
5991 VARIANT_BOOL disabled
= 100;
5994 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
5995 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
5996 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
5997 IHTMLButtonElement_Release(button
);
5999 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6002 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6003 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6005 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6008 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6009 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6010 IHTMLButtonElement_Release(button
);
6012 _test_button_get_disabled(line
, elem
, b
);
6015 static void test_button_elem(IHTMLElement
*elem
)
6017 test_button_name(elem
, NULL
);
6018 set_button_name(elem
, "button name");
6021 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6022 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6023 IHTMLTableRow
*row
, LONG len
, const char *id
)
6025 IHTMLElementCollection
*col
;
6031 hres
= IHTMLTableRow_get_cells(row
, &col
);
6032 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6033 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6035 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6036 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6037 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6039 V_VT(&var
) = VT_BSTR
;
6040 V_BSTR(&var
) = a2bstr(id
);
6041 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6042 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6043 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6046 IDispatch_Release(disp
);
6047 IHTMLElementCollection_Release(col
);
6050 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6054 IHTMLTableCell
*cell
;
6056 hres
= IHTMLTableRow_deleteCell(row
, 0);
6057 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6058 test_tr_possess(elem
, row
, 1, "td2");
6060 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6061 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6062 ok(disp
!= NULL
, "disp == NULL\n");
6063 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6064 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6065 ok(cell
!= NULL
, "cell == NULL\n");
6066 if (SUCCEEDED(hres
))
6067 IHTMLTableCell_Release(cell
);
6068 test_tr_possess(elem
, row
, 2, "td2");
6069 IDispatch_Release(disp
);
6072 static void test_tr_elem(IHTMLElement
*elem
)
6074 IHTMLElementCollection
*col
;
6079 VARIANT vbg
, vDefaultbg
;
6081 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6083 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6084 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6089 hres
= IHTMLTableRow_get_cells(row
, &col
);
6090 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6091 ok(col
!= NULL
, "get_cells returned NULL\n");
6093 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6094 IHTMLElementCollection_Release(col
);
6096 bstr
= a2bstr("left");
6097 hres
= IHTMLTableRow_put_align(row
, bstr
);
6098 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6099 SysFreeString(bstr
);
6102 hres
= IHTMLTableRow_get_align(row
, &bstr
);
6103 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6104 ok(bstr
!= NULL
, "get_align returned NULL\n");
6105 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6106 SysFreeString(bstr
);
6108 bstr
= a2bstr("top");
6109 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
6110 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
6111 SysFreeString(bstr
);
6114 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
6115 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
6116 ok(bstr
!= NULL
, "get_valign returned NULL\n");
6117 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
6118 SysFreeString(bstr
);
6121 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
6122 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6123 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
6126 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
6127 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
6128 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
6130 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
6131 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6132 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6133 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6135 V_VT(&vbg
) = VT_BSTR
;
6136 V_BSTR(&vbg
) = a2bstr("red");
6137 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6138 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6141 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6142 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6143 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6144 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6148 V_I4(&vbg
) = 0xff0000;
6149 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6150 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6153 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6154 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6155 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6156 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6159 /* Restore Originial */
6160 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
6161 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6162 VariantClear(&vDefaultbg
);
6164 test_tr_modify(elem
, row
);
6166 IHTMLTableRow_Release(row
);
6169 static void test_td_elem(IHTMLElement
*elem
)
6171 IHTMLTableCell
*cell
;
6175 VARIANT vbg
, vDefaultbg
;
6177 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
6178 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6183 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
6184 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
6185 ok(lval
== 1, "Expected 1, got %d\n", lval
);
6187 str
= a2bstr("left");
6188 hres
= IHTMLTableCell_put_align(cell
, str
);
6189 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
6193 hres
= IHTMLTableCell_get_align(cell
, &str
);
6194 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6195 ok(str
!= NULL
, "str is NULL\n");
6196 if (str
!= NULL
&& hres
== S_OK
) {
6197 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
6201 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
6202 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6203 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6204 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6206 V_VT(&vbg
) = VT_BSTR
;
6207 V_BSTR(&vbg
) = a2bstr("red");
6208 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6209 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6212 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6213 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6214 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6215 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6219 V_I4(&vbg
) = 0xff0000;
6220 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6221 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6224 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6225 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6226 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6227 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6230 /* Restore Originial */
6231 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
6232 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6233 VariantClear(&vDefaultbg
);
6235 IHTMLTableCell_Release(cell
);
6238 static void test_label_elem(IHTMLElement
*elem
)
6240 IHTMLLabelElement
*label
;
6244 label
= get_label_iface((IUnknown
*)elem
);
6247 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6248 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6249 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6253 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6254 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6257 str
= (void*)0xdeadbeef;
6258 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6259 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6260 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
6262 str
= a2bstr("abc");
6263 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6264 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6268 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6269 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6270 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6273 IHTMLLabelElement_Release(label
);
6276 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
6277 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
6282 V_VT(&v
) = VT_ERROR
;
6283 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
6284 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
6285 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
6287 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
6289 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6293 static void test_table_modify(IHTMLTable
*table
)
6300 test_table_length(table
, 2);
6302 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
6303 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
6304 ok(disp
!= NULL
, "disp == NULL\n");
6305 test_table_length(table
, 3);
6306 if (hres
!= S_OK
|| disp
== NULL
)
6309 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
6310 IDispatch_Release(disp
);
6312 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
6313 ok(row
!= NULL
, "row == NULL\n");
6316 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
6317 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6318 ok(index
== 0, "index = %d, expected 0\n", index
);
6320 IHTMLTableRow_Release(row
);
6322 hres
= IHTMLTable_deleteRow(table
, 0);
6323 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
6324 test_table_length(table
, 2);
6327 static void test_table_elem(IHTMLElement
*elem
)
6329 IHTMLElementCollection
*col
;
6331 IHTMLTable3
*table3
;
6336 VARIANT vbg
, vDefaultbg
;
6338 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
6339 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
6340 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
6342 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
6343 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
6347 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
6348 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
6353 hres
= IHTMLTable_get_rows(table
, &col
);
6354 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6355 ok(col
!= NULL
, "get_rows returned NULL\n");
6357 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
6358 IHTMLElementCollection_Release(col
);
6360 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6362 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
6363 test_elem_tag((IUnknown
*)node
, "TABLE");
6364 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6365 IHTMLDOMNode_Release(node
);
6367 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
6368 test_elem_tag((IUnknown
*)node
, "TABLE");
6369 test_elem_all((IUnknown
*)node
, NULL
, 0);
6370 IHTMLDOMNode_Release(node
);
6373 hres
= IHTMLTable_get_tBodies(table
, &col
);
6374 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
6375 ok(col
!= NULL
, "get_tBodies returned NULL\n");
6377 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
6378 IHTMLElementCollection_Release(col
);
6380 test_table_cell_spacing(table
, NULL
);
6384 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6385 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6386 test_table_cell_spacing(table
, "10");
6389 V_BSTR(&v
) = a2bstr("11");
6390 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6391 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6392 test_table_cell_spacing(table
, "11");
6395 bstr
= a2bstr("left");
6396 hres
= IHTMLTable_put_align(table
, bstr
);
6397 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6398 SysFreeString(bstr
);
6401 hres
= IHTMLTable_get_align(table
, &bstr
);
6402 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6403 ok(bstr
!= NULL
, "get_align returned NULL\n");
6404 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6405 SysFreeString(bstr
);
6407 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
6408 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6409 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6410 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6412 V_VT(&vbg
) = VT_BSTR
;
6413 V_BSTR(&vbg
) = a2bstr("red");
6414 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6415 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6418 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6419 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6420 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6421 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6425 V_I4(&vbg
) = 0xff0000;
6426 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6427 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6430 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6431 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6432 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6433 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6436 /* Restore Originial */
6437 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
6438 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6439 VariantClear(&vDefaultbg
);
6442 V_BSTR(&v
) = a2bstr("11");
6443 hres
= IHTMLTable_put_width(table
, v
);
6444 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6446 IHTMLTable_get_width(table
, &v
);
6447 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6448 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6452 V_BSTR(&v
) = a2bstr("11.9");
6453 hres
= IHTMLTable_put_width(table
, v
);
6454 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6456 IHTMLTable_get_width(table
, &v
);
6457 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6458 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6462 V_BSTR(&v
) = a2bstr("40.2%");
6463 hres
= IHTMLTable_put_width(table
, v
);
6464 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6466 IHTMLTable_get_width(table
, &v
);
6467 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6468 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6473 hres
= IHTMLTable_put_width(table
, v
);
6474 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6475 IHTMLTable_get_width(table
, &v
);
6476 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6477 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6482 hres
= IHTMLTable_put_width(table
, v
);
6483 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6484 IHTMLTable_get_width(table
, &v
);
6485 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6486 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6490 bstr
= a2bstr("box");
6491 hres
= IHTMLTable_put_frame(table
, bstr
);
6492 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
6493 SysFreeString(bstr
);
6494 hres
= IHTMLTable_get_frame(table
, &bstr
);
6495 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
6496 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
6497 SysFreeString(bstr
);
6499 test_table_modify(table
);
6500 bstr
= a2bstr("summary");
6501 hres
= IHTMLTable3_put_summary(table3
, bstr
);
6502 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
6503 SysFreeString(bstr
);
6505 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
6506 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
6507 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
6508 SysFreeString(bstr
);
6510 IHTMLTable3_Release(table3
);
6511 IHTMLTable_Release(table
);
6514 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
6523 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6524 SafeArrayAccessData(sa
, (void**)&var
);
6525 V_VT(var
) = VT_BSTR
;
6526 V_BSTR(var
) = a2bstr(text
);
6527 SafeArrayUnaccessData(sa
);
6530 hres
= IHTMLDocument2_writeln(doc
, sa
);
6532 hres
= IHTMLDocument2_write(doc
, sa
);
6533 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6535 SafeArrayDestroy(sa
);
6538 static void doc_complex_write(IHTMLDocument2
*doc
)
6540 SAFEARRAYBOUND dim
= {5, 0};
6545 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6546 SafeArrayAccessData(sa
, (void**)&args
);
6548 V_VT(args
) = VT_BSTR
;
6549 V_BSTR(args
) = a2bstr("<body i4val=\"");
6550 V_VT(args
+1) = VT_I4
;
6552 V_VT(args
+2) = VT_BSTR
;
6553 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
6554 V_VT(args
+3) = VT_R8
;
6555 V_R8(args
+3) = 3.14;
6556 V_VT(args
+4) = VT_BSTR
;
6557 V_BSTR(args
+4) = a2bstr("\">");
6558 SafeArrayUnaccessData(sa
);
6560 hres
= IHTMLDocument2_write(doc
, sa
);
6561 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6563 SafeArrayDestroy(sa
);
6566 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
6568 IHTMLDocument2
*window_doc
, *elem_doc
;
6569 IHTMLFrameElement3
*frame_elem3
;
6570 IHTMLWindow2
*content_window
;
6573 content_window
= get_frame_content_window(frame_elem
);
6574 test_ifaces((IUnknown
*)content_window
, window_iids
);
6575 window_doc
= get_window_doc(content_window
);
6576 IHTMLWindow2_Release(content_window
);
6578 elem_doc
= get_elem_doc(frame_elem
);
6579 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
6582 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
6583 if(SUCCEEDED(hres
)) {
6584 IDispatch
*disp
= NULL
;
6586 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
6587 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6588 ok(disp
!= NULL
, "contentDocument == NULL\n");
6589 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
6591 IDispatch_Release(disp
);
6592 IHTMLFrameElement3_Release(frame_elem3
);
6594 win_skip("IHTMLFrameElement3 not supported\n");
6598 IHTMLDocument2_Release(elem_doc
);
6599 IHTMLDocument2_Release(window_doc
);
6602 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
6603 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6605 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6609 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
6610 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6611 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
6613 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6615 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6617 IHTMLIFrameElement2_Release(iframe
);
6620 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
6621 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
6623 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6628 V_BSTR(&v
) = a2bstr(val
);
6629 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
6630 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
6632 IHTMLIFrameElement2_Release(iframe
);
6635 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
6636 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6638 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6642 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
6643 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6644 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
6646 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6648 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6650 IHTMLIFrameElement2_Release(iframe
);
6653 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
6654 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
6656 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6661 V_BSTR(&v
) = a2bstr(val
);
6662 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
6663 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
6665 IHTMLIFrameElement2_Release(iframe
);
6668 static void test_iframe_elem(IHTMLElement
*elem
)
6670 IHTMLDocument2
*content_doc
, *owner_doc
;
6671 IHTMLIFrameElement3
*iframe3
;
6672 IHTMLElementCollection
*col
;
6673 IHTMLWindow2
*content_window
;
6680 static const elem_type_t all_types
[] = {
6688 test_frame_doc((IUnknown
*)elem
, TRUE
);
6689 test_framebase((IUnknown
*)elem
);
6691 content_window
= get_frame_content_window((IUnknown
*)elem
);
6692 test_ifaces((IUnknown
*)content_window
, window_iids
);
6693 test_window_length(content_window
, 0);
6695 content_doc
= get_window_doc(content_window
);
6696 IHTMLWindow2_Release(content_window
);
6698 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
6699 if(SUCCEEDED(hres
)) {
6700 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
6701 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6702 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
6703 IDispatch_Release(disp
);
6705 IHTMLIFrameElement3_Release(iframe3
);
6707 win_skip("IHTMLIFrameElement3 not supported\n");
6710 test_iframe_height(elem
, NULL
);
6711 set_iframe_height(elem
, "100px");
6712 set_iframe_height(elem
, "50%");
6713 test_iframe_height(elem
, "50%");
6715 test_iframe_width(elem
, NULL
);
6716 set_iframe_width(elem
, "150px");
6717 set_iframe_width(elem
, "70%");
6718 test_iframe_width(elem
, "70%");
6720 str
= a2bstr("text/html");
6721 V_VT(&errv
) = VT_ERROR
;
6723 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
6725 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
6726 ok(disp
!= NULL
, "disp == NULL\n");
6727 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
6728 IDispatch_Release(disp
);
6730 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
6731 doc_complex_write(content_doc
);
6732 doc_write(content_doc
, TRUE
, "<br />");
6733 doc_write(content_doc
, TRUE
, "</html>");
6735 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
6736 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6737 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6738 IHTMLElementCollection_Release(col
);
6740 body
= doc_get_body(content_doc
);
6741 test_elem_attr(body
, "i4val", "4");
6742 test_elem_attr(body
, "r8val", "3.14");
6743 IHTMLElement_Release(body
);
6745 hres
= IHTMLDocument2_close(content_doc
);
6746 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
6748 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
6749 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6751 IHTMLDocument2_Release(content_doc
);
6754 static void test_stylesheet(IDispatch
*disp
)
6756 IHTMLStyleSheetRulesCollection
*col
= NULL
;
6757 IHTMLStyleSheet
*stylesheet
;
6761 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
6763 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
6764 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
6766 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
6767 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
6768 ok(col
!= NULL
, "col == NULL\n");
6770 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
6771 IHTMLStyleSheetRulesCollection_Release(col
);
6773 href
= (void*)0xdeadbeef;
6774 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
6775 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
6776 ok(href
== NULL
, "got href != NULL\n");
6777 SysFreeString(href
);
6779 IHTMLStyleSheet_Release(stylesheet
);
6782 static void test_stylesheets(IHTMLDocument2
*doc
)
6784 IHTMLStyleSheetsCollection
*col
= NULL
;
6789 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
6790 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6791 ok(col
!= NULL
, "col == NULL\n");
6793 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
6795 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
6796 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6797 ok(len
== 1, "len=%d\n", len
);
6803 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
6804 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
6805 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
6806 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
6807 test_stylesheet(V_DISPATCH(&res
));
6814 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
6815 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
6816 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
6819 IHTMLStyleSheetsCollection_Release(col
);
6822 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
6824 IDispatchEx
*dispex
;
6826 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
6834 static const WCHAR w0
[] = {'0',0};
6835 static const WCHAR w100
[] = {'1','0','0',0};
6837 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
6838 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
6840 bstr
= SysAllocString(w0
);
6841 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6842 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6843 SysFreeString(bstr
);
6846 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
6847 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
6848 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
6849 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
6850 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
6851 type
= get_node_type((IUnknown
*)node
);
6852 ok(type
== 3, "type=%d\n", type
);
6853 IHTMLDOMNode_Release(node
);
6856 bstr
= SysAllocString(w100
);
6857 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6858 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
6859 SysFreeString(bstr
);
6861 IDispatchEx_Release(dispex
);
6864 static void test_enum_children(IUnknown
*unk
, unsigned len
)
6866 IEnumVARIANT
*enum_var
;
6871 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
6872 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
6874 for(i
=0; i
<len
; i
++) {
6876 V_VT(&v
) = VT_ERROR
;
6877 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
6878 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
6880 ok(fetched
== 1, "fetched = %d\n", fetched
);
6881 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
6882 IDispatch_Release(V_DISPATCH(&v
));
6885 fetched
= 0xdeadbeef;
6887 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
6888 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
6889 ok(fetched
== 0, "fetched = %d\n", fetched
);
6890 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
6892 hres
= IEnumVARIANT_Reset(enum_var
);
6893 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
6895 fetched
= 0xdeadbeef;
6897 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
6898 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
6899 ok(fetched
== 0, "fetched = %d\n", fetched
);
6900 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
6902 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
6903 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
6905 hres
= IEnumVARIANT_Reset(enum_var
);
6906 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
6908 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
6909 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
6911 IEnumVARIANT_Release(enum_var
);
6914 static void test_elems(IHTMLDocument2
*doc
)
6916 IHTMLElementCollection
*col
;
6917 IHTMLDOMChildrenCollection
*child_col
;
6918 IHTMLElement
*elem
, *elem2
, *elem3
;
6919 IHTMLDOMNode
*node
, *node2
;
6920 IHTMLWindow2
*window
;
6924 IHTMLElementCollection
*collection
;
6925 IHTMLDocument3
*doc3
;
6928 static const elem_type_t all_types
[] = {
6961 static const elem_type_t item_types
[] = {
6967 hres
= IHTMLDocument2_get_all(doc
, &col
);
6968 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6969 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6970 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
6972 elem
= get_elem_col_item_idx(col
, 0);
6973 test_elem_source_index(elem
, 0);
6974 IHTMLElement_Release(elem
);
6976 elem
= get_elem_col_item_idx(col
, 3);
6977 test_elem_source_index(elem
, 3);
6978 IHTMLElement_Release(elem
);
6980 IHTMLElementCollection_Release(col
);
6982 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6983 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6986 static const elem_type_t images_types
[] = {ET_IMG
};
6987 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
6989 IHTMLElementCollection_Release(collection
);
6992 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6993 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6996 static const elem_type_t images_types
[] = {ET_A
};
6997 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
6999 IHTMLElementCollection_Release(collection
);
7002 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7003 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7006 static const elem_type_t anchor_types
[] = {ET_A
};
7007 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7009 IHTMLElementCollection_Release(collection
);
7012 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7013 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7015 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7016 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7017 IHTMLElementCollection_Release(collection
);
7020 test_plugins_col(doc
);
7022 elem
= get_doc_elem(doc
);
7023 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
7024 IHTMLElement_Release(elem
);
7026 get_elem_by_id(doc
, "xxx", FALSE
);
7027 elem
= get_doc_elem_by_id(doc
, "xxx");
7028 ok(!elem
, "elem != NULL\n");
7030 elem
= get_doc_elem_by_id(doc
, "s");
7031 ok(elem
!= NULL
, "elem == NULL\n");
7033 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
7034 test_elem_attr(elem
, "xxx", NULL
);
7035 test_elem_attr(elem
, "id", "s");
7036 test_elem_class((IUnknown
*)elem
, NULL
);
7037 test_elem_set_class((IUnknown
*)elem
, "cl");
7038 test_elem_set_class((IUnknown
*)elem
, NULL
);
7039 test_elem_tabindex((IUnknown
*)elem
, 0);
7040 test_elem_set_tabindex((IUnknown
*)elem
, 1);
7041 test_elem_filters((IUnknown
*)elem
);
7043 node
= test_node_get_parent((IUnknown
*)elem
);
7044 ok(node
!= NULL
, "node == NULL\n");
7045 test_node_name((IUnknown
*)node
, "BODY");
7046 node2
= test_node_get_parent((IUnknown
*)node
);
7047 IHTMLDOMNode_Release(node
);
7048 ok(node2
!= NULL
, "node == NULL\n");
7049 test_node_name((IUnknown
*)node2
, "HTML");
7050 node
= test_node_get_parent((IUnknown
*)node2
);
7051 IHTMLDOMNode_Release(node2
);
7052 ok(node
!= NULL
, "node == NULL\n");
7055 test_node_name((IUnknown
*)node
, "#document");
7056 type
= get_node_type((IUnknown
*)node
);
7057 ok(type
== 9, "type=%d, expected 9\n", type
);
7058 node2
= test_node_get_parent((IUnknown
*)node
);
7059 IHTMLDOMNode_Release(node
);
7060 ok(node2
== NULL
, "node != NULL\n");
7063 elem2
= test_elem_get_parent((IUnknown
*)elem
);
7064 ok(elem2
!= NULL
, "elem2 == NULL\n");
7065 test_node_name((IUnknown
*)elem2
, "BODY");
7067 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
7068 ok(elem3
!= NULL
, "elem3 == NULL\n");
7069 test_node_name((IUnknown
*)elem3
, "HTML");
7071 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
7072 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
7073 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
7074 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
7075 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
7076 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
7077 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
7078 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
7079 IHTMLElement_Release(elem2
);
7081 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
7082 ok(elem2
== NULL
, "elem2 != NULL\n");
7083 test_elem_source_index(elem3
, 0);
7084 IHTMLElement_Release(elem3
);
7086 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
7087 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
7088 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
7090 test_elem_innertext(elem
, "opt1opt2");
7092 IHTMLElement_Release(elem
);
7095 elem
= get_elem_by_id(doc
, "s", TRUE
);
7097 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
7098 IHTMLDocument2
*doc_node
, *elem_doc
;
7100 test_select_elem(select
);
7102 test_elem_title((IUnknown
*)select
, NULL
);
7103 test_elem_set_title((IUnknown
*)select
, "Title");
7104 test_elem_title((IUnknown
*)select
, "Title");
7105 test_elem_offset((IUnknown
*)select
, "BODY");
7106 test_elem_bounding_client_rect((IUnknown
*)select
);
7108 node
= get_first_child((IUnknown
*)select
);
7109 ok(node
!= NULL
, "node == NULL\n");
7111 test_elem_type((IUnknown
*)node
, ET_OPTION
);
7112 IHTMLDOMNode_Release(node
);
7115 type
= get_node_type((IUnknown
*)select
);
7116 ok(type
== 1, "type=%d\n", type
);
7118 IHTMLSelectElement_Release(select
);
7120 elem_doc
= get_elem_doc((IUnknown
*)elem
);
7122 doc_node
= get_doc_node(doc
);
7123 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
7124 IHTMLDocument2_Release(doc_node
);
7125 IHTMLDocument2_Release(elem_doc
);
7127 IHTMLElement_Release(elem
);
7130 elem
= get_elem_by_id(doc
, "sc", TRUE
);
7132 IHTMLScriptElement
*script
;
7135 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
7136 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
7142 hres
= IHTMLScriptElement_put_type (script
, NULL
);
7143 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7144 hres
= IHTMLScriptElement_get_type(script
, &type
);
7145 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7146 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
7148 type
= a2bstr("text/javascript");
7149 hres
= IHTMLScriptElement_put_type (script
, type
);
7150 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7151 SysFreeString(type
);
7152 hres
= IHTMLScriptElement_get_type(script
, &type
);
7153 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7154 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
7155 SysFreeString(type
);
7157 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
7160 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
7161 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7163 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
7164 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
7165 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
7167 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
7168 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7170 str
= (BSTR
)0xdeadbeef;
7171 hres
= IHTMLScriptElement_get_src(script
, &str
);
7172 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
7173 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
7176 IHTMLScriptElement_Release(script
);
7179 elem
= get_elem_by_id(doc
, "in", TRUE
);
7181 IHTMLInputElement
*input
;
7183 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
7184 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
7186 test_elem_id((IUnknown
*)elem
, "in");
7187 test_elem_put_id((IUnknown
*)elem
, "newin");
7188 test_input_get_disabled(input
, VARIANT_FALSE
);
7189 test_input_set_disabled(input
, VARIANT_TRUE
);
7190 test_input_set_disabled(input
, VARIANT_FALSE
);
7191 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
7192 test_input_get_disabled(input
, VARIANT_TRUE
);
7193 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
7194 test_input_get_disabled(input
, VARIANT_FALSE
);
7195 test_elem_client_size((IUnknown
*)elem
);
7196 test_input_type(input
, "text");
7198 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7199 test_node_put_value_str((IUnknown
*)elem
, "test");
7200 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7201 test_input_value((IUnknown
*)elem
, NULL
);
7202 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7203 test_input_put_value((IUnknown
*)elem
, "test");
7204 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7205 test_elem_class((IUnknown
*)elem
, "testclass");
7206 test_elem_tabindex((IUnknown
*)elem
, 2);
7207 test_elem_set_tabindex((IUnknown
*)elem
, 3);
7208 test_elem_title((IUnknown
*)elem
, "test title");
7210 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
7211 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
7212 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
7214 test_input_get_checked(input
, VARIANT_FALSE
);
7215 test_input_set_checked(input
, VARIANT_TRUE
);
7216 test_input_set_checked(input
, VARIANT_FALSE
);
7218 test_input_maxlength(input
, 0x7fffffff);
7219 test_input_set_maxlength(input
, 30);
7221 test_input_name(input
, NULL
);
7222 test_input_set_name(input
, "test");
7224 test_input_src(input
, NULL
);
7225 test_input_set_src(input
, "about:blank");
7227 test_input_set_size(input
, 15, S_OK
);
7228 test_input_get_size(input
, 15);
7229 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
7230 test_input_get_size(input
, 15);
7231 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
7232 test_input_get_size(input
, 15);
7234 test_input_readOnly(input
, VARIANT_TRUE
);
7235 test_input_readOnly(input
, VARIANT_FALSE
);
7237 IHTMLInputElement_Release(input
);
7238 IHTMLElement_Release(elem
);
7241 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7243 test_img_align((IUnknown
*)elem
, "left");
7244 test_img_name((IUnknown
*)elem
, "WineImg");
7245 test_img_src((IUnknown
*)elem
, "", NULL
);
7246 test_img_set_src((IUnknown
*)elem
, "about:blank");
7247 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
7248 test_img_alt((IUnknown
*)elem
, NULL
);
7249 test_img_set_alt((IUnknown
*)elem
, "alt test");
7250 test_img_name((IUnknown
*)elem
, "WineImg");
7251 test_img_complete(elem
, VARIANT_FALSE
);
7252 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
7253 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
7254 IHTMLElement_Release(elem
);
7257 elem
= get_elem_by_id(doc
, "attr", TRUE
);
7259 test_dynamic_properties(elem
);
7260 test_attr_collection(elem
);
7261 test_contenteditable((IUnknown
*)elem
);
7262 IHTMLElement_Release(elem
);
7265 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
7267 test_style_media((IUnknown
*)elem
, NULL
);
7268 test_style_put_media((IUnknown
*)elem
, "screen");
7269 test_style_type((IUnknown
*)elem
, NULL
);
7270 test_style_put_type((IUnknown
*)elem
, "text/css");
7271 IHTMLElement_Release(elem
);
7274 elem
= get_doc_elem_by_id(doc
, "tbl");
7275 ok(elem
!= NULL
, "elem == NULL\n");
7277 test_table_elem(elem
);
7278 IHTMLElement_Release(elem
);
7281 elem
= get_doc_elem_by_id(doc
, "labelid");
7282 ok(elem
!= NULL
, "elem == NULL\n");
7284 test_label_elem(elem
);
7285 IHTMLElement_Release(elem
);
7288 elem
= get_doc_elem_by_id(doc
, "td2");
7289 ok(elem
!= NULL
, "elem == NULL\n");
7292 IHTMLElement_Release(elem
);
7295 elem
= get_doc_elem_by_id(doc
, "row2");
7296 ok(elem
!= NULL
, "elem == NULL\n");
7299 IHTMLElement_Release(elem
);
7302 elem
= get_doc_elem_by_id(doc
, "ifr");
7303 ok(elem
!= NULL
, "elem == NULL\n");
7305 test_iframe_elem(elem
);
7306 IHTMLElement_Release(elem
);
7309 elem
= get_doc_elem_by_id(doc
, "btnid");
7310 ok(elem
!= NULL
, "elem == NULL\n");
7312 test_button_elem(elem
);
7313 test_button_get_disabled(elem
, VARIANT_FALSE
);
7314 test_button_set_disabled(elem
, VARIANT_TRUE
);
7315 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7316 test_button_get_disabled(elem
, VARIANT_FALSE
);
7317 IHTMLElement_Release(elem
);
7320 elem
= get_doc_elem_by_id(doc
, "objid");
7321 ok(elem
!= NULL
, "elem == NULL\n");
7323 test_object_vspace((IUnknown
*)elem
, 100);
7324 test_object_name(elem
, "objname");
7325 set_object_name(elem
, "test");
7326 set_object_name(elem
, NULL
);
7327 IHTMLElement_Release(elem
);
7330 elem
= get_elem_by_id(doc
, "a", TRUE
);
7332 test_anchor_href((IUnknown
*)elem
, "http://test/");
7334 /* Change the href */
7335 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
7336 test_anchor_href((IUnknown
*)elem
, "http://test1/");
7337 test_anchor_hostname((IUnknown
*)elem
, "test1");
7339 /* Restore the href */
7340 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
7341 test_anchor_href((IUnknown
*)elem
, "http://test/");
7342 test_anchor_hostname((IUnknown
*)elem
, "test");
7343 test_anchor_hash(elem
, NULL
);
7346 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7348 test_anchor_rel((IUnknown
*)elem
, NULL
);
7349 test_anchor_put_rel((IUnknown
*)elem
, "Next");
7350 test_anchor_rel((IUnknown
*)elem
, "Next");
7352 /* Change the target */
7353 test_anchor_put_target((IUnknown
*)elem
, "wine");
7354 test_anchor_get_target((IUnknown
*)elem
, "wine");
7356 /* Restore the target */
7357 test_anchor_put_target((IUnknown
*)elem
, NULL
);
7358 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7360 test_anchor_name((IUnknown
*)elem
, "x");
7361 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
7362 test_anchor_put_name((IUnknown
*)elem
, NULL
);
7363 test_anchor_put_name((IUnknown
*)elem
, "x");
7365 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
7366 test_anchor_hash(elem
, "#hash");
7367 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
7369 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
7370 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
7371 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
7372 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
7374 test_anchor_put_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD"); /* encoded cjk characters */
7375 test_anchor_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD", FALSE
);
7377 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
7378 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
7380 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
7381 as part of the pathname, and cannot be accessed by get_search. */
7382 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
7383 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
7385 IHTMLElement_Release(elem
);
7388 elem
= get_doc_elem_by_id(doc
, "metaid");
7390 test_meta_name((IUnknown
*)elem
, "meta name");
7391 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
7392 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
7393 test_meta_charset((IUnknown
*)elem
, NULL
);
7394 set_meta_charset((IUnknown
*)elem
, "utf-8");
7395 IHTMLElement_Release(elem
);
7398 elem
= doc_get_body(doc
);
7400 node
= get_first_child((IUnknown
*)elem
);
7401 ok(node
!= NULL
, "node == NULL\n");
7403 test_ifaces((IUnknown
*)node
, text_iids
);
7404 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
7406 node2
= get_first_child((IUnknown
*)node
);
7407 ok(!node2
, "node2 != NULL\n");
7409 type
= get_node_type((IUnknown
*)node
);
7410 ok(type
== 3, "type=%d\n", type
);
7412 test_node_get_value_str((IUnknown
*)node
, "text test");
7413 test_node_put_value_str((IUnknown
*)elem
, "test text");
7414 test_node_get_value_str((IUnknown
*)node
, "text test");
7416 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
7417 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
7418 ok(!disp
, "disp != NULL\n");
7420 IHTMLDOMNode_Release(node
);
7423 child_col
= get_child_nodes((IUnknown
*)elem
);
7424 ok(child_col
!= NULL
, "child_coll == NULL\n");
7429 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
7431 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
7432 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7433 ok(length
, "length=0\n");
7436 node
= get_child_item(child_col
, 0);
7437 ok(node
!= NULL
, "node == NULL\n");
7441 type
= get_node_type((IUnknown
*)node
);
7442 ok(type
== 3, "type=%d\n", type
);
7443 node2
= node_get_next((IUnknown
*)node
);
7445 prev
= node_get_prev((IUnknown
*)node2
);
7446 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
7447 IHTMLDOMNode_Release(prev
);
7449 IHTMLDOMNode_Release(node
);
7452 node
= get_child_item(child_col
, 1);
7453 ok(node
!= NULL
, "node == NULL\n");
7455 type
= get_node_type((IUnknown
*)node
);
7456 ok(type
== 8, "type=%d\n", type
);
7458 test_elem_id((IUnknown
*)node
, NULL
);
7459 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
7460 IHTMLDOMNode_Release(node2
);
7461 IHTMLDOMNode_Release(node
);
7464 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
7465 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7467 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
7468 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7470 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
7471 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7473 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
7474 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7476 test_child_col_disp(child_col
);
7478 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
7479 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
7481 test_enum_children(enum_unk
, length
);
7483 IUnknown_Release(enum_unk
);
7485 IHTMLDOMChildrenCollection_Release(child_col
);
7488 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7489 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
7490 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7492 IHTMLElement_Release(elem
);
7494 elem
= get_doc_elem_by_id(doc
, "frm");
7495 ok(elem
!= NULL
, "elem == NULL\n");
7497 test_form_length((IUnknown
*)elem
, 0);
7498 test_form_elements((IUnknown
*)elem
);
7499 IHTMLElement_Release(elem
);
7502 test_stylesheets(doc
);
7503 test_create_option_elem(doc
);
7504 test_create_img_elem(doc
);
7506 elem
= get_doc_elem_by_id(doc
, "tbl");
7507 ok(elem
!= NULL
, "elem = NULL\n");
7508 test_elem_set_innertext(elem
, "inner text");
7509 IHTMLElement_Release(elem
);
7511 test_doc_title(doc
, "test");
7512 test_doc_set_title(doc
, "test title");
7513 test_doc_title(doc
, "test title");
7516 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
7517 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
7520 IDispatchEx
*dispex
;
7521 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
7522 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
7526 BSTR str
= a2bstr("Testing");
7527 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
7528 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7529 ok(pid
!= -1, "pid == -1\n");
7531 IDispatchEx_Release(dispex
);
7534 IDispatch_Release(disp
);
7536 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
7537 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
7539 str
= a2bstr("Img");
7540 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
7541 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
7545 static const elem_type_t img_types
[] = { ET_IMG
};
7547 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
7548 IHTMLElementCollection_Release(col
);
7551 elem
= get_doc_elem_by_id(doc
, "y");
7552 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
7553 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
7554 test_elem_set_innerhtml((IUnknown
*)elem
, "");
7555 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
7556 node
= node_get_next((IUnknown
*)elem
);
7557 ok(!node
, "node = %p\n", node
);
7559 elem2
= get_doc_elem_by_id(doc
, "x");
7560 test_elem_tag((IUnknown
*)elem2
, "A");
7561 node
= node_get_next((IUnknown
*)elem2
);
7562 IHTMLDOMNode_Release(node
);
7563 IHTMLElement_Release(elem2
);
7564 IHTMLElement_Release(elem
);
7566 IHTMLDocument3_Release(doc3
);
7568 elem
= get_elem_by_id(doc
, "s", TRUE
);
7570 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
7572 test_select_put_length((IUnknown
*)elem
, 3);
7573 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
7574 test_select_put_length((IUnknown
*)elem
, 1);
7575 test_elem_all((IUnknown
*)elem
, select_types
, 1);
7576 IHTMLElement_Release(elem
);
7579 window
= get_doc_window(doc
);
7580 test_window_name(window
, NULL
);
7581 set_window_name(window
, "test name");
7582 test_window_length(window
, 1);
7583 IHTMLWindow2_Release(window
);
7586 static void test_attr(IHTMLElement
*elem
)
7588 IHTMLDOMAttribute
*attr
, *attr2
;
7591 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
7593 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7595 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
7596 test_ifaces((IUnknown
*)attr
, attr_iids
);
7597 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
7598 test_attr_specified(attr
, VARIANT_TRUE
);
7600 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7601 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
7602 IHTMLDOMAttribute_Release(attr2
);
7604 get_attr_node_value(attr
, &v
, VT_BSTR
);
7605 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7609 V_BSTR(&v
) = a2bstr("divid2");
7610 put_attr_node_value(attr
, v
);
7612 get_attr_node_value(attr
, &v
, VT_BSTR
);
7613 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7616 IHTMLDOMAttribute_Release(attr
);
7618 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7619 get_attr_node_value(attr
, &v
, VT_BSTR
);
7620 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7624 V_BSTR(&v
) = a2bstr("newvalue");
7625 put_attr_node_value(attr
, v
);
7628 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7629 get_attr_node_value(attr
, &v
, VT_BSTR
);
7630 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7633 test_attr_specified(attr
, VARIANT_TRUE
);
7634 IHTMLDOMAttribute_Release(attr
);
7638 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
7639 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
7640 get_attr_node_value(attr
, &v
, VT_I4
);
7641 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
7642 test_attr_specified(attr
, VARIANT_TRUE
);
7646 put_attr_node_value(attr
, v
);
7648 get_attr_node_value(attr
, &v
, VT_I4
);
7649 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
7651 IHTMLDOMAttribute_Release(attr
);
7653 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
7654 test_attr_specified(attr
, VARIANT_FALSE
);
7655 IHTMLDOMAttribute_Release(attr
);
7658 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
7662 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7663 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
7664 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7666 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7667 IHTMLElement_Release(elem
);
7670 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7671 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
7672 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7674 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
7675 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
7676 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
7677 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
7678 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7679 IHTMLElement_Release(elem
);
7683 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
7684 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
7686 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
7687 IHTMLElementCollection
*col
;
7688 BSTR str
= a2bstr(name
);
7691 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
7692 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
7693 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
7695 IHTMLDocument3_Release(doc3
);
7700 static void test_elem_names(IHTMLDocument2
*doc
)
7702 IHTMLElementCollection
*col
;
7707 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
7709 body
= doc_get_body(doc
);
7711 test_elem_set_innerhtml((IUnknown
*)body
,
7712 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
7713 col
= doc_get_elems_by_name(doc
, "test");
7714 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
7715 IHTMLElementCollection_Release(col
);
7717 col
= doc_get_elems_by_name(doc
, "yyy");
7718 test_elem_collection((IUnknown
*)col
, NULL
, 0);
7719 IHTMLElementCollection_Release(col
);
7721 /* case insensivity test */
7722 col
= doc_get_elems_by_name(doc
, "Xxx");
7723 hres
= IHTMLElementCollection_get_length(col
, &len
);
7724 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7725 todo_wine
ok(len
== 1, "len = %d\n", len
);
7726 IHTMLElementCollection_Release(col
);
7728 IHTMLElement_Release(body
);
7731 static void test_elems2(IHTMLDocument2
*doc
)
7733 IHTMLElement
*elem
, *elem2
, *div
;
7735 static const elem_type_t outer_types
[] = {
7740 div
= get_doc_elem_by_id(doc
, "divid");
7742 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
7744 test_link_disabled(elem
, VARIANT_FALSE
);
7745 test_link_rel(elem
, "stylesheet");
7746 test_link_rev(elem
, NULL
);
7747 test_link_type(elem
, "text/css");
7748 test_link_href(elem
, "about:blank");
7749 test_link_media(elem
, "all");
7750 link_put_disabled(elem
, VARIANT_TRUE
);
7751 link_put_rel(elem
, "prev");
7752 link_put_rev(elem
, "next");
7753 link_put_type(elem
, "text/plain");
7754 link_put_href(elem
, "about:prev");
7755 IHTMLElement_Release(elem
);
7758 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
7759 elem2
= get_doc_elem_by_id(doc
, "innerid");
7760 ok(elem2
!= NULL
, "elem2 == NULL\n");
7761 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
7762 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
7763 IHTMLElement_Release(elem2
);
7765 elem2
= get_doc_elem_by_id(doc
, "aid");
7766 ok(elem2
!= NULL
, "elem2 == NULL\n");
7767 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
7768 test_elem_all((IUnknown
*)div
, outer_types
, 1);
7769 IHTMLElement_Release(elem2
);
7771 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
7772 elem
= get_elem_by_id(doc
, "ta", TRUE
);
7774 test_textarea_value((IUnknown
*)elem
, NULL
);
7775 test_textarea_put_value((IUnknown
*)elem
, "test");
7776 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
7777 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
7778 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
7779 test_textarea_type((IUnknown
*)elem
);
7780 IHTMLElement_Release(elem
);
7783 test_elem_set_innerhtml((IUnknown
*)div
,
7784 "<input value=\"val\" id =\"inputid\" />");
7785 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
7787 test_input_defaultValue((IUnknown
*)elem
, "val");
7788 test_input_put_value((IUnknown
*)elem
, "test");
7789 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
7790 test_input_value((IUnknown
*)elem
, "test");
7791 IHTMLElement_Release(elem
);
7794 test_elem_set_innerhtml((IUnknown
*)div
, "");
7795 test_insert_adjacent_elems(doc
, div
);
7797 test_elem_set_innerhtml((IUnknown
*)div
,
7798 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
7799 elem
= get_elem_by_id(doc
, "form", TRUE
);
7801 test_form_length((IUnknown
*)elem
, 2);
7802 test_form_item(elem
);
7803 test_form_action((IUnknown
*)elem
, NULL
);
7804 test_form_put_action((IUnknown
*)elem
, "about:blank");
7805 test_form_method((IUnknown
*)elem
, "get");
7806 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
7807 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
7808 test_form_method((IUnknown
*)elem
, "post");
7809 test_form_name((IUnknown
*)elem
, NULL
);
7810 test_form_put_name((IUnknown
*)elem
, "Name");
7811 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
7812 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
7813 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
7814 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
7815 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
7816 test_form_elements((IUnknown
*)elem
);
7817 test_form_reset((IUnknown
*)elem
);
7818 test_form_target((IUnknown
*)elem
);
7819 IHTMLElement_Release(elem
);
7821 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
7822 test_input_get_form((IUnknown
*)elem
, "form");
7823 IHTMLElement_Release(elem
);
7827 test_blocked(doc
, div
);
7828 test_elem_names(doc
);
7830 IHTMLElement_Release(div
);
7833 static void test_create_elems(IHTMLDocument2
*doc
)
7835 IHTMLElement
*elem
, *body
, *elem2
;
7836 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
7837 IHTMLDOMAttribute
*attr
;
7838 IHTMLDocument5
*doc5
;
7845 static const elem_type_t types1
[] = { ET_TESTG
};
7847 elem
= test_create_elem(doc
, "TEST");
7848 test_elem_tag((IUnknown
*)elem
, "TEST");
7849 type
= get_node_type((IUnknown
*)elem
);
7850 ok(type
== 1, "type=%d\n", type
);
7851 test_ifaces((IUnknown
*)elem
, elem_iids
);
7852 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
7853 test_elem_source_index(elem
, -1);
7855 body
= doc_get_body(doc
);
7856 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
7858 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
7859 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
7860 elem2
= get_elem_iface((IUnknown
*)node
);
7861 IHTMLElement_Release(elem2
);
7863 hres
= IHTMLElement_get_all(body
, &disp
);
7864 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7865 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
7866 IDispatch_Release(disp
);
7868 test_node_remove_child((IUnknown
*)body
, node
);
7870 hres
= IHTMLElement_get_all(body
, &disp
);
7871 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7872 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
7873 IDispatch_Release(disp
);
7874 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
7876 IHTMLElement_Release(elem
);
7877 IHTMLDOMNode_Release(node
);
7879 node
= test_create_text(doc
, "abc");
7880 test_ifaces((IUnknown
*)node
, text_iids
);
7881 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
7882 test_text_length((IUnknown
*)node
, 3);
7883 test_text_data((IUnknown
*)node
, "abc");
7884 set_text_data((IUnknown
*)node
, "test");
7885 test_text_data((IUnknown
*)node
, "test");
7887 V_VT(&var
) = VT_NULL
;
7888 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7889 IHTMLDOMNode_Release(node
);
7891 node
= test_create_text(doc
, "insert ");
7893 V_VT(&var
) = VT_DISPATCH
;
7894 V_DISPATCH(&var
) = (IDispatch
*)node2
;
7895 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7896 IHTMLDOMNode_Release(node
);
7897 IHTMLDOMNode_Release(node2
);
7898 IHTMLDOMNode_Release(node3
);
7900 test_elem_innertext(body
, "insert test");
7901 test_elem_innerhtml((IUnknown
*)body
, "insert test");
7903 node
= test_create_text(doc
, " Test");
7904 V_VT(&var
) = VT_DISPATCH
;
7905 V_DISPATCH(&var
) = NULL
;
7906 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7907 test_elem_innertext(body
, "insert test Test");
7908 IHTMLDOMNode_Release(node
);
7910 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
7912 str
= a2bstr("testing");
7913 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
7915 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
7918 type
= get_node_type((IUnknown
*)comment
);
7919 ok(type
== 8, "type=%d, expected 8\n", type
);
7921 test_node_get_value_str((IUnknown
*)comment
, "testing");
7922 test_elem_title((IUnknown
*)comment
, NULL
);
7923 test_elem_set_title((IUnknown
*)comment
, "comment title");
7924 test_elem_title((IUnknown
*)comment
, "comment title");
7925 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
7926 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
7927 test_comment_attrs((IUnknown
*)comment
);
7929 IHTMLDOMNode_Release(comment
);
7932 str
= a2bstr("Test");
7933 hres
= IHTMLDocument5_createAttribute(doc5
, str
, &attr
);
7934 ok(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
7936 if(SUCCEEDED(hres
)) {
7937 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
7938 test_ifaces((IUnknown
*)attr
, attr_iids
);
7939 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
7941 test_attr_node_name(attr
, "Test");
7943 IHTMLDOMAttribute_Release(attr
);
7946 IHTMLDocument5_Release(doc5
);
7949 IHTMLElement_Release(body
);
7952 static void test_replacechild_elems(IHTMLDocument2
*doc
)
7955 IHTMLDOMNode
*node
, *node2
, *node3
;
7956 IHTMLDOMNode
*nodeBody
, *nodeNew
;
7960 body
= doc_get_body(doc
);
7962 node
= test_create_text(doc
, "insert");
7964 V_VT(&var
) = VT_NULL
;
7965 V_DISPATCH(&var
) = NULL
;
7966 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7967 IHTMLDOMNode_Release(node
);
7969 test_elem_innertext(body
, "insert");
7971 node3
= test_create_text(doc
, "replaced");
7973 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
7975 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
7976 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
7978 test_elem_innertext(body
, "replaced");
7980 IHTMLDOMNode_Release(node2
);
7981 IHTMLDOMNode_Release(node3
);
7982 IHTMLDOMNode_Release(nodeBody
);
7984 IHTMLElement_Release(body
);
7987 static void test_noscript(IHTMLDocument2
*doc
)
7989 IHTMLElementCollection
*col
;
7993 static const elem_type_t all_types
[] = {
8002 static const elem_type_t body_all_types
[] = {
8007 hres
= IHTMLDocument2_get_all(doc
, &col
);
8008 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8009 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8010 IHTMLElementCollection_Release(col
);
8012 body
= doc_get_body(doc
);
8013 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
8014 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
8015 IHTMLElement_Release(body
);
8018 static void test_doctype(IHTMLDocument2
*doc
)
8020 IHTMLDocument2
*doc_node
;
8021 IHTMLDOMNode
*doctype
;
8024 doc_node
= get_doc_node(doc
);
8025 doctype
= get_first_child((IUnknown
*)doc_node
);
8026 IHTMLDocument2_Release(doc_node
);
8028 type
= get_node_type((IUnknown
*)doctype
);
8029 ok(type
== 8, "type = %d\n", type
);
8031 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
8032 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
8033 IHTMLDOMNode_Release(doctype
);
8036 static void test_null_write(IHTMLDocument2
*doc
)
8040 doc_write(doc
, FALSE
, NULL
);
8041 doc_write(doc
, TRUE
, NULL
);
8043 hres
= IHTMLDocument2_write(doc
, NULL
);
8045 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
8047 hres
= IHTMLDocument2_writeln(doc
, NULL
);
8049 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
8052 static void test_create_stylesheet(IHTMLDocument2
*doc
)
8054 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
8055 IHTMLStyleElement
*style_elem
;
8056 IHTMLElement
*doc_elem
, *elem
;
8059 static const elem_type_t all_types
[] = {
8067 static const elem_type_t all_types2
[] = {
8076 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
8078 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
8079 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
8081 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
8083 doc_elem
= get_doc_elem(doc
);
8085 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
8086 IHTMLElement_Release(doc_elem
);
8088 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
8089 IHTMLElement_Release(elem
);
8090 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
8093 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
8094 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
8095 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
8096 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
8098 IHTMLStyleSheet_Release(stylesheet2
);
8099 IHTMLStyleSheet_Release(stylesheet
);
8101 IHTMLStyleElement_Release(style_elem
);
8104 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
8106 IOleCommandTarget
*cmdtrg
;
8109 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
8110 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
8112 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
8113 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
8115 IOleCommandTarget_Release(cmdtrg
);
8118 static void test_indent(IHTMLDocument2
*doc
)
8120 IHTMLElementCollection
*col
;
8121 IHTMLTxtRange
*range
;
8124 static const elem_type_t all_types
[] = {
8133 static const elem_type_t indent_types
[] = {
8144 hres
= IHTMLDocument2_get_all(doc
, &col
);
8145 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8146 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8147 IHTMLElementCollection_Release(col
);
8149 range
= test_create_body_range(doc
);
8150 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
8151 IHTMLTxtRange_Release(range
);
8153 hres
= IHTMLDocument2_get_all(doc
, &col
);
8154 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8155 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
8156 IHTMLElementCollection_Release(col
);
8159 static void test_cond_comment(IHTMLDocument2
*doc
)
8161 IHTMLElementCollection
*col
;
8164 static const elem_type_t all_types
[] = {
8172 hres
= IHTMLDocument2_get_all(doc
, &col
);
8173 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8174 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8175 IHTMLElementCollection_Release(col
);
8178 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
8180 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
8181 return E_NOINTERFACE
;
8184 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
8189 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
8194 static const IUnknownVtbl UnknownVtbl
= {
8195 Unknown_QueryInterface
,
8199 static IUnknown obj_ident_test
= { &UnknownVtbl
};
8201 static void test_frame(IDispatch
*disp
, const char *exp_id
)
8203 IHTMLWindow2
*frame2
, *parent
, *top
;
8204 IHTMLDocument2
*parent_doc
, *top_doc
;
8205 IHTMLWindow4
*frame
;
8206 IHTMLFrameBase
*frame_elem
;
8207 IObjectIdentity
*obj_ident
;
8208 ITravelLogClient
*tlc
;
8211 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
8212 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
8216 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
8217 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
8218 IHTMLWindow4_Release(frame
);
8222 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
8223 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
8224 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
8225 IHTMLFrameBase_Release(frame_elem
);
8227 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
8228 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
8232 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
8233 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
8235 IHTMLWindow2_Release(frame2
);
8239 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
8240 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
8241 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
8242 if(hres
== E_NOINTERFACE
) {
8243 win_skip("IID_ITravelLogClient not available\n");
8246 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
8248 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
8249 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8250 ITravelLogClient_Release(tlc
);
8253 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
8254 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8255 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
8256 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
8257 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
8258 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
8260 IObjectIdentity_Release(obj_ident
);
8262 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
8263 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8264 IHTMLWindow2_Release(parent
);
8266 IHTMLWindow2_Release(frame2
);
8270 test_doc_title(parent_doc
, "frameset test");
8271 IHTMLDocument2_Release(parent_doc
);
8274 hres
= IHTMLWindow2_get_top(frame2
, &top
);
8275 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
8276 IHTMLWindow2_Release(frame2
);
8280 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
8281 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8282 IHTMLWindow2_Release(top
);
8286 test_doc_title(top_doc
, "frameset test");
8287 IHTMLDocument2_Release(top_doc
);
8290 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
8292 VARIANT index_var
, result_var
;
8296 /* test result length */
8297 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
8298 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
8299 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
8301 /* test first frame */
8302 V_VT(&index_var
) = VT_I4
;
8303 V_I4(&index_var
) = 0;
8304 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8305 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8306 if(SUCCEEDED(hres
)) {
8307 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8308 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
8310 VariantClear(&result_var
);
8312 /* test second frame */
8313 V_I4(&index_var
) = 1;
8314 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8315 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8316 if(SUCCEEDED(hres
)) {
8317 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8318 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
8320 VariantClear(&result_var
);
8322 /* fail on next frame */
8323 V_I4(&index_var
) = 3;
8324 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8325 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
8326 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
8327 VariantClear(&result_var
);
8329 /* string argument (element id lookup) */
8330 V_VT(&index_var
) = VT_BSTR
;
8331 V_BSTR(&index_var
) = a2bstr(frid
);
8332 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8333 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8334 if(SUCCEEDED(hres
)) {
8335 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8336 test_frame(V_DISPATCH(&result_var
), frid
);
8338 VariantClear(&result_var
);
8339 VariantClear(&index_var
);
8341 /* invalid argument */
8342 V_VT(&index_var
) = VT_BOOL
;
8343 V_BOOL(&index_var
) = VARIANT_TRUE
;
8344 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8345 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
8346 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
8347 VariantClear(&result_var
);
8350 static void test_frameset(IHTMLDocument2
*doc
)
8352 IHTMLWindow2
*window
;
8353 IHTMLFramesCollection2
*frames
;
8357 window
= get_doc_window(doc
);
8359 /* test using IHTMLFramesCollection object */
8361 hres
= IHTMLWindow2_get_frames(window
, &frames
);
8362 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
8366 test_frames_collection(frames
, "fr1");
8367 IHTMLFramesCollection2_Release(frames
);
8369 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
8370 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
8374 test_frames_collection(frames
, "fr1");
8375 IHTMLFramesCollection2_Release(frames
);
8377 /* test using IHTMLWindow2 inheritance */
8378 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
8380 /* getElementById with node name attributes */
8381 elem
= get_doc_elem_by_id(doc
, "nm1");
8382 test_elem_id((IUnknown
*)elem
, "fr1");
8384 test_framebase((IUnknown
*)elem
);
8385 test_framebase_name(elem
, "nm1");
8386 test_framebase_put_name(elem
, "frame name");
8387 test_framebase_put_name(elem
, NULL
);
8388 test_framebase_put_name(elem
, "nm1");
8389 IHTMLElement_Release(elem
);
8391 /* get_name with no name attr */
8392 elem
= get_doc_elem_by_id(doc
, "fr3");
8393 test_framebase_name(elem
, NULL
);
8394 test_framebase_put_name(elem
, "frame name");
8395 test_framebase_put_name(elem
, NULL
);
8396 IHTMLElement_Release(elem
);
8398 IHTMLWindow2_Release(window
);
8401 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
8403 IHTMLDocument2
*frag
;
8404 IHTMLDocument3
*doc3
;
8407 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8408 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8410 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
8411 IHTMLDocument3_Release(doc3
);
8412 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
8413 ok(frag
!= NULL
, "frag == NULL\n");
8418 static void test_docfrag(IHTMLDocument2
*doc
)
8420 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
8421 IHTMLElement
*div
, *body
, *br
;
8422 IHTMLElementCollection
*col
;
8423 IHTMLLocation
*location
;
8426 static const elem_type_t all_types
[] = {
8435 frag
= create_docfrag(doc
);
8437 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
8439 body
= (void*)0xdeadbeef;
8440 hres
= IHTMLDocument2_get_body(frag
, &body
);
8441 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
8442 ok(!body
, "body != NULL\n");
8444 location
= (void*)0xdeadbeef;
8445 hres
= IHTMLDocument2_get_location(frag
, &location
);
8446 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
8447 ok(location
== (void*)0xdeadbeef, "location changed\n");
8449 br
= test_create_elem(doc
, "BR");
8450 test_elem_source_index(br
, -1);
8451 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
8452 test_elem_source_index(br
, 0);
8453 IHTMLElement_Release(br
);
8455 div
= get_elem_by_id(doc
, "divid", TRUE
);
8456 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
8457 IHTMLElement_Release(div
);
8459 hres
= IHTMLDocument2_get_all(doc
, &col
);
8460 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8461 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8462 IHTMLElementCollection_Release(col
);
8464 div
= test_create_elem(frag
, "div");
8465 owner_doc
= get_owner_doc((IUnknown
*)div
);
8466 doc_node
= get_doc_node(doc
);
8467 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
8468 IHTMLDocument2_Release(doc_node
);
8469 IHTMLDocument2_Release(owner_doc
);
8470 IHTMLElement_Release(div
);
8472 IHTMLDocument2_Release(frag
);
8475 static void check_quirks_mode(IHTMLDocument2
*doc
)
8477 test_compatmode(doc
, "BackCompat");
8480 static void check_strict_mode(IHTMLDocument2
*doc
)
8482 test_compatmode(doc
, "CSS1Compat");
8485 static IHTMLDocument2
*notif_doc
;
8486 static BOOL doc_complete
;
8488 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
8489 REFIID riid
, void**ppv
)
8491 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
8496 ok(0, "unexpected call\n");
8497 return E_NOINTERFACE
;
8500 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
8505 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
8510 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
8512 if(dispID
== DISPID_READYSTATE
){
8516 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
8517 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
8519 if(!strcmp_wa(state
, "complete"))
8520 doc_complete
= TRUE
;
8522 SysFreeString(state
);
8528 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
8530 ok(0, "unexpected call\n");
8534 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
8535 PropertyNotifySink_QueryInterface
,
8536 PropertyNotifySink_AddRef
,
8537 PropertyNotifySink_Release
,
8538 PropertyNotifySink_OnChanged
,
8539 PropertyNotifySink_OnRequestEdit
8542 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
8544 static IHTMLDocument2
*create_doc_with_string(const char *str
)
8546 IPersistStreamInit
*init
;
8548 IHTMLDocument2
*doc
;
8552 notif_doc
= doc
= create_document();
8556 doc_complete
= FALSE
;
8558 mem
= GlobalAlloc(0, len
);
8559 memcpy(mem
, str
, len
);
8560 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
8562 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
8564 IPersistStreamInit_Load(init
, stream
);
8565 IPersistStreamInit_Release(init
);
8566 IStream_Release(stream
);
8571 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
8573 IConnectionPointContainer
*container
;
8574 IConnectionPoint
*cp
;
8578 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
8579 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
8581 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
8582 IConnectionPointContainer_Release(container
);
8583 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
8585 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
8586 IConnectionPoint_Release(cp
);
8587 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
8590 typedef void (*domtest_t
)(IHTMLDocument2
*);
8592 static void run_domtest(const char *str
, domtest_t test
)
8594 IHTMLDocument2
*doc
;
8598 doc
= create_doc_with_string(str
);
8602 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
8604 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
8605 TranslateMessage(&msg
);
8606 DispatchMessageW(&msg
);
8611 ref
= IHTMLDocument2_Release(doc
);
8612 ok(!ref
|| broken(ref
== 1), /* Vista */
8616 static void test_quirks_mode(void)
8618 run_domtest("<html></html>", check_quirks_mode
);
8619 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
8620 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
8625 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
8626 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
8627 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
8631 run_domtest(doc_str1
, test_doc_elem
);
8632 run_domtest(doc_str1
, test_get_set_attr
);
8633 run_domtest(range_test_str
, test_txtrange
);
8634 run_domtest(range_test2_str
, test_txtrange2
);
8635 if (winetest_interactive
|| ! is_ie_hardened()) {
8636 run_domtest(elem_test_str
, test_elems
);
8637 run_domtest(elem_test2_str
, test_elems2
);
8638 run_domtest(noscript_str
, test_noscript
);
8640 skip("IE running in Enhanced Security Configuration\n");
8642 run_domtest(doc_blank
, test_create_elems
);
8643 run_domtest(doc_blank
, test_defaults
);
8644 run_domtest(doc_blank
, test_null_write
);
8645 run_domtest(emptydiv_str
, test_create_stylesheet
);
8646 run_domtest(indent_test_str
, test_indent
);
8647 run_domtest(cond_comment_str
, test_cond_comment
);
8648 run_domtest(frameset_str
, test_frameset
);
8649 run_domtest(emptydiv_str
, test_docfrag
);
8650 run_domtest(doc_blank
, test_replacechild_elems
);
8651 run_domtest(doctype_str
, test_doctype
);