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 "<body onload=\"Testing()\">text test<!-- a comment -->"
52 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
53 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
54 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
55 "<textarea id=\"X\">text text</textarea>"
56 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
57 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
58 "<test /><object id=\"objid\" vspace=100></object><embed />"
59 "<img id=\"imgid\" name=\"WineImg\"/>"
60 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
61 "<form id=\"frm\"></form>"
62 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
64 static const char elem_test2_str
[] =
65 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
66 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
69 static const char indent_test_str
[] =
70 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
71 static const char cond_comment_str
[] =
72 "<html><head><title>test</title></head><body>"
73 "<!--[if gte IE 4]> <br> <![endif]-->"
75 static const char frameset_str
[] =
76 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
77 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
78 "<frame src=\"about:blank\" id=\"fr3\">"
80 static const char emptydiv_str
[] =
81 "<html><head><title>emptydiv test</title></head>"
82 "<body><div id=\"divid\"></div></body></html>";
84 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
85 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
86 static WCHAR wordW
[] = {'w','o','r','d',0};
121 static const IID
* const none_iids
[] = {
126 static const IID
* const doc_node_iids
[] = {
135 &IID_IConnectionPointContainer
,
136 &IID_IInternetHostSecurityManager
,
139 &IID_IProvideClassInfo
,
143 static const IID
* const doc_obj_iids
[] = {
150 &IID_IConnectionPointContainer
,
154 &IID_IProvideClassInfo
,
155 &IID_ITargetContainer
,
159 #define ELEM_IFACES \
161 &IID_IHTMLDOMNode2, \
163 &IID_IHTMLElement2, \
164 &IID_IHTMLElement3, \
165 &IID_IHTMLElement4, \
168 static const IID
* const elem_iids
[] = {
170 &IID_IConnectionPointContainer
,
174 static const IID
* const body_iids
[] = {
176 &IID_IHTMLTextContainer
,
177 &IID_IHTMLBodyElement
,
178 &IID_IConnectionPointContainer
,
182 static const IID
* const anchor_iids
[] = {
184 &IID_IHTMLAnchorElement
,
185 &IID_IConnectionPointContainer
,
189 static const IID
* const input_iids
[] = {
191 &IID_IHTMLInputElement
,
192 &IID_IHTMLInputTextElement
,
193 &IID_IConnectionPointContainer
,
197 static const IID
* const select_iids
[] = {
199 &IID_IHTMLSelectElement
,
200 &IID_IConnectionPointContainer
,
204 static const IID
* const textarea_iids
[] = {
206 &IID_IHTMLTextAreaElement
,
207 &IID_IConnectionPointContainer
,
211 static const IID
* const option_iids
[] = {
213 &IID_IHTMLOptionElement
,
214 &IID_IConnectionPointContainer
,
218 static const IID
* const table_iids
[] = {
223 &IID_IConnectionPointContainer
,
227 static const IID
* const script_iids
[] = {
229 &IID_IHTMLScriptElement
,
230 &IID_IConnectionPointContainer
,
234 static const IID
* const text_iids
[] = {
237 &IID_IHTMLDOMTextNode
,
241 static const IID
* const attr_iids
[] = {
242 &IID_IHTMLDOMAttribute
,
247 static const IID
* const location_iids
[] = {
253 static const IID
* const window_iids
[] = {
258 &IID_IServiceProvider
,
262 static const IID
* const comment_iids
[] = {
264 &IID_IHTMLCommentElement
,
265 &IID_IConnectionPointContainer
,
269 static const IID
* const img_iids
[] = {
271 &IID_IHTMLImgElement
,
272 &IID_IConnectionPointContainer
,
276 static const IID
* const tr_iids
[] = {
279 &IID_IConnectionPointContainer
,
283 static const IID
* const td_iids
[] = {
286 &IID_IConnectionPointContainer
,
290 static const IID
* const frame_iids
[] = {
293 &IID_IHTMLFrameBase2
,
294 &IID_IConnectionPointContainer
,
298 static const IID
* const head_iids
[] = {
300 &IID_IHTMLHeadElement
,
301 &IID_IConnectionPointContainer
,
305 static const IID
* const title_iids
[] = {
307 &IID_IHTMLTitleElement
,
308 &IID_IConnectionPointContainer
,
312 static const IID
* const meta_iids
[] = {
314 &IID_IHTMLMetaElement
,
315 &IID_IConnectionPointContainer
,
319 static const IID
* const object_iids
[] = {
321 &IID_IHTMLObjectElement
,
322 &IID_IHTMLObjectElement2
,
323 /* FIXME: No IConnectionPointContainer */
327 static const IID
* const embed_iids
[] = {
329 &IID_IHTMLEmbedElement
,
330 /* FIXME: No IConnectionPointContainer */
334 static const IID
* const iframe_iids
[] = {
337 &IID_IHTMLFrameBase2
,
338 &IID_IHTMLIFrameElement
,
339 &IID_IConnectionPointContainer
,
343 static const IID
* const form_iids
[] = {
345 &IID_IHTMLFormElement
,
346 &IID_IConnectionPointContainer
,
350 static const IID
* const styleelem_iids
[] = {
352 &IID_IHTMLStyleElement
,
353 &IID_IConnectionPointContainer
,
357 static const IID
* const generic_iids
[] = {
359 &IID_IHTMLGenericElement
,
360 &IID_IConnectionPointContainer
,
364 static const IID
* const style_iids
[] = {
375 static const IID
* const cstyle_iids
[] = {
379 &IID_IHTMLCurrentStyle
,
380 &IID_IHTMLCurrentStyle2
,
381 &IID_IHTMLCurrentStyle3
,
385 static const IID
* const img_factory_iids
[] = {
389 &IID_IHTMLImageElementFactory
,
399 static const elem_type_info_t elem_type_infos
[] = {
400 {"", none_iids
, NULL
},
401 {"HTML", elem_iids
, NULL
},
402 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
403 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
404 {"BODY", body_iids
, &DIID_DispHTMLBody
},
405 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
406 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
407 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
408 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
409 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
410 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
411 {"BLOCKQUOTE",elem_iids
, NULL
},
412 {"P", elem_iids
, NULL
},
413 {"BR", elem_iids
, NULL
},
414 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
415 {"TBODY", elem_iids
, NULL
},
416 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
417 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
418 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
419 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
420 {"IMG", img_iids
, &DIID_DispHTMLImg
},
421 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
422 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
423 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
424 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
425 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
426 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
427 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
428 {"DIV", elem_iids
, NULL
},
429 {"META", meta_iids
, &DIID_DispHTMLMetaElement
}
432 static const char *dbgstr_guid(REFIID riid
)
436 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
437 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
438 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
439 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
444 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
447 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
448 return lstrcmpA(stra
, buf
);
451 static BSTR
a2bstr(const char *str
)
459 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
460 ret
= SysAllocStringLen(NULL
, len
);
461 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
466 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
468 IUnknown
*unk1
, *unk2
;
473 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
474 IUnknown_Release(unk1
);
475 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
476 IUnknown_Release(unk2
);
481 static IHTMLDocument2
*create_document(void)
484 IHTMLDocument5
*doc5
;
487 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
488 &IID_IHTMLDocument2
, (void**)&doc
);
489 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
493 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
495 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
496 IHTMLDocument2_Release(doc
);
500 IHTMLDocument5_Release(doc5
);
504 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
505 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
510 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
511 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
515 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
516 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
518 const IID
* const *piid
;
522 for(piid
= iids
; *piid
; piid
++) {
523 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
524 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
526 IUnknown_Release(unk
);
530 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
531 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
536 unk
= (void*)0xdeadbeef;
537 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
538 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
539 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
542 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
543 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
545 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
552 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
553 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
554 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
556 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
557 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
559 if(SUCCEEDED(hres
)) {
562 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
563 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
565 *iid
= type_attr
->guid
;
569 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
570 ITypeInfo_Release(typeinfo
);
573 IDispatchEx_Release(dispex
);
577 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
578 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
580 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
581 DISPPARAMS dp
= {NULL
,NULL
,0,0};
586 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
587 IDispatchEx_Release(dispex
);
588 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
590 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
591 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
595 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
596 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
600 if(_test_get_dispid(line
, unk
, &iid
))
601 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", dbgstr_guid(&iid
));
604 _test_disp_value(line
, unk
, val
);
607 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
608 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
612 if(_test_get_dispid(line
, unk
, &iid
))
613 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
614 "unexpected guid %s\n", dbgstr_guid(&iid
));
617 _test_disp_value(line
, unk
, val
);
620 #define test_class_info(u) _test_class_info(__LINE__,u)
621 static void _test_class_info(unsigned line
, IUnknown
*unk
)
623 IProvideClassInfo
*classinfo
;
628 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
629 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
633 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
634 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
637 IProvideClassInfo_Release(classinfo
);
641 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
642 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
645 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
646 "unexpected guid %s\n", dbgstr_guid(&type_attr
->guid
));
647 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
648 "unexpected typekind %d\n", type_attr
->typekind
);
649 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
652 ITypeInfo_Release(typeinfo
);
653 IProvideClassInfo_Release(classinfo
);
656 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
657 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
659 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
660 DISPPARAMS dp
= {val
, NULL
, 1, 0};
667 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
669 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
671 memset(&ei
, 0, sizeof(ei
));
672 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
673 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
677 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
678 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
683 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
684 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
688 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
689 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
694 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
695 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
699 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
700 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
705 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
706 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
710 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
711 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
716 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
717 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
721 #define get_node_iface(u) _get_node_iface(__LINE__,u)
722 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
727 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
728 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
732 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
733 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
738 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
739 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
743 #define get_img_iface(u) _get_img_iface(__LINE__,u)
744 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
746 IHTMLImgElement
*img
;
749 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
750 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
754 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
755 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
757 IHTMLAnchorElement
*anchor
;
760 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
761 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
765 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
766 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
768 IHTMLTextAreaElement
*textarea
;
771 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
772 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
776 #define get_select_iface(u) _get_select_iface(__LINE__,u)
777 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
779 IHTMLSelectElement
*select
;
782 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
783 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
787 #define get_form_iface(u) _get_form_iface(__LINE__,u)
788 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
790 IHTMLFormElement
*form
;
793 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
794 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
798 #define get_text_iface(u) _get_text_iface(__LINE__,u)
799 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
801 IHTMLDOMTextNode
*text
;
804 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
805 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
809 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
810 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
812 IHTMLCommentElement
*comment
;
815 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
816 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
820 #define get_object_iface(u) _get_object_iface(__LINE__,u)
821 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
823 IHTMLObjectElement
*obj
;
826 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
827 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
831 #define get_style_iface(u) _get_style_iface(__LINE__,u)
832 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
834 IHTMLStyleElement
*obj
;
837 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
838 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
842 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
843 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
845 IHTMLMetaElement
*ret
;
848 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
849 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
853 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
854 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
856 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
860 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
861 IHTMLDOMNode_Release(node
);
862 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
863 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
868 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
869 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
871 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
872 IDispatch
*disp
= (void*)0xdeadbeef;
873 IHTMLDocument2
*doc
= NULL
;
876 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
877 IHTMLDOMNode2_Release(node
);
878 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
881 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
882 IDispatch_Release(disp
);
883 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
889 #define get_doc_window(d) _get_doc_window(__LINE__,d)
890 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
892 IHTMLWindow2
*window
;
896 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
897 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
898 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
903 #define clone_node(n,d) _clone_node(__LINE__,n,d)
904 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
906 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
907 IHTMLDOMNode
*ret
= NULL
;
910 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
911 IHTMLDOMNode_Release(node
);
912 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
913 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
919 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
920 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
922 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
926 hres
= IHTMLElement_get_tagName(elem
, &tag
);
927 IHTMLElement_Release(elem
);
928 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
929 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
934 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
935 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
937 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
938 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
940 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
941 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
944 #define get_node_type(n) _get_node_type(__LINE__,n)
945 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
947 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
951 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
952 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
954 IHTMLDOMNode_Release(node
);
959 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
960 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
962 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
963 IHTMLDOMChildrenCollection
*col
= NULL
;
967 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
968 IHTMLDOMNode_Release(node
);
969 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
973 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
974 IDispatch_Release(disp
);
975 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
980 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
981 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
983 IHTMLDOMNode
*node
= NULL
;
987 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
988 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
990 node
= _get_node_iface(line
, (IUnknown
*)disp
);
991 IDispatch_Release(disp
);
996 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
997 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1003 VariantInit(&value
);
1006 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1008 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1011 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1012 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1014 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1017 VariantClear(&value
);
1020 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1021 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1023 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1024 IHTMLElement
*off_parent
;
1028 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1029 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1031 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1032 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1034 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1035 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1037 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1038 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1040 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1041 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1043 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1044 IHTMLElement_Release(off_parent
);
1046 IHTMLElement_Release(elem
);
1049 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1050 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1052 IHTMLWindow2
*window
;
1053 IHTMLDocument2
*ret
;
1056 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1057 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1059 hres
= IHTMLWindow2_get_document(window
, &ret
);
1060 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1061 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1066 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1067 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1072 hres
= IHTMLWindow2_get_name(window
, &name
);
1073 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1075 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1077 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1078 SysFreeString(name
);
1081 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1082 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1088 hres
= IHTMLWindow2_put_name(window
, str
);
1090 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1092 _test_window_name(line
, window
, name
);
1095 #define test_window_status(d) _test_window_status(__LINE__,d)
1096 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1101 status
= (void*)0xdeadbeef;
1102 hres
= IHTMLWindow2_get_status(window
, &status
);
1103 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1104 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1105 SysFreeString(status
);
1108 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1109 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1114 str
= a2bstr(status
);
1115 hres
= IHTMLWindow2_put_status(window
, str
);
1117 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1120 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1121 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1126 hres
= IHTMLWindow2_get_length(window
, &length
);
1127 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1128 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1131 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1132 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1134 IHTMLFrameBase2
*base2
;
1135 IHTMLWindow2
*window
;
1138 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1139 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1142 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1143 IHTMLFrameBase2_Release(base2
);
1144 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1145 ok(window
!= NULL
, "contentWindow = NULL\n");
1150 static void test_get_set_attr(IHTMLDocument2
*doc
)
1153 IHTMLDocument3
*doc3
;
1158 /* grab an element to test with */
1159 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1160 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1162 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1163 IHTMLDocument3_Release(doc3
);
1164 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1166 /* get a non-present attribute */
1167 bstr
= a2bstr("notAnAttribute");
1168 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1169 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1170 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1172 SysFreeString(bstr
);
1174 /* get a present attribute */
1175 bstr
= a2bstr("scrollHeight");
1176 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1177 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1178 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1180 SysFreeString(bstr
);
1182 /* create a new BSTR attribute */
1183 bstr
= a2bstr("newAttribute");
1185 V_VT(&val
) = VT_BSTR
;
1186 V_BSTR(&val
) = a2bstr("the value");
1187 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1188 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1191 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1192 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1193 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1194 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
)));
1197 /* overwrite the attribute with a BOOL */
1198 V_VT(&val
) = VT_BOOL
;
1199 V_BOOL(&val
) = VARIANT_TRUE
;
1200 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1201 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1204 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1205 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1206 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1207 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1210 SysFreeString(bstr
);
1212 /* case-insensitive */
1213 bstr
= a2bstr("newattribute");
1214 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1215 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1216 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1217 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1219 SysFreeString(bstr
);
1221 IHTMLElement_Release(elem
);
1224 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1225 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1228 IHTMLDocument3
*doc3
;
1231 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1232 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1233 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1234 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1235 IHTMLDocument3_Release(doc3
);
1240 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1241 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1243 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1247 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1248 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1249 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1252 _test_disp_value(line
, unk
, exhref
);
1255 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1256 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1258 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1262 str
= a2bstr(exhref
);
1263 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1264 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1267 _test_disp_value(line
, unk
, exhref
);
1270 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1271 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1273 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1277 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1278 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1280 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1282 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1286 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1287 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1289 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1293 str
= target
? a2bstr(target
) : NULL
;
1294 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1295 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1299 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1300 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1302 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1306 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1307 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1309 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1311 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1315 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1316 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1318 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1322 str
= name
? a2bstr(name
) : NULL
;
1323 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1324 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1327 _test_anchor_name(line
, unk
, name
);
1331 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1332 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1337 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1338 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1339 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1340 SysFreeString(bstr
);
1343 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1344 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1349 bstr
= a2bstr(text
);
1350 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1351 SysFreeString(bstr
);
1352 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1354 _test_option_text(line
, option
, text
);
1357 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1358 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1363 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1364 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1365 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1366 SysFreeString(bstr
);
1369 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1370 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1375 bstr
= a2bstr(value
);
1376 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1377 SysFreeString(bstr
);
1378 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1380 _test_option_value(line
, option
, value
);
1383 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1384 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1386 VARIANT_BOOL b
= 0x100;
1389 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1390 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1391 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1394 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1395 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1399 hres
= IHTMLOptionElement_put_selected(option
, b
);
1400 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1401 _test_option_selected(line
, option
, b
);
1404 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1405 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1407 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1408 BSTR value
= (void*)0xdeadbeef;
1411 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1412 IHTMLTextAreaElement_Release(textarea
);
1413 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1415 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1417 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1418 SysFreeString(value
);
1421 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1422 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1424 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1425 BSTR tmp
= a2bstr(value
);
1428 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1429 IHTMLTextAreaElement_Release(textarea
);
1430 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1433 _test_textarea_value(line
, unk
, value
);
1436 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1437 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1439 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1440 VARIANT_BOOL b
= 0x100;
1443 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1444 IHTMLTextAreaElement_Release(textarea
);
1445 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1446 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1449 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1450 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1452 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1455 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1456 IHTMLTextAreaElement_Release(textarea
);
1457 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1459 _test_textarea_readonly(line
, unk
, b
);
1462 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1463 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1465 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1466 BSTR type
= (void*)0xdeadbeef;
1469 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1470 IHTMLTextAreaElement_Release(textarea
);
1471 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1472 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1473 SysFreeString(type
);
1476 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1477 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1479 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1483 text
= a2bstr(extext
);
1484 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1485 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1486 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1488 IHTMLCommentElement_Release(comment
);
1489 SysFreeString(text
);
1492 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1493 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1495 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1496 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1497 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1498 IHTMLDOMAttribute
*attr
;
1499 BSTR name
= a2bstr("test");
1503 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1504 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1505 ok(attr
== NULL
, "attr != NULL\n");
1509 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1510 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1512 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1513 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1514 ok(attr
!= NULL
, "attr == NULL\n");
1516 IHTMLDOMAttribute_Release(attr
);
1517 IHTMLCommentElement_Release(comment
);
1518 IHTMLElement_Release(elem
);
1519 IHTMLElement4_Release(elem
);
1520 SysFreeString(name
);
1523 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1524 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1526 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1531 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1532 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1533 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1534 IHTMLObjectElement_Release(object
);
1537 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1538 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1539 const char *txt
, const char *val
)
1541 IHTMLOptionElementFactory
*factory
;
1542 IHTMLOptionElement
*option
;
1543 IHTMLWindow2
*window
;
1544 VARIANT text
, value
, empty
;
1547 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1548 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1550 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1551 IHTMLWindow2_Release(window
);
1552 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1554 V_VT(&text
) = VT_BSTR
;
1555 V_BSTR(&text
) = a2bstr(txt
);
1556 V_VT(&value
) = VT_BSTR
;
1557 V_BSTR(&value
) = a2bstr(val
);
1558 V_VT(&empty
) = VT_EMPTY
;
1560 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1561 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1563 IHTMLOptionElementFactory_Release(factory
);
1564 VariantClear(&text
);
1565 VariantClear(&value
);
1567 _test_option_text(line
, option
, txt
);
1568 _test_option_value(line
, option
, val
);
1569 _test_option_selected(line
, option
, VARIANT_FALSE
);
1574 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1575 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1580 hres
= IHTMLImgElement_get_width(img
, &found
);
1581 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1582 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1585 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1586 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1590 hres
= IHTMLImgElement_put_width(img
, width
);
1591 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1593 _test_img_width(line
, img
, width
);
1596 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1597 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1602 hres
= IHTMLImgElement_get_height(img
, &found
);
1603 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1604 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1607 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1608 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1612 hres
= IHTMLImgElement_put_height(img
, height
);
1613 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1615 _test_img_height(line
, img
, height
);
1618 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1619 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1620 LONG wdth
, LONG hght
)
1622 IHTMLImageElementFactory
*factory
;
1623 IHTMLImgElement
*img
;
1624 IHTMLWindow2
*window
;
1625 VARIANT width
, height
;
1629 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1630 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1632 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1633 IHTMLWindow2_Release(window
);
1634 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1636 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1637 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1640 snprintf(buf
, 16, "%d", wdth
);
1641 V_VT(&width
) = VT_BSTR
;
1642 V_BSTR(&width
) = a2bstr(buf
);
1644 V_VT(&width
) = VT_EMPTY
;
1649 snprintf(buf
, 16, "%d", hght
);
1650 V_VT(&height
) = VT_BSTR
;
1651 V_BSTR(&height
) = a2bstr(buf
);
1653 V_VT(&height
) = VT_EMPTY
;
1657 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1658 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1660 IHTMLImageElementFactory_Release(factory
);
1661 VariantClear(&width
);
1662 VariantClear(&height
);
1664 if(SUCCEEDED(hres
)) {
1665 _test_img_width(line
, img
, wdth
);
1666 _test_img_height(line
, img
, hght
);
1673 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1674 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1676 LONG len
= 0xdeadbeef;
1679 hres
= IHTMLSelectElement_get_length(select
, &len
);
1680 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1681 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1684 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1685 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1687 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1690 hres
= IHTMLSelectElement_put_length(select
, length
);
1691 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1692 _test_select_length(line
, select
, length
);
1693 IHTMLSelectElement_Release(select
);
1696 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1697 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1699 LONG idx
= 0xdeadbeef;
1702 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1703 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1704 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1707 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1708 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1712 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1713 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1714 _test_select_selidx(line
, select
, index
);
1717 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1718 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1723 hres
= IHTMLSelectElement_get_value(select
, &val
);
1724 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1726 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1728 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1732 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1733 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1739 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1740 SysFreeString(bstr
);
1741 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1744 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1745 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1750 hres
= IHTMLSelectElement_get_type(select
, &type
);
1751 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1752 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1753 SysFreeString(type
);
1756 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1757 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1762 hres
= IHTMLTxtRange_get_text(range
, &text
);
1763 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1766 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1767 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1769 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1772 SysFreeString(text
);
1776 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1777 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1781 hres
= IHTMLTxtRange_collapse(range
, b
);
1782 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1783 _test_range_text(line
, range
, NULL
);
1786 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1787 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1788 VARIANT_BOOL exb
, const char *extext
)
1790 VARIANT_BOOL b
= 0xe0e0;
1793 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1794 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1795 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1796 _test_range_text(line
, range
, extext
);
1799 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1800 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1802 LONG c
= 0xdeadbeef;
1805 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1806 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1807 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1808 _test_range_text(line
, range
, NULL
);
1811 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1812 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1813 LPWSTR unit
, LONG cnt
, LONG excnt
)
1815 LONG c
= 0xdeadbeef;
1818 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1819 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1820 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1823 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1824 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1826 LONG c
= 0xdeadbeef;
1829 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1830 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1831 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1834 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1835 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1838 BSTR bstr
= a2bstr(text
);
1840 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1841 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1842 SysFreeString(bstr
);
1843 _test_range_text(line
, range
, NULL
);
1846 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1847 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1853 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1854 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1855 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1858 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1859 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1865 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1866 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1867 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1870 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1871 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1872 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1875 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1876 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1880 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1881 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1886 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1887 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1889 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1891 IHTMLElement_Release(elem
);
1894 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1895 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1896 const elem_type_t
*elem_types
, LONG exlen
)
1898 IHTMLElementCollection
*col
;
1901 VARIANT name
, index
;
1902 IDispatch
*disp
, *disp2
;
1905 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1906 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1908 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1910 hres
= IHTMLElementCollection_get_length(col
, &len
);
1911 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1912 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1917 V_VT(&index
) = VT_EMPTY
;
1919 for(i
=0; i
<len
; i
++) {
1920 V_VT(&name
) = VT_I4
;
1922 disp
= (void*)0xdeadbeef;
1923 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1924 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1925 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1926 if(FAILED(hres
) || !disp
)
1929 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1932 V_VT(&name
) = VT_UINT
;
1934 disp2
= (void*)0xdeadbeef;
1935 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1936 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1937 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1939 IDispatch_Release(disp2
);
1942 IDispatch_Release(disp
);
1945 V_VT(&name
) = VT_I4
;
1947 disp
= (void*)0xdeadbeef;
1948 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1949 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1950 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1952 V_VT(&name
) = VT_I4
;
1954 disp
= (void*)0xdeadbeef;
1955 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1956 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1957 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1959 IHTMLElementCollection_Release(col
);
1962 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1963 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1965 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1969 hres
= IHTMLElement_get_all(elem
, &disp
);
1970 IHTMLElement_Release(elem
);
1971 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1973 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1974 IDispatch_Release(disp
);
1977 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1978 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1980 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1981 IHTMLElementCollection
*col
= NULL
;
1982 elem_type_t
*types
= NULL
;
1987 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1988 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1990 IHTMLElement2_Release(elem
);
1991 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1992 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1995 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1996 for(i
=0; i
<exlen
; i
++)
2000 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2002 HeapFree(GetProcessHeap(), 0, types
);
2005 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2006 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2011 hres
= IHTMLElement_get_innerText(elem
, &text
);
2012 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2013 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2014 wine_dbgstr_w(text
), extext
);
2015 SysFreeString(text
);
2018 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2019 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2021 IHTMLDOMChildrenCollection
*col
;
2026 hres
= IHTMLElement_put_innerText(elem
, str
);
2027 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2030 _test_elem_innertext(line
, elem
, text
);
2033 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2034 ok(col
!= NULL
, "col == NULL\n");
2036 LONG length
= 0, type
;
2039 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2040 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2041 ok(length
== 1, "length = %d\n", length
);
2043 node
= _get_child_item(line
, col
, 0);
2044 ok(node
!= NULL
, "node == NULL\n");
2046 type
= _get_node_type(line
, (IUnknown
*)node
);
2047 ok(type
== 3, "type=%d\n", type
);
2048 IHTMLDOMNode_Release(node
);
2051 IHTMLDOMChildrenCollection_Release(col
);
2056 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2057 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2059 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2063 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2064 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2066 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2068 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2070 IHTMLElement_Release(elem
);
2071 SysFreeString(html
);
2074 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2075 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2077 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2081 html
= a2bstr(inner_html
);
2082 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2083 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2085 IHTMLElement_Release(elem
);
2086 SysFreeString(html
);
2089 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2090 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2092 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2096 html
= a2bstr(outer_html
);
2097 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2098 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2100 IHTMLElement_Release(elem
);
2101 SysFreeString(html
);
2104 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2105 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2107 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2111 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2112 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2113 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2115 IHTMLElement_Release(elem
);
2116 SysFreeString(html
);
2119 #define get_first_child(n) _get_first_child(__LINE__,n)
2120 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2122 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2123 IHTMLDOMNode
*child
= NULL
;
2126 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2127 IHTMLDOMNode_Release(node
);
2128 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2133 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2134 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2136 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2137 VARIANT_BOOL b
= 0xdead;
2140 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2141 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2142 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2144 IHTMLDOMNode_Release(node
);
2147 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2148 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2150 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2151 IHTMLDOMNode
*parent
;
2154 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2155 IHTMLDOMNode_Release(node
);
2156 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2161 #define node_get_next(u) _node_get_next(__LINE__,u)
2162 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2164 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2168 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2169 IHTMLDOMNode_Release(node
);
2170 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2175 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2176 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2178 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2182 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2183 IHTMLDOMNode_Release(node
);
2184 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2189 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2190 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2192 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2193 IHTMLElement
*parent
;
2196 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2197 IHTMLElement_Release(elem
);
2198 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2203 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2204 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2206 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2207 VARIANT_BOOL disabled
= 100;
2211 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2212 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2213 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2214 IHTMLElement3_Release(elem3
);
2217 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2218 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2220 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2224 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2225 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2227 IHTMLElement3_Release(elem3
);
2228 _test_elem3_get_disabled(line
, unk
, b
);
2231 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2232 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2234 VARIANT_BOOL disabled
= 100;
2237 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2238 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2239 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2241 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2244 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2245 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
2247 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2251 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
2252 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2253 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
2254 IHTMLDOMTextNode_Release(text
);
2257 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2258 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
2262 hres
= IHTMLSelectElement_put_disabled(select
, b
);
2263 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2265 _test_select_get_disabled(line
, select
, b
);
2268 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2269 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
2271 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2272 IHTMLTextContainer
*txtcont
;
2273 LONG l
= -1, l2
= -1;
2276 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
2277 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
2278 IHTMLElement2_Release(elem
);
2280 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2281 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2283 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
2284 IHTMLTextContainer_Release(txtcont
);
2285 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
2286 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
2291 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2292 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
2294 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2295 IHTMLTextContainer
*txtcont
;
2296 LONG l
= -1, l2
= -1;
2299 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
2300 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
2301 IHTMLElement2_Release(elem
);
2303 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2304 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2306 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
2307 IHTMLTextContainer_Release(txtcont
);
2308 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
2309 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
2314 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2315 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
2317 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2318 IHTMLTextContainer
*txtcont
;
2319 LONG l
= -1, l2
= -1;
2322 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
2323 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2324 IHTMLElement2_Release(elem
);
2326 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2327 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2329 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
2330 IHTMLTextContainer_Release(txtcont
);
2331 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
2332 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2337 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2338 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2340 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2341 IHTMLTextContainer
*txtcont
;
2342 LONG l
= -1, l2
= -1;
2345 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2346 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2348 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2349 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2350 IHTMLElement2_Release(elem
);
2352 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2353 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2355 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2356 IHTMLTextContainer_Release(txtcont
);
2357 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2358 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2361 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2362 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
2364 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2368 hres
= IHTMLImgElement_get_src(img
, &src
);
2369 IHTMLImgElement_Release(img
);
2370 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2371 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
2372 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2376 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2377 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2379 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2384 hres
= IHTMLImgElement_put_src(img
, tmp
);
2385 IHTMLImgElement_Release(img
);
2387 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2390 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2391 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2393 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2397 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2398 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2400 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2402 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2406 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2407 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2409 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2414 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2415 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2418 _test_img_alt(line
, unk
, alt
);
2421 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2422 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2424 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2428 hres
= IHTMLImgElement_get_name(img
, &sName
);
2429 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2430 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2431 IHTMLImgElement_Release(img
);
2432 SysFreeString(sName
);
2435 static void test_dynamic_properties(IHTMLElement
*elem
)
2437 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
2438 IDispatchEx
*dispex
;
2439 BSTR name
, attr1
= SysAllocString(attr1W
);
2443 DISPID id
= DISPID_STARTENUM
;
2446 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2447 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2449 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
2450 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
2451 ok(succ
, "removeAttribute set succ to FALSE\n");
2454 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2455 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
2459 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
2460 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
2462 if(!strcmp_wa(name
, "attr1"))
2463 ok(0, "attr1 should be removed\n");
2464 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
2466 SysFreeString(name
);
2468 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
2469 IDispatchEx_Release(dispex
);
2471 V_VT(&val
) = VT_BSTR
;
2472 V_BSTR(&val
) = attr1
;
2473 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
2474 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2475 SysFreeString(attr1
);
2478 static void test_attr_collection_disp(IDispatch
*disp
)
2480 IDispatchEx
*dispex
;
2481 IHTMLDOMAttribute
*attr
;
2482 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
2489 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
2490 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2493 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2494 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2495 SysFreeString(bstr
);
2498 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2499 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2500 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2501 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2504 bstr
= a2bstr("attr1");
2505 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2506 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2507 SysFreeString(bstr
);
2510 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2511 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2512 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2513 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2514 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
2515 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2516 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &bstr
);
2517 ok(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
2518 ok(!strcmp_wa(bstr
, "attr1"), "node name is %s, expected attr1\n", wine_dbgstr_w(bstr
));
2519 SysFreeString(bstr
);
2520 IHTMLDOMAttribute_Release(attr
);
2523 IDispatchEx_Release(dispex
);
2526 static void test_attr_collection(IHTMLElement
*elem
)
2528 static const WCHAR testW
[] = {'t','e','s','t',0};
2531 IDispatch
*disp
, *attr
;
2532 IHTMLDOMAttribute
*dom_attr
;
2533 IHTMLAttributeCollection
*attr_col
;
2534 BSTR name
= SysAllocString(testW
);
2536 LONG i
, len
, checked
;
2539 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
2540 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2542 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
2543 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
2545 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
2546 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
2547 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
2548 IDispatch_Release(attr
);
2549 IHTMLDOMNode_Release(node
);
2551 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
2552 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2554 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
2555 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2559 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2560 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2561 SysFreeString(name
);
2563 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
2564 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2565 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
2568 for(i
=0; i
<len
; i
++) {
2571 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
2572 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
2574 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
2575 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
2576 IDispatch_Release(attr
);
2578 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
2579 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
2581 if(!strcmp_wa(name
, "id")) {
2583 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
2584 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
2585 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
2586 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
2587 } else if(!strcmp_wa(name
, "attr1")) {
2589 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
2590 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
2591 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
2592 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
2593 } else if(!strcmp_wa(name
, "attr2")) {
2595 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
2596 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
2597 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
2598 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
2599 } else if(!strcmp_wa(name
, "attr3")) {
2601 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
2602 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
2603 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
2604 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
2605 } else if(!strcmp_wa(name
, "test")) {
2607 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
2608 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
2609 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
2610 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
2613 IHTMLDOMAttribute_Release(dom_attr
);
2614 SysFreeString(name
);
2617 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
2620 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
2621 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
2623 V_VT(&id
) = VT_BSTR
;
2624 V_BSTR(&id
) = a2bstr("nonexisting");
2625 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
2626 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
2629 test_attr_collection_disp(disp
);
2631 IDispatch_Release(disp
);
2632 IHTMLAttributeCollection_Release(attr_col
);
2635 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
2636 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2638 VARIANT_BOOL specified
;
2641 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
2642 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
2643 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
2646 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2647 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
2652 hres
= IHTMLInputElement_get_type(input
, &type
);
2653 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2654 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2655 SysFreeString(type
);
2658 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2659 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
2661 BSTR name
= (BSTR
)0xdeadbeef;
2664 hres
= IHTMLInputElement_get_name(input
, &name
);
2665 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2667 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
2669 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
2670 SysFreeString(name
);
2673 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2674 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
2676 BSTR tmp
= a2bstr(name
);
2679 hres
= IHTMLInputElement_put_name(input
, tmp
);
2680 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
2683 _test_input_name(line
, input
, name
);
2686 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2687 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2689 VARIANT_BOOL disabled
= 100;
2692 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
2693 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2694 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2696 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
2699 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2700 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2704 hres
= IHTMLInputElement_put_disabled(input
, b
);
2705 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2707 _test_input_get_disabled(line
, input
, b
);
2710 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2711 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2713 VARIANT_BOOL checked
= 100;
2716 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
2717 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2718 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2721 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2722 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2726 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2727 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2729 _test_input_get_defaultchecked(line
, input
, b
);
2732 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2733 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2735 VARIANT_BOOL checked
= 100;
2738 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2739 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2740 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2743 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2744 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2748 hres
= IHTMLInputElement_put_checked(input
, b
);
2749 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
2751 _test_input_get_checked(line
, input
, b
);
2754 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
2755 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
2757 LONG maxlength
= 0xdeadbeef;
2760 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
2761 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
2762 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
2765 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
2766 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
2770 hres
= IHTMLInputElement_put_maxLength(input
, l
);
2771 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
2773 _test_input_maxlength(line
, input
, l
);
2776 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2777 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2779 IHTMLInputElement
*input
;
2783 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2784 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2788 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2789 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2791 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2793 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
2794 SysFreeString(bstr
);
2795 IHTMLInputElement_Release(input
);
2798 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2799 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2801 IHTMLInputElement
*input
;
2805 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2806 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2811 hres
= IHTMLInputElement_put_value(input
, bstr
);
2812 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2813 SysFreeString(bstr
);
2814 IHTMLInputElement_Release(input
);
2816 _test_input_value(line
, unk
, val
);
2819 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2820 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2825 hres
= IHTMLInputElement_get_src(input
, &src
);
2826 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2828 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2830 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2834 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2835 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2841 hres
= IHTMLInputElement_put_src(input
, tmp
);
2843 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2845 _test_input_src(line
, input
, src
);
2848 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2849 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2851 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2852 BSTR
class = (void*)0xdeadbeef;
2855 hres
= IHTMLElement_get_className(elem
, &class);
2856 IHTMLElement_Release(elem
);
2857 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2859 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2861 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2862 SysFreeString(class);
2865 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2866 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2868 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2872 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2873 IHTMLElement2_Release(elem2
);
2874 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2875 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2878 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2879 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2881 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2884 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2885 IHTMLElement2_Release(elem2
);
2886 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2888 _test_elem_tabindex(line
, unk
, index
);
2891 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2892 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
2894 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2898 hres
= IHTMLStyleElement_get_media(style
, &media
);
2899 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
2901 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
2903 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
2905 IHTMLStyleElement_Release(style
);
2906 SysFreeString(media
);
2909 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2910 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
2912 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2916 str
= a2bstr(media
);
2917 hres
= IHTMLStyleElement_put_media(style
, str
);
2918 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
2919 IHTMLStyleElement_Release(style
);
2922 _test_style_media(line
, unk
, media
);
2925 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2926 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
2928 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2932 hres
= IHTMLStyleElement_get_type(style
, &type
);
2933 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
2935 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
2937 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
2939 IHTMLStyleElement_Release(style
);
2940 SysFreeString(type
);
2943 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2944 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
2946 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2951 hres
= IHTMLStyleElement_put_type(style
, str
);
2952 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
2953 IHTMLStyleElement_Release(style
);
2956 _test_style_type(line
, unk
, type
);
2959 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2960 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2962 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2964 IHTMLFiltersCollection
*filters
;
2966 hres
= IHTMLElement_get_filters(elem
, &filters
);
2967 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2968 "get_filters failed: %08x\n", hres
);
2972 IDispatchEx
*dispex
;
2974 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2975 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2976 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2978 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2979 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2980 "Could not get IDispatchEx interface: %08x\n", hres
);
2981 if(SUCCEEDED(hres
)) {
2982 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2983 IDispatchEx_Release(dispex
);
2986 IHTMLFiltersCollection_Release(filters
);
2989 IHTMLElement_Release(elem
);
2992 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2993 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2995 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2999 tmp
= class ? a2bstr(class) : NULL
;
3000 hres
= IHTMLElement_put_className(elem
, tmp
);
3001 IHTMLElement_Release(elem
);
3002 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
3005 _test_elem_class(line
, unk
, class);
3008 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3009 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3011 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3012 BSTR id
= (void*)0xdeadbeef;
3015 hres
= IHTMLElement_get_id(elem
, &id
);
3016 IHTMLElement_Release(elem
);
3017 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3020 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3022 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3027 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3028 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3030 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3031 BSTR tmp
= a2bstr(new_id
);
3034 hres
= IHTMLElement_put_id(elem
, tmp
);
3035 IHTMLElement_Release(elem
);
3037 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3039 _test_elem_id(line
, unk
, new_id
);
3042 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
3043 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
3045 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3049 hres
= IHTMLElement_get_title(elem
, &title
);
3050 IHTMLElement_Release(elem
);
3051 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3053 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
3055 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
3057 SysFreeString(title
);
3060 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
3061 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
3063 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3067 tmp
= a2bstr(title
);
3068 hres
= IHTMLElement_put_title(elem
, tmp
);
3069 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3071 IHTMLElement_Release(elem
);
3075 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
3076 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
3078 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3082 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
3083 IHTMLDOMNode_Release(node
);
3084 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3087 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
3088 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
3090 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
3096 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
3097 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
3099 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3103 V_VT(&var
) = VT_BSTR
;
3104 V_BSTR(&var
) = a2bstr(val
);
3106 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
3107 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3108 IHTMLDOMNode_Release(node
);
3112 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
3113 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
3115 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3119 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
3120 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
3121 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
3122 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
3124 IHTMLElement2_Release(elem
);
3127 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
3128 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
3130 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3134 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
3135 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
3136 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
3138 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
3139 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
3140 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
3142 IHTMLElement2_Release(elem
);
3145 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
3146 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
3148 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3149 LONG len
= 0xdeadbeef;
3152 hres
= IHTMLFormElement_get_length(form
, &len
);
3153 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3154 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
3156 IHTMLFormElement_Release(form
);
3159 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
3160 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
3162 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3163 BSTR action
= (void*)0xdeadbeef;
3166 hres
= IHTMLFormElement_get_action(form
, &action
);
3167 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
3169 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
3171 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
3173 SysFreeString(action
);
3174 IHTMLFormElement_Release(form
);
3177 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
3178 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
3180 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3181 BSTR tmp
= a2bstr(action
);
3184 hres
= IHTMLFormElement_put_action(form
, tmp
);
3185 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
3187 IHTMLFormElement_Release(form
);
3189 _test_form_action(line
, unk
, action
);
3192 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
3193 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
3195 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3196 BSTR method
= (void*)0xdeadbeef;
3199 hres
= IHTMLFormElement_get_method(form
, &method
);
3200 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
3202 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
3204 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
3206 SysFreeString(method
);
3207 IHTMLFormElement_Release(form
);
3210 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
3211 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
3213 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3214 BSTR tmp
= a2bstr(method
);
3217 hres
= IHTMLFormElement_put_method(form
, tmp
);
3218 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
3220 IHTMLFormElement_Release(form
);
3222 if(exp_hres
== S_OK
)
3223 _test_form_method(line
, unk
, method
);
3226 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
3227 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
3229 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3230 BSTR name
= (void*)0xdeadbeef;
3233 hres
= IHTMLFormElement_get_name(form
, &name
);
3234 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3236 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
3238 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
3240 SysFreeString(name
);
3241 IHTMLFormElement_Release(form
);
3244 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
3245 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
3247 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3248 BSTR tmp
= a2bstr(name
);
3251 hres
= IHTMLFormElement_put_name(form
, tmp
);
3252 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
3254 IHTMLFormElement_Release(form
);
3256 _test_form_name(line
, unk
, name
);
3259 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
3260 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
3262 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3263 BSTR encoding
= (void*)0xdeadbeef;
3266 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
3267 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
3269 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
3271 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
3273 SysFreeString(encoding
);
3274 IHTMLFormElement_Release(form
);
3277 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
3278 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
3280 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3281 BSTR tmp
= a2bstr(encoding
);
3284 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
3285 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
3287 IHTMLFormElement_Release(form
);
3289 if(exp_hres
== S_OK
)
3290 _test_form_encoding(line
, unk
, encoding
);
3293 #define test_form_elements(a) _test_form_elements(__LINE__,a)
3294 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
3296 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3301 hres
= IHTMLFormElement_get_elements(form
, &disp
);
3302 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
3303 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
3304 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
3306 IDispatch_Release(disp
);
3307 IHTMLFormElement_Release(form
);
3310 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
3311 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
3313 IHTMLMetaElement
*meta
;
3318 meta
= _get_metaelem_iface(line
, unk
);
3319 hres
= IHTMLMetaElement_get_name(meta
, &name
);
3320 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3321 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
3322 SysFreeString(name
);
3323 IHTMLMetaElement_Release(meta
);
3326 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
3327 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
3329 IHTMLMetaElement
*meta
;
3330 BSTR content
= NULL
;
3334 meta
= _get_metaelem_iface(line
, unk
);
3335 hres
= IHTMLMetaElement_get_content(meta
, &content
);
3336 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
3337 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
3338 SysFreeString(content
);
3339 IHTMLMetaElement_Release(meta
);
3342 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
3343 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
3345 IHTMLMetaElement
*meta
;
3350 meta
= _get_metaelem_iface(line
, unk
);
3351 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
3352 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
3353 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
3355 IHTMLMetaElement_Release(meta
);
3358 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
3359 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
3361 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3362 IHTMLDocument2
*doc
;
3367 hres
= IHTMLElement_get_document(elem
, &disp
);
3368 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
3369 ok(disp
!= NULL
, "disp == NULL\n");
3371 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
3372 IDispatch_Release(disp
);
3373 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
3378 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
3379 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
3381 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
3382 BSTR str
= a2bstr(attr_name
);
3383 IHTMLDOMAttribute
*attr
;
3386 attr
= (void*)0xdeadbeef;
3387 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
3388 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
3390 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
3392 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
3394 IHTMLElement4_Release(elem
);
3399 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
3400 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
3404 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
3405 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3406 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
3409 #define get_window_doc(e) _get_window_doc(__LINE__,e)
3410 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
3412 IHTMLDocument2
*doc
;
3416 hres
= IHTMLWindow2_get_document(window
, &doc
);
3417 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
3418 ok(doc
!= NULL
, "disp == NULL\n");
3423 #define doc_get_body(d) _doc_get_body(__LINE__,d)
3424 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
3429 hres
= IHTMLDocument2_get_body(doc
, &elem
);
3430 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3431 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
3436 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
3437 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
3439 IHTMLElement
*elem
= NULL
;
3444 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
3445 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
3446 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
3452 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
3453 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
3455 IHTMLDocument3
*doc3
;
3456 IHTMLDOMNode
*node
= NULL
;
3460 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
3461 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
3464 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
3465 IHTMLDocument3_Release(doc3
);
3467 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
3468 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
3473 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
3474 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
3476 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
3477 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
3478 IHTMLDOMNode
*new_child
= NULL
;
3481 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
3482 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
3483 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
3484 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3486 IHTMLDOMNode_Release(node
);
3487 IHTMLDOMNode_Release(child
);
3492 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
3493 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
3495 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
3496 IHTMLDOMNode
*new_child
= NULL
;
3499 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
3500 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
3501 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
3502 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3504 IHTMLDOMNode_Release(node
);
3509 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
3510 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
3512 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3513 IHTMLDOMNode
*new_node
= NULL
;
3516 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
3517 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
3518 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
3519 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
3521 IHTMLDOMNode_Release(node
);
3522 IHTMLDOMNode_Release(new_node
);
3525 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
3526 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
3531 hres
= IHTMLDocument2_get_title(doc
, &title
);
3532 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3533 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
3534 SysFreeString(title
);
3537 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3538 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
3543 tmp
= a2bstr(title
);
3544 hres
= IHTMLDocument2_put_title(doc
, tmp
);
3545 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3549 static void test_elem_bounding_client_rect(IUnknown
*unk
)
3551 IHTMLRect
*rect
, *rect2
;
3552 IHTMLElement2
*elem2
;
3556 elem2
= get_elem2_iface(unk
);
3557 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
3558 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
3559 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
3560 IHTMLElement2_Release(elem2
);
3561 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
3562 ok(rect
!= NULL
, "rect == NULL\n");
3563 ok(rect
!= rect2
, "rect == rect2\n");
3564 IHTMLRect_Release(rect2
);
3566 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
3569 hres
= IHTMLRect_get_top(rect
, &l
);
3570 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3571 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3574 hres
= IHTMLRect_get_left(rect
, &l
);
3575 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3576 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3579 hres
= IHTMLRect_get_bottom(rect
, &l
);
3580 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3581 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3584 hres
= IHTMLRect_get_right(rect
, &l
);
3585 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3586 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3588 IHTMLRect_Release(rect
);
3591 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
3592 const elem_type_t
*elem_types
, LONG len
)
3595 VARIANT name
, index
;
3599 V_VT(&index
) = VT_EMPTY
;
3600 V_VT(&name
) = VT_BSTR
;
3601 V_BSTR(&name
) = a2bstr(n
);
3603 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3604 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3606 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
3607 IDispatch_Release(disp
);
3609 V_VT(&index
) = VT_I4
;
3611 for(i
=0; i
<len
; i
++) {
3613 disp
= (void*)0xdeadbeef;
3614 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3615 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3616 ok(disp
!= NULL
, "disp == NULL\n");
3617 if(FAILED(hres
) || !disp
)
3620 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
3622 IDispatch_Release(disp
);
3626 disp
= (void*)0xdeadbeef;
3627 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3628 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3629 ok(disp
== NULL
, "disp != NULL\n");
3632 disp
= (void*)0xdeadbeef;
3633 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3634 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3635 ok(disp
== NULL
, "disp != NULL\n");
3637 SysFreeString(V_BSTR(&name
));
3640 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
3642 IHTMLElementCollection
*col
;
3644 IDispatch
*disp
= (void*)0xdeadbeef;
3645 VARIANT name
, index
;
3648 hres
= IHTMLDocument2_get_all(doc
, &col
);
3649 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3650 ok(col
!= NULL
, "col == NULL\n");
3651 if(FAILED(hres
) || !col
)
3654 V_VT(&index
) = VT_EMPTY
;
3655 V_VT(&name
) = VT_BSTR
;
3656 V_BSTR(&name
) = a2bstr(id
);
3658 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3659 IHTMLElementCollection_Release(col
);
3660 SysFreeString(V_BSTR(&name
));
3661 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3662 if(!expect_success
) {
3663 ok(disp
== NULL
, "disp != NULL\n");
3667 ok(disp
!= NULL
, "disp == NULL\n");
3671 elem
= get_elem_iface((IUnknown
*)disp
);
3672 IDispatch_Release(disp
);
3677 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
3679 IHTMLDocument3
*doc3
;
3684 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
3685 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
3688 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
3690 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
3692 IHTMLDocument3_Release(doc3
);
3697 static void test_select_elem(IHTMLSelectElement
*select
)
3699 IDispatch
*disp
, *disp2
;
3700 VARIANT name
, index
;
3703 test_select_type(select
, "select-one");
3704 test_select_length(select
, 2);
3705 test_select_selidx(select
, 0);
3706 test_select_put_selidx(select
, 1);
3708 test_select_set_value(select
, "val1");
3709 test_select_value(select
, "val1");
3711 test_select_get_disabled(select
, VARIANT_FALSE
);
3712 test_select_set_disabled(select
, VARIANT_TRUE
);
3713 test_select_set_disabled(select
, VARIANT_FALSE
);
3716 hres
= IHTMLSelectElement_get_options(select
, &disp
);
3717 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
3718 ok(disp
!= NULL
, "options == NULL\n");
3719 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
3720 IDispatch_Release(disp
);
3722 V_VT(&index
) = VT_EMPTY
;
3723 V_VT(&name
) = VT_I4
;
3725 disp
= (void*)0xdeadbeef;
3726 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3727 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3728 ok(!disp
, "disp = %p\n", disp
);
3731 disp
= (void*)0xdeadbeef;
3732 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3733 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3734 ok(!disp
, "disp = %p\n", disp
);
3737 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
3738 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
3741 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3742 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3743 ok(disp
!= NULL
, "disp = NULL\n");
3744 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
3746 V_VT(&index
) = VT_I4
;
3749 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
3750 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3751 ok(disp2
!= NULL
, "disp = NULL\n");
3752 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
3753 IDispatch_Release(disp2
);
3754 IDispatch_Release(disp
);
3757 static void test_form_item(IHTMLElement
*elem
)
3759 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
3760 IDispatch
*disp
, *disp2
;
3761 VARIANT name
, index
;
3764 V_VT(&index
) = VT_EMPTY
;
3765 V_VT(&name
) = VT_I4
;
3767 disp
= (void*)0xdeadbeef;
3768 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3769 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3770 ok(!disp
, "disp = %p\n", disp
);
3773 disp
= (void*)0xdeadbeef;
3774 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3775 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3776 ok(!disp
, "disp = %p\n", disp
);
3779 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
3780 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3783 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3784 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3785 ok(disp
!= NULL
, "disp = NULL\n");
3786 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
3788 V_VT(&index
) = VT_I4
;
3791 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
3792 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3793 ok(disp2
!= NULL
, "disp = NULL\n");
3794 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
3795 IDispatch_Release(disp2
);
3796 IDispatch_Release(disp
);
3799 static void test_create_option_elem(IHTMLDocument2
*doc
)
3801 IHTMLOptionElement
*option
;
3803 option
= create_option_elem(doc
, "test text", "test value");
3805 test_option_put_text(option
, "new text");
3806 test_option_put_value(option
, "new value");
3807 test_option_put_selected(option
, VARIANT_TRUE
);
3808 test_option_put_selected(option
, VARIANT_FALSE
);
3810 IHTMLOptionElement_Release(option
);
3813 static void test_create_img_elem(IHTMLDocument2
*doc
)
3815 IHTMLImgElement
*img
;
3817 img
= create_img_elem(doc
, 10, 15);
3820 test_img_put_width(img
, 5);
3821 test_img_put_height(img
, 20);
3823 IHTMLImgElement_Release(img
);
3827 img
= create_img_elem(doc
, -1, -1);
3830 test_img_put_width(img
, 5);
3831 test_img_put_height(img
, 20);
3833 IHTMLImgElement_Release(img
);
3837 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
3839 IHTMLBodyElement
*body
;
3840 IHTMLTxtRange
*range
;
3844 elem
= doc_get_body(doc
);
3845 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
3846 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3847 IHTMLElement_Release(elem
);
3849 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
3850 IHTMLBodyElement_Release(body
);
3851 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
3856 static void test_txtrange(IHTMLDocument2
*doc
)
3858 IHTMLTxtRange
*body_range
, *range
, *range2
;
3859 IHTMLSelectionObject
*selection
;
3860 IDispatch
*disp_range
;
3863 body_range
= test_create_body_range(doc
);
3865 test_range_text(body_range
, "test abc 123\r\nit's text");
3867 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3868 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3870 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
3871 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3872 test_range_isequal(range
, range2
, VARIANT_TRUE
);
3874 test_range_text(range
, "test abc 123\r\nit's text");
3875 test_range_text(body_range
, "test abc 123\r\nit's text");
3877 test_range_collapse(range
, TRUE
);
3878 test_range_isequal(range
, range2
, VARIANT_FALSE
);
3879 test_range_inrange(range
, range2
, VARIANT_FALSE
);
3880 test_range_inrange(range2
, range
, VARIANT_TRUE
);
3881 IHTMLTxtRange_Release(range2
);
3883 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3884 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
3885 test_range_move(range
, characterW
, 2, 2);
3886 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3888 test_range_collapse(range
, FALSE
);
3889 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
3891 test_range_collapse(range
, FALSE
);
3892 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3893 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
3894 test_range_move(range
, characterW
, 2, 2);
3895 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3896 test_range_moveend(range
, characterW
, -5, -5);
3897 test_range_text(range
, NULL
);
3898 test_range_moveend(range
, characterW
, 3, 3);
3899 test_range_text(range
, "c 1");
3900 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
3901 test_range_collapse(range
, TRUE
);
3902 test_range_move(range
, characterW
, 4, 4);
3903 test_range_moveend(range
, characterW
, 1, 1);
3904 test_range_text(range
, " ");
3905 test_range_move(range
, wordW
, 1, 1);
3906 test_range_moveend(range
, characterW
, 2, 2);
3907 test_range_text(range
, "ab");
3909 IHTMLTxtRange_Release(range
);
3911 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3912 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3914 test_range_text(range
, "test abc 123\r\nit's text");
3915 test_range_move(range
, characterW
, 3, 3);
3916 test_range_moveend(range
, characterW
, 1, 1);
3917 test_range_text(range
, "t");
3918 test_range_moveend(range
, characterW
, 3, 3);
3919 test_range_text(range
, "t ab");
3920 test_range_moveend(range
, characterW
, -2, -2);
3921 test_range_text(range
, "t ");
3922 test_range_move(range
, characterW
, 6, 6);
3923 test_range_moveend(range
, characterW
, 3, 3);
3924 test_range_text(range
, "123");
3925 test_range_moveend(range
, characterW
, 2, 2);
3926 test_range_text(range
, "123\r\ni");
3928 IHTMLTxtRange_Release(range
);
3930 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3931 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3933 test_range_move(range
, wordW
, 1, 1);
3934 test_range_moveend(range
, characterW
, 2, 2);
3935 test_range_text(range
, "ab");
3937 test_range_move(range
, characterW
, -2, -2);
3938 test_range_moveend(range
, characterW
, 2, 2);
3939 test_range_text(range
, "t ");
3941 test_range_move(range
, wordW
, 3, 3);
3942 test_range_move(range
, wordW
, -2, -2);
3943 test_range_moveend(range
, characterW
, 2, 2);
3944 test_range_text(range
, "ab");
3946 test_range_move(range
, characterW
, -6, -5);
3947 test_range_moveend(range
, characterW
, -1, 0);
3948 test_range_moveend(range
, characterW
, -6, 0);
3949 test_range_move(range
, characterW
, 2, 2);
3950 test_range_moveend(range
, characterW
, 2, 2);
3951 test_range_text(range
, "st");
3952 test_range_moveend(range
, characterW
, -6, -4);
3953 test_range_moveend(range
, characterW
, 2, 2);
3955 IHTMLTxtRange_Release(range
);
3957 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3958 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3960 test_range_move(range
, wordW
, 2, 2);
3961 test_range_moveend(range
, characterW
, 2, 2);
3962 test_range_text(range
, "12");
3964 test_range_move(range
, characterW
, 15, 14);
3965 test_range_move(range
, characterW
, -2, -2);
3966 test_range_moveend(range
, characterW
, 3, 2);
3967 test_range_text(range
, "t");
3968 test_range_moveend(range
, characterW
, -1, -1);
3969 test_range_text(range
, "t");
3970 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
3971 test_range_move(range
, characterW
, -2, -2);
3972 test_range_moveend(range
, characterW
, 2, 2);
3973 test_range_text(range
, "s ");
3974 test_range_move(range
, characterW
, 100, 7);
3975 test_range_move(range
, wordW
, 1, 0);
3976 test_range_move(range
, characterW
, -2, -2);
3977 test_range_moveend(range
, characterW
, 3, 2);
3978 test_range_text(range
, "t");
3980 IHTMLTxtRange_Release(range
);
3982 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3983 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3985 test_range_collapse(range
, TRUE
);
3986 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3987 test_range_put_text(range
, "word");
3988 test_range_text(body_range
, "wordabc 123\r\nit's text");
3989 test_range_text(range
, NULL
);
3990 test_range_moveend(range
, characterW
, 3, 3);
3991 test_range_text(range
, "abc");
3992 test_range_movestart(range
, characterW
, -2, -2);
3993 test_range_text(range
, "rdabc");
3994 test_range_movestart(range
, characterW
, 3, 3);
3995 test_range_text(range
, "bc");
3996 test_range_movestart(range
, characterW
, 4, 4);
3997 test_range_text(range
, NULL
);
3998 test_range_movestart(range
, characterW
, -3, -3);
3999 test_range_text(range
, "c 1");
4000 test_range_movestart(range
, characterW
, -7, -6);
4001 test_range_text(range
, "wordabc 1");
4002 test_range_movestart(range
, characterW
, 100, 22);
4003 test_range_text(range
, NULL
);
4005 IHTMLTxtRange_Release(range
);
4006 IHTMLTxtRange_Release(body_range
);
4008 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4009 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
4011 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
4012 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
4013 IHTMLSelectionObject_Release(selection
);
4015 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
4016 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
4017 IDispatch_Release(disp_range
);
4019 test_range_text(range
, NULL
);
4020 test_range_moveend(range
, characterW
, 3, 3);
4021 test_range_text(range
, "wor");
4022 test_range_parent(range
, ET_BODY
);
4023 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4024 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4025 test_range_move(range
, characterW
, 3, 3);
4026 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
4027 test_range_moveend(range
, characterW
, -4, -4);
4028 test_range_put_text(range
, "abc def ");
4029 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
4030 test_range_move(range
, wordW
, 1, 1);
4031 test_range_movestart(range
, characterW
, -1, -1);
4032 test_range_text(range
, " ");
4033 test_range_move(range
, wordW
, 1, 1);
4034 test_range_moveend(range
, characterW
, 3, 3);
4035 test_range_text(range
, "def");
4036 test_range_put_text(range
, "xyz");
4037 test_range_moveend(range
, characterW
, 1, 1);
4038 test_range_move(range
, wordW
, 1, 1);
4039 test_range_moveend(range
, characterW
, 2, 2);
4040 test_range_text(range
, "ab");
4042 IHTMLTxtRange_Release(range
);
4045 static void test_txtrange2(IHTMLDocument2
*doc
)
4047 IHTMLTxtRange
*range
;
4049 range
= test_create_body_range(doc
);
4051 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
4052 test_range_move(range
, characterW
, 5, 5);
4053 test_range_moveend(range
, characterW
, 1, 1);
4054 test_range_text(range
, "2");
4055 test_range_move(range
, characterW
, -3, -3);
4056 test_range_moveend(range
, characterW
, 3, 3);
4057 test_range_text(range
, "c\r\n\r\n1");
4058 test_range_collapse(range
, VARIANT_FALSE
);
4059 test_range_moveend(range
, characterW
, 4, 4);
4060 test_range_text(range
, "23");
4061 test_range_moveend(range
, characterW
, 1, 1);
4062 test_range_text(range
, "23\r\n\r\n\r\nd");
4063 test_range_moveend(range
, characterW
, -1, -1);
4064 test_range_text(range
, "23");
4065 test_range_moveend(range
, characterW
, -1, -1);
4066 test_range_text(range
, "23");
4067 test_range_moveend(range
, characterW
, -2, -2);
4068 test_range_text(range
, "2");
4070 IHTMLTxtRange_Release(range
);
4073 static void test_compatmode(IHTMLDocument2
*doc
)
4075 IHTMLDocument5
*doc5
;
4079 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
4080 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
4084 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
4085 IHTMLDocument5_Release(doc5
);
4086 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
4087 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
4088 SysFreeString(mode
);
4091 static void test_location(IHTMLDocument2
*doc
)
4093 IHTMLLocation
*location
, *location2
;
4094 IHTMLWindow2
*window
;
4099 hres
= IHTMLDocument2_get_location(doc
, &location
);
4100 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
4102 hres
= IHTMLDocument2_get_location(doc
, &location2
);
4103 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
4105 ok(location
== location2
, "location != location2\n");
4106 IHTMLLocation_Release(location2
);
4108 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
4109 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
4111 hres
= IHTMLWindow2_get_location(window
, &location2
);
4112 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
4113 ok(location
== location2
, "location != location2\n");
4114 IHTMLLocation_Release(location2
);
4116 test_ifaces((IUnknown
*)location
, location_iids
);
4117 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
4119 hres
= IHTMLLocation_get_pathname(location
, &str
);
4120 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
4121 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
4124 hres
= IHTMLLocation_get_href(location
, NULL
);
4125 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
4127 hres
= IHTMLLocation_get_href(location
, &str
);
4128 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4129 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
4132 ref
= IHTMLLocation_Release(location
);
4133 ok(!ref
, "location chould be destroyed here\n");
4136 static void test_plugins_col(IHTMLDocument2
*doc
)
4138 IHTMLPluginsCollection
*col
, *col2
;
4139 IHTMLWindow2
*window
;
4145 window
= get_doc_window(doc
);
4146 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
4147 IHTMLWindow2_Release(window
);
4149 hres
= IOmNavigator_get_plugins(nav
, &col
);
4150 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
4152 hres
= IOmNavigator_get_plugins(nav
, &col2
);
4153 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
4154 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
4155 IHTMLPluginsCollection_Release(col2
);
4157 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
4160 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
4161 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4162 ok(!len
, "length = %d\n", len
);
4164 ref
= IHTMLPluginsCollection_Release(col
);
4165 ok(!ref
, "ref=%d\n", ref
);
4167 IOmNavigator_Release(nav
);
4170 static void test_mime_types_col(IOmNavigator
*nav
)
4172 IHTMLMimeTypesCollection
*col
, *col2
;
4177 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
4178 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
4180 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
4181 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
4182 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
4183 IHTMLMimeTypesCollection_Release(col2
);
4185 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
4187 length
= 0xdeadbeef;
4188 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
4189 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4190 ok(!length
, "length = %d\n", length
);
4192 ref
= IHTMLMimeTypesCollection_Release(col
);
4193 ok(!ref
, "ref=%d\n", ref
);
4196 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
4197 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
4199 BSTR str
= (void*)0xdeadbeef;
4200 IHTMLFrameBase
*fbase
;
4203 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
4204 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
4206 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
4207 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
4209 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
4211 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
4214 IHTMLFrameBase_Release(fbase
);
4217 static void test_framebase(IUnknown
*unk
)
4219 IHTMLFrameBase
*fbase
;
4223 /* get/put scrolling */
4224 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
4225 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
4227 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
4228 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
4229 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
4233 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
4234 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
4237 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
4238 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
4239 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
4242 str
= a2bstr("junk");
4243 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
4244 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
4245 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
4248 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
4249 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
4250 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
4253 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
4254 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
4255 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
4258 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
4259 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
4262 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
4263 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
4264 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
4266 IHTMLFrameBase_Release(fbase
);
4269 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
4270 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
4275 if(pLCIDToLocaleName
) {
4276 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
4277 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
4278 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
4280 win_skip("LCIDToLocaleName not available, unable to test language string\n");
4281 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
4285 static void test_navigator(IHTMLDocument2
*doc
)
4287 IHTMLWindow2
*window
;
4288 IOmNavigator
*navigator
, *navigator2
;
4295 static const WCHAR v40
[] = {'4','.','0'};
4297 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
4298 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
4300 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
4301 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
4302 ok(navigator
!= NULL
, "navigator == NULL\n");
4303 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
4305 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
4306 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
4307 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
4309 IHTMLWindow2_Release(window
);
4310 IOmNavigator_Release(navigator2
);
4312 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
4313 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
4314 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
4315 SysFreeString(bstr
);
4318 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
4319 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
4320 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
4321 SysFreeString(bstr
);
4324 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
4325 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
4326 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
4327 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
4328 SysFreeString(bstr
);
4331 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
4332 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
4333 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
4334 SysFreeString(bstr
);
4337 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
4338 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
4339 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
4340 SysFreeString(bstr
);
4343 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
4344 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
4345 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
4346 SysFreeString(bstr
);
4348 if (pGetUserDefaultUILanguage
)
4351 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
4352 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
4353 test_language_string(bstr
, pGetUserDefaultUILanguage());
4354 SysFreeString(bstr
);
4357 win_skip("GetUserDefaultUILanguage not available\n");
4360 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
4361 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
4362 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
4363 SysFreeString(bstr
);
4365 hres
= IOmNavigator_toString(navigator
, NULL
);
4366 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
4369 hres
= IOmNavigator_toString(navigator
, &bstr
);
4370 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
4371 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
4372 SysFreeString(bstr
);
4375 hres
= ObtainUserAgentString(0, buf
, &size
);
4376 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
4379 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
4380 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
4381 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
4382 SysFreeString(bstr
);
4384 if(!strncmp(buf
, "Mozilla/", 8)) {
4386 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
4387 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
4388 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
4389 SysFreeString(bstr
);
4391 skip("nonstandard user agent\n");
4395 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
4396 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
4397 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
4398 SysFreeString(bstr
);
4400 test_mime_types_col(navigator
);
4402 ref
= IOmNavigator_Release(navigator
);
4403 ok(!ref
, "navigator should be destroyed here\n");
4406 static void test_screen(IHTMLWindow2
*window
)
4408 IHTMLScreen
*screen
, *screen2
;
4409 IDispatchEx
*dispex
;
4416 hres
= IHTMLWindow2_get_screen(window
, &screen
);
4417 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
4418 ok(screen
!= NULL
, "screen == NULL\n");
4421 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
4422 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
4423 ok(screen2
!= NULL
, "screen == NULL\n");
4424 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
4425 IHTMLScreen_Release(screen2
);
4427 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
4428 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
4429 if(SUCCEEDED(hres
)) {
4430 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
4431 IDispatchEx_Release(dispex
);
4434 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
4436 exl
= GetDeviceCaps(hdc
, HORZRES
);
4438 hres
= IHTMLScreen_get_width(screen
, &l
);
4439 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4440 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
4442 exl
= GetDeviceCaps(hdc
, VERTRES
);
4444 hres
= IHTMLScreen_get_height(screen
, &l
);
4445 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4446 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
4448 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
4450 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
4451 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4452 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
4456 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
4459 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
4460 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
4461 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
4464 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
4465 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
4466 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
4468 IHTMLScreen_Release(screen
);
4471 static void test_default_selection(IHTMLDocument2
*doc
)
4473 IHTMLSelectionObject
*selection
;
4474 IHTMLTxtRange
*range
;
4479 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4480 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
4482 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
4483 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4484 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
4487 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
4488 IHTMLSelectionObject_Release(selection
);
4489 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
4491 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
4492 IDispatch_Release(disp
);
4493 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
4495 test_range_text(range
, NULL
);
4496 IHTMLTxtRange_Release(range
);
4499 static void test_doc_elem(IHTMLDocument2
*doc
)
4501 IHTMLDocument2
*doc_node
, *owner_doc
;
4503 IHTMLDocument3
*doc3
;
4506 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4507 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
4509 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
4510 IHTMLDocument3_Release(doc3
);
4511 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
4513 test_node_name((IUnknown
*)elem
, "HTML");
4514 test_elem_tag((IUnknown
*)elem
, "HTML");
4516 doc_node
= get_doc_node(doc
);
4517 owner_doc
= get_owner_doc((IUnknown
*)elem
);
4518 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
4519 IHTMLDocument2_Release(owner_doc
);
4521 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
4522 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
4523 IHTMLDocument2_Release(doc_node
);
4525 test_elem_client_rect((IUnknown
*)elem
);
4527 IHTMLElement_Release(elem
);
4530 static void test_default_body(IHTMLBodyElement
*body
)
4537 bstr
= (void*)0xdeadbeef;
4538 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
4539 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
4540 ok(bstr
== NULL
, "bstr != NULL\n");
4542 l
= elem_get_scroll_height((IUnknown
*)body
);
4543 ok(l
!= -1, "scrollHeight == -1\n");
4544 l
= elem_get_scroll_width((IUnknown
*)body
);
4545 ok(l
!= -1, "scrollWidth == -1\n");
4546 l
= elem_get_scroll_top((IUnknown
*)body
);
4547 ok(!l
, "scrollTop = %d\n", l
);
4548 elem_get_scroll_left((IUnknown
*)body
);
4550 /* get_text tests */
4551 hres
= IHTMLBodyElement_get_text(body
, &v
);
4552 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4553 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4554 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
4556 /* get_text - Invalid Text */
4558 V_BSTR(&v
) = a2bstr("Invalid");
4559 hres
= IHTMLBodyElement_put_text(body
, v
);
4560 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4564 hres
= IHTMLBodyElement_get_text(body
, &v
);
4565 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4566 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4567 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
4570 /* get_text - Valid Text */
4572 V_BSTR(&v
) = a2bstr("#FF0000");
4573 hres
= IHTMLBodyElement_put_text(body
, v
);
4574 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4578 hres
= IHTMLBodyElement_get_text(body
, &v
);
4579 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4580 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4581 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
4585 static void test_body_funs(IHTMLBodyElement
*body
)
4587 VARIANT vbg
, vDefaultbg
;
4590 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
4591 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4592 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
4593 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
4595 V_VT(&vbg
) = VT_BSTR
;
4596 V_BSTR(&vbg
) = a2bstr("red");
4597 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
4598 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4601 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
4602 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4603 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
4604 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
4607 /* Restore Originial */
4608 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
4609 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4610 VariantClear(&vDefaultbg
);
4613 static void test_history(IHTMLWindow2
*window
)
4615 IOmHistory
*history
, *history2
;
4619 hres
= IHTMLWindow2_get_history(window
, &history
);
4620 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
4621 ok(history
!= NULL
, "history = NULL\n");
4623 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
4626 hres
= IHTMLWindow2_get_history(window
, &history2
);
4627 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
4628 ok(history2
!= NULL
, "history2 = NULL\n");
4629 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
4631 IOmHistory_Release(history2
);
4632 IOmHistory_Release(history
);
4635 static void test_window(IHTMLDocument2
*doc
)
4637 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
4638 IHTMLDocument2
*doc2
= NULL
;
4645 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
4646 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
4647 test_ifaces((IUnknown
*)window
, window_iids
);
4648 hres
= IDispatch_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
4650 IUnknown_Release(unk
);
4652 win_skip("IID_ITravelLogClient not supported\n");
4654 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
4656 hres
= IHTMLWindow2_get_document(window
, &doc2
);
4657 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4658 ok(doc2
!= NULL
, "doc2 == NULL\n");
4660 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
4661 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
4662 test_class_info((IUnknown
*)doc2
);
4664 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
4665 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
4666 test_class_info((IUnknown
*)doc
);
4668 unk
= (void*)0xdeadbeef;
4669 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
4670 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
4671 ok(!unk
, "unk = %p\n", unk
);
4673 IHTMLDocument_Release(doc2
);
4675 hres
= IHTMLWindow2_get_window(window
, &window2
);
4676 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
4677 ok(window2
!= NULL
, "window2 == NULL\n");
4679 hres
= IHTMLWindow2_get_self(window
, &self
);
4680 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
4681 ok(window2
!= NULL
, "self == NULL\n");
4683 ok(self
== window2
, "self != window2\n");
4685 IHTMLWindow2_Release(window2
);
4688 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
4689 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
4690 ok(disp
== (void*)window
, "disp != window\n");
4691 IDispatch_Release(disp
);
4693 hres
= IHTMLWindow2_toString(window
, NULL
);
4694 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
4697 hres
= IHTMLWindow2_toString(window
, &str
);
4698 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
4699 ok(!strcmp_wa(str
, "[object]") ||
4700 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
4703 V_VT(&v
) = VT_ERROR
;
4704 hres
= IHTMLWindow2_get_opener(window
, &v
);
4705 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
4706 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
4709 hres
= IHTMLWindow2_get_parent(window
, &parent
);
4710 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
4711 ok(parent
!= NULL
, "parent == NULL\n");
4712 ok(parent
== self
, "parent != window\n");
4713 IHTMLWindow2_Release(parent
);
4714 IHTMLWindow2_Release(self
);
4716 test_window_name(window
, NULL
);
4717 set_window_name(window
, "test");
4718 test_window_length(window
, 0);
4719 test_screen(window
);
4720 test_window_status(window
);
4721 set_window_status(window
, "Test!");
4722 test_history(window
);
4724 IHTMLWindow2_Release(window
);
4727 static void test_defaults(IHTMLDocument2
*doc
)
4729 IHTMLStyleSheetsCollection
*stylesheetcol
;
4730 IHTMLCurrentStyle
*cstyle
;
4731 IHTMLBodyElement
*body
;
4732 IHTMLElement2
*elem2
;
4737 IHTMLElementCollection
*collection
;
4739 elem
= doc_get_body(doc
);
4741 hres
= IHTMLDocument2_get_images(doc
, NULL
);
4742 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4744 hres
= IHTMLDocument2_get_images(doc
, &collection
);
4745 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
4748 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4749 IHTMLElementCollection_Release(collection
);
4752 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
4753 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4755 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
4756 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
4759 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4760 IHTMLElementCollection_Release(collection
);
4763 hres
= IHTMLDocument2_get_links(doc
, NULL
);
4764 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4766 hres
= IHTMLDocument2_get_links(doc
, &collection
);
4767 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
4770 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4771 IHTMLElementCollection_Release(collection
);
4774 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
4775 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4777 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
4778 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
4781 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4782 IHTMLElementCollection_Release(collection
);
4785 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
4786 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4788 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
4789 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
4792 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4793 IHTMLElementCollection_Release(collection
);
4796 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
4797 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
4798 test_default_body(body
);
4799 test_body_funs(body
);
4800 IHTMLBodyElement_Release(body
);
4802 hres
= IHTMLElement_get_style(elem
, &style
);
4803 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
4805 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
4806 test_ifaces((IUnknown
*)style
, style_iids
);
4807 IHTMLStyle_Release(style
);
4810 test_compatmode(doc
);
4812 test_navigator(doc
);
4813 test_plugins_col(doc
);
4815 elem2
= get_elem2_iface((IUnknown
*)elem
);
4816 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
4817 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
4818 if(SUCCEEDED(hres
)) {
4821 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
4822 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
4824 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
4826 IUnknown_Release(unk
);
4829 /*IE6 doesn't have interface */
4830 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
4833 IHTMLCurrentStyle_Release(cstyle
);
4835 IHTMLElement2_Release(elem2
);
4837 IHTMLElement_Release(elem
);
4839 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
4840 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
4843 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
4844 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4845 ok(l
== 0, "length = %d\n", l
);
4847 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
4849 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
4850 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
4852 test_default_selection(doc
);
4853 test_doc_title(doc
, "");
4856 static void test_tr_elem(IHTMLElement
*elem
)
4858 IHTMLElementCollection
*col
;
4862 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
4864 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
4865 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
4870 hres
= IHTMLTableRow_get_cells(row
, &col
);
4871 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
4872 ok(col
!= NULL
, "get_cells returned NULL\n");
4874 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
4875 IHTMLElementCollection_Release(col
);
4877 IHTMLTable_Release(row
);
4880 static void test_table_elem(IHTMLElement
*elem
)
4882 IHTMLElementCollection
*col
;
4887 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
4888 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
4890 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
4891 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
4896 hres
= IHTMLTable_get_rows(table
, &col
);
4897 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
4898 ok(col
!= NULL
, "get_ros returned NULL\n");
4900 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
4901 IHTMLElementCollection_Release(col
);
4903 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
4905 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
4906 test_elem_tag((IUnknown
*)node
, "TABLE");
4907 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
4908 IHTMLDOMNode_Release(node
);
4910 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
4911 test_elem_tag((IUnknown
*)node
, "TABLE");
4912 test_elem_all((IUnknown
*)node
, NULL
, 0);
4913 IHTMLDOMNode_Release(node
);
4915 IHTMLTable_Release(table
);
4918 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
4927 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
4928 SafeArrayAccessData(sa
, (void**)&var
);
4929 V_VT(var
) = VT_BSTR
;
4930 V_BSTR(var
) = a2bstr(text
);
4931 SafeArrayUnaccessData(sa
);
4934 hres
= IHTMLDocument2_writeln(doc
, sa
);
4936 hres
= IHTMLDocument2_write(doc
, sa
);
4937 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
4939 SafeArrayDestroy(sa
);
4942 static void doc_complex_write(IHTMLDocument2
*doc
)
4944 SAFEARRAYBOUND dim
= {5, 0};
4949 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
4950 SafeArrayAccessData(sa
, (void**)&args
);
4952 V_VT(args
) = VT_BSTR
;
4953 V_BSTR(args
) = a2bstr("<body i4val=\"");
4954 V_VT(args
+1) = VT_I4
;
4956 V_VT(args
+2) = VT_BSTR
;
4957 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
4958 V_VT(args
+3) = VT_R8
;
4959 V_R8(args
+3) = 3.14;
4960 V_VT(args
+4) = VT_BSTR
;
4961 V_BSTR(args
+4) = a2bstr("\">");
4962 SafeArrayUnaccessData(sa
);
4964 hres
= IHTMLDocument2_write(doc
, sa
);
4965 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
4967 SafeArrayDestroy(sa
);
4970 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
4972 IHTMLDocument2
*window_doc
, *elem_doc
;
4973 IHTMLFrameElement3
*frame_elem3
;
4974 IHTMLWindow2
*content_window
;
4977 content_window
= get_frame_content_window(frame_elem
);
4978 window_doc
= get_window_doc(content_window
);
4979 IHTMLWindow2_Release(content_window
);
4981 elem_doc
= get_elem_doc(frame_elem
);
4982 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
4985 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
4986 if(SUCCEEDED(hres
)) {
4987 IDispatch
*disp
= NULL
;
4989 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
4990 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
4991 ok(disp
!= NULL
, "contentDocument == NULL\n");
4992 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
4994 IDispatch_Release(disp
);
4995 IHTMLFrameElement3_Release(frame_elem3
);
4997 win_skip("IHTMLFrameElement3 not supported\n");
5001 IHTMLDocument2_Release(elem_doc
);
5002 IHTMLDocument2_Release(window_doc
);
5005 static void test_iframe_elem(IHTMLElement
*elem
)
5007 IHTMLDocument2
*content_doc
, *owner_doc
;
5008 IHTMLElementCollection
*col
;
5009 IHTMLWindow2
*content_window
;
5016 static const elem_type_t all_types
[] = {
5024 test_frame_doc((IUnknown
*)elem
, TRUE
);
5025 test_framebase((IUnknown
*)elem
);
5027 content_window
= get_frame_content_window((IUnknown
*)elem
);
5028 test_window_length(content_window
, 0);
5030 content_doc
= get_window_doc(content_window
);
5031 IHTMLWindow2_Release(content_window
);
5033 str
= a2bstr("text/html");
5034 V_VT(&errv
) = VT_ERROR
;
5036 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5038 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5039 ok(disp
!= NULL
, "disp == NULL\n");
5040 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5041 IDispatch_Release(disp
);
5043 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
5044 doc_complex_write(content_doc
);
5045 doc_write(content_doc
, TRUE
, "<br />");
5046 doc_write(content_doc
, TRUE
, "</html>");
5048 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5049 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5050 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5051 IHTMLElementCollection_Release(col
);
5053 body
= doc_get_body(content_doc
);
5054 test_elem_attr(body
, "i4val", "4");
5055 test_elem_attr(body
, "r8val", "3.14");
5056 IHTMLElement_Release(body
);
5058 hres
= IHTMLDocument2_close(content_doc
);
5059 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5061 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5062 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5064 IHTMLDocument2_Release(content_doc
);
5067 static void test_stylesheet(IDispatch
*disp
)
5069 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5070 IHTMLStyleSheet
*stylesheet
;
5073 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5074 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5076 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5077 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5078 ok(col
!= NULL
, "col == NULL\n");
5080 IHTMLStyleSheetRulesCollection_Release(col
);
5081 IHTMLStyleSheet_Release(stylesheet
);
5084 static void test_stylesheets(IHTMLDocument2
*doc
)
5086 IHTMLStyleSheetsCollection
*col
= NULL
;
5091 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5092 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5093 ok(col
!= NULL
, "col == NULL\n");
5095 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
5097 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5098 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5099 ok(len
== 1, "len=%d\n", len
);
5105 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5106 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5107 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5108 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5109 test_stylesheet(V_DISPATCH(&res
));
5116 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5117 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5118 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5119 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5122 IHTMLStyleSheetsCollection_Release(col
);
5125 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
5127 IDispatchEx
*dispex
;
5129 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
5137 static const WCHAR w0
[] = {'0',0};
5138 static const WCHAR w100
[] = {'1','0','0',0};
5140 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
5141 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
5143 bstr
= SysAllocString(w0
);
5144 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5145 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5146 SysFreeString(bstr
);
5149 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
5150 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
5151 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
5152 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
5153 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
5154 type
= get_node_type((IUnknown
*)node
);
5155 ok(type
== 3, "type=%d\n", type
);
5156 IHTMLDOMNode_Release(node
);
5159 bstr
= SysAllocString(w100
);
5160 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5161 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
5162 SysFreeString(bstr
);
5164 IDispatchEx_Release(dispex
);
5169 static void test_elems(IHTMLDocument2
*doc
)
5171 IHTMLElementCollection
*col
;
5172 IHTMLDOMChildrenCollection
*child_col
;
5173 IHTMLElement
*elem
, *elem2
, *elem3
;
5174 IHTMLDOMNode
*node
, *node2
;
5175 IHTMLWindow2
*window
;
5179 IHTMLElementCollection
*collection
;
5180 IHTMLDocument3
*doc3
;
5183 static const elem_type_t all_types
[] = {
5213 static const elem_type_t item_types
[] = {
5219 hres
= IHTMLDocument2_get_all(doc
, &col
);
5220 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5221 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5222 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
5223 IHTMLElementCollection_Release(col
);
5225 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5226 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5229 static const elem_type_t images_types
[] = {ET_IMG
};
5230 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5232 IHTMLElementCollection_Release(collection
);
5235 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5236 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5239 static const elem_type_t images_types
[] = {ET_A
};
5240 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5242 IHTMLElementCollection_Release(collection
);
5245 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5246 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5249 static const elem_type_t anchor_types
[] = {ET_A
};
5250 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
5252 IHTMLElementCollection_Release(collection
);
5255 test_plugins_col(doc
);
5257 elem
= get_doc_elem(doc
);
5258 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
5259 IHTMLElement_Release(elem
);
5261 get_elem_by_id(doc
, "xxx", FALSE
);
5262 elem
= get_doc_elem_by_id(doc
, "xxx");
5263 ok(!elem
, "elem != NULL\n");
5265 elem
= get_doc_elem_by_id(doc
, "s");
5266 ok(elem
!= NULL
, "elem == NULL\n");
5268 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
5269 test_elem_attr(elem
, "xxx", NULL
);
5270 test_elem_attr(elem
, "id", "s");
5271 test_elem_class((IUnknown
*)elem
, NULL
);
5272 test_elem_set_class((IUnknown
*)elem
, "cl");
5273 test_elem_set_class((IUnknown
*)elem
, NULL
);
5274 test_elem_tabindex((IUnknown
*)elem
, 0);
5275 test_elem_set_tabindex((IUnknown
*)elem
, 1);
5276 test_elem_filters((IUnknown
*)elem
);
5278 node
= test_node_get_parent((IUnknown
*)elem
);
5279 ok(node
!= NULL
, "node == NULL\n");
5280 test_node_name((IUnknown
*)node
, "BODY");
5281 node2
= test_node_get_parent((IUnknown
*)node
);
5282 IHTMLDOMNode_Release(node
);
5283 ok(node2
!= NULL
, "node == NULL\n");
5284 test_node_name((IUnknown
*)node2
, "HTML");
5285 node
= test_node_get_parent((IUnknown
*)node2
);
5286 IHTMLDOMNode_Release(node2
);
5287 ok(node
!= NULL
, "node == NULL\n");
5290 test_node_name((IUnknown
*)node
, "#document");
5291 type
= get_node_type((IUnknown
*)node
);
5292 ok(type
== 9, "type=%d, expected 9\n", type
);
5293 node2
= test_node_get_parent((IUnknown
*)node
);
5294 IHTMLDOMNode_Release(node
);
5295 ok(node2
== NULL
, "node != NULL\n");
5298 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5299 ok(elem2
!= NULL
, "elem2 == NULL\n");
5300 test_node_name((IUnknown
*)elem2
, "BODY");
5301 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
5302 IHTMLElement_Release(elem2
);
5303 ok(elem3
!= NULL
, "elem3 == NULL\n");
5304 test_node_name((IUnknown
*)elem3
, "HTML");
5305 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
5306 IHTMLElement_Release(elem3
);
5307 ok(elem2
== NULL
, "elem2 != NULL\n");
5309 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
5310 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
5311 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
5313 test_elem_innertext(elem
, "opt1opt2");
5315 IHTMLElement_Release(elem
);
5318 elem
= get_elem_by_id(doc
, "s", TRUE
);
5320 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
5321 IHTMLDocument2
*doc_node
, *elem_doc
;
5323 test_select_elem(select
);
5325 test_elem_title((IUnknown
*)select
, NULL
);
5326 test_elem_set_title((IUnknown
*)select
, "Title");
5327 test_elem_title((IUnknown
*)select
, "Title");
5328 test_elem_offset((IUnknown
*)select
, "BODY");
5329 test_elem_bounding_client_rect((IUnknown
*)select
);
5331 node
= get_first_child((IUnknown
*)select
);
5332 ok(node
!= NULL
, "node == NULL\n");
5334 test_elem_type((IUnknown
*)node
, ET_OPTION
);
5335 IHTMLDOMNode_Release(node
);
5338 type
= get_node_type((IUnknown
*)select
);
5339 ok(type
== 1, "type=%d\n", type
);
5341 IHTMLSelectElement_Release(select
);
5343 elem_doc
= get_elem_doc((IUnknown
*)elem
);
5345 doc_node
= get_doc_node(doc
);
5346 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
5347 IHTMLDocument2_Release(doc_node
);
5348 IHTMLDocument2_Release(elem_doc
);
5350 IHTMLElement_Release(elem
);
5353 elem
= get_elem_by_id(doc
, "sc", TRUE
);
5355 IHTMLScriptElement
*script
;
5358 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
5359 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
5365 hres
= IHTMLScriptElement_put_type (script
, NULL
);
5366 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5367 hres
= IHTMLScriptElement_get_type(script
, &type
);
5368 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5369 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
5371 hres
= IHTMLScriptElement_put_type (script
, a2bstr ("text/javascript"));
5372 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5373 hres
= IHTMLScriptElement_get_type(script
, &type
);
5374 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5375 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
5377 SysFreeString(type
);
5380 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
5381 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5383 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
5384 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
5385 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
5387 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
5388 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5390 str
= (BSTR
)0xdeadbeef;
5391 hres
= IHTMLScriptElement_get_src(script
, &str
);
5392 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
5393 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
5396 IHTMLScriptElement_Release(script
);
5399 elem
= get_elem_by_id(doc
, "in", TRUE
);
5401 IHTMLInputElement
*input
;
5403 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
5404 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
5406 test_elem_id((IUnknown
*)elem
, "in");
5407 test_elem_put_id((IUnknown
*)elem
, "newin");
5408 test_input_get_disabled(input
, VARIANT_FALSE
);
5409 test_input_set_disabled(input
, VARIANT_TRUE
);
5410 test_input_set_disabled(input
, VARIANT_FALSE
);
5411 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
5412 test_input_get_disabled(input
, VARIANT_TRUE
);
5413 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
5414 test_input_get_disabled(input
, VARIANT_FALSE
);
5415 test_elem_client_size((IUnknown
*)elem
);
5416 test_input_type(input
, "text");
5418 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5419 test_node_put_value_str((IUnknown
*)elem
, "test");
5420 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5421 test_input_value((IUnknown
*)elem
, NULL
);
5422 test_input_put_value((IUnknown
*)elem
, "test");
5423 test_elem_class((IUnknown
*)elem
, "testclass");
5424 test_elem_tabindex((IUnknown
*)elem
, 2);
5425 test_elem_set_tabindex((IUnknown
*)elem
, 3);
5426 test_elem_title((IUnknown
*)elem
, "test title");
5428 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
5429 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
5430 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
5432 test_input_get_checked(input
, VARIANT_FALSE
);
5433 test_input_set_checked(input
, VARIANT_TRUE
);
5434 test_input_set_checked(input
, VARIANT_FALSE
);
5436 test_input_maxlength(input
, 0x7fffffff);
5437 test_input_set_maxlength(input
, 30);
5439 test_input_name(input
, NULL
);
5440 test_input_set_name(input
, "test");
5442 test_input_src(input
, NULL
);
5443 test_input_set_src(input
, "about:blank");
5445 IHTMLInputElement_Release(input
);
5446 IHTMLElement_Release(elem
);
5449 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5451 test_img_src((IUnknown
*)elem
, "", NULL
);
5452 test_img_set_src((IUnknown
*)elem
, "about:blank");
5453 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
5454 test_img_alt((IUnknown
*)elem
, NULL
);
5455 test_img_set_alt((IUnknown
*)elem
, "alt test");
5456 test_img_name((IUnknown
*)elem
, "WineImg");
5457 IHTMLElement_Release(elem
);
5460 elem
= get_elem_by_id(doc
, "attr", TRUE
);
5462 test_dynamic_properties(elem
);
5463 test_attr_collection(elem
);
5464 IHTMLElement_Release(elem
);
5467 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
5469 test_style_media((IUnknown
*)elem
, NULL
);
5470 test_style_put_media((IUnknown
*)elem
, "screen");
5471 test_style_type((IUnknown
*)elem
, NULL
);
5472 test_style_put_type((IUnknown
*)elem
, "text/css");
5473 IHTMLElement_Release(elem
);
5476 elem
= get_doc_elem_by_id(doc
, "tbl");
5477 ok(elem
!= NULL
, "elem == NULL\n");
5479 test_table_elem(elem
);
5480 IHTMLElement_Release(elem
);
5483 elem
= get_doc_elem_by_id(doc
, "row2");
5484 ok(elem
!= NULL
, "elem == NULL\n");
5487 IHTMLElement_Release(elem
);
5490 elem
= get_doc_elem_by_id(doc
, "ifr");
5491 ok(elem
!= NULL
, "elem == NULL\n");
5493 test_iframe_elem(elem
);
5494 IHTMLElement_Release(elem
);
5497 elem
= get_doc_elem_by_id(doc
, "objid");
5498 ok(elem
!= NULL
, "elem == NULL\n");
5500 test_object_vspace((IUnknown
*)elem
, 100);
5501 IHTMLElement_Release(elem
);
5504 elem
= get_elem_by_id(doc
, "a", TRUE
);
5506 test_anchor_href((IUnknown
*)elem
, "http://test/");
5508 /* Change the href */
5509 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
5510 test_anchor_href((IUnknown
*)elem
, "http://test1/");
5512 /* Restore the href */
5513 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
5514 test_anchor_href((IUnknown
*)elem
, "http://test/");
5517 test_anchor_get_target((IUnknown
*)elem
, NULL
);
5519 /* Change the target */
5520 test_anchor_put_target((IUnknown
*)elem
, "wine");
5521 test_anchor_get_target((IUnknown
*)elem
, "wine");
5523 /* Restore the target */
5524 test_anchor_put_target((IUnknown
*)elem
, NULL
);
5525 test_anchor_get_target((IUnknown
*)elem
, NULL
);
5527 test_anchor_name((IUnknown
*)elem
, "x");
5528 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
5529 test_anchor_put_name((IUnknown
*)elem
, NULL
);
5530 test_anchor_put_name((IUnknown
*)elem
, "x");
5532 IHTMLElement_Release(elem
);
5535 elem
= get_doc_elem_by_id(doc
, "metaid");
5537 test_meta_name((IUnknown
*)elem
, "meta name");
5538 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
5539 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
5540 IHTMLElement_Release(elem
);
5543 elem
= doc_get_body(doc
);
5545 node
= get_first_child((IUnknown
*)elem
);
5546 ok(node
!= NULL
, "node == NULL\n");
5548 test_ifaces((IUnknown
*)node
, text_iids
);
5549 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5551 node2
= get_first_child((IUnknown
*)node
);
5552 ok(!node2
, "node2 != NULL\n");
5554 type
= get_node_type((IUnknown
*)node
);
5555 ok(type
== 3, "type=%d\n", type
);
5557 test_node_get_value_str((IUnknown
*)node
, "text test");
5558 test_node_put_value_str((IUnknown
*)elem
, "test text");
5559 test_node_get_value_str((IUnknown
*)node
, "text test");
5561 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
5562 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
5563 ok(!disp
, "disp != NULL\n");
5565 IHTMLDOMNode_Release(node
);
5568 child_col
= get_child_nodes((IUnknown
*)elem
);
5569 ok(child_col
!= NULL
, "child_coll == NULL\n");
5573 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
5575 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
5576 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5577 ok(length
, "length=0\n");
5580 node
= get_child_item(child_col
, 0);
5581 ok(node
!= NULL
, "node == NULL\n");
5585 type
= get_node_type((IUnknown
*)node
);
5586 ok(type
== 3, "type=%d\n", type
);
5587 node2
= node_get_next((IUnknown
*)node
);
5589 prev
= node_get_prev((IUnknown
*)node2
);
5590 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
5591 IHTMLDOMNode_Release(prev
);
5593 IHTMLDOMNode_Release(node
);
5596 node
= get_child_item(child_col
, 1);
5597 ok(node
!= NULL
, "node == NULL\n");
5599 type
= get_node_type((IUnknown
*)node
);
5600 ok(type
== 8, "type=%d\n", type
);
5602 test_elem_id((IUnknown
*)node
, NULL
);
5603 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
5604 IHTMLDOMNode_Release(node2
);
5605 IHTMLDOMNode_Release(node
);
5608 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
5609 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5611 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
5612 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5614 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
5615 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5617 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
5618 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5620 test_child_col_disp(child_col
);
5622 IHTMLDOMChildrenCollection_Release(child_col
);
5625 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5626 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
5627 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5629 IHTMLElement_Release(elem
);
5631 elem
= get_doc_elem_by_id(doc
, "frm");
5632 ok(elem
!= NULL
, "elem == NULL\n");
5634 test_form_length((IUnknown
*)elem
, 0);
5635 test_form_elements((IUnknown
*)elem
);
5636 IHTMLElement_Release(elem
);
5639 test_stylesheets(doc
);
5640 test_create_option_elem(doc
);
5641 test_create_img_elem(doc
);
5643 elem
= get_doc_elem_by_id(doc
, "tbl");
5644 ok(elem
!= NULL
, "elem = NULL\n");
5645 test_elem_set_innertext(elem
, "inner text");
5646 IHTMLElement_Release(elem
);
5648 test_doc_title(doc
, "test");
5649 test_doc_set_title(doc
, "test title");
5650 test_doc_title(doc
, "test title");
5653 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5654 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5657 IDispatchEx
*dispex
;
5658 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
5659 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
5663 BSTR str
= a2bstr("Testing");
5664 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
5665 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5666 ok(pid
!= -1, "pid == -1\n");
5668 IDispatchEx_Release(dispex
);
5671 IDispatch_Release(disp
);
5673 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5674 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5676 str
= a2bstr("img");
5677 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
5678 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
5682 static const elem_type_t img_types
[] = { ET_IMG
};
5684 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
5685 IHTMLElementCollection_Release(col
);
5688 elem
= get_doc_elem_by_id(doc
, "y");
5689 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
5690 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
5691 test_elem_set_innerhtml((IUnknown
*)elem
, "");
5692 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
5693 node
= node_get_next((IUnknown
*)elem
);
5694 ok(!node
, "node = %p\n", node
);
5696 elem2
= get_doc_elem_by_id(doc
, "x");
5697 test_elem_tag((IUnknown
*)elem2
, "A");
5698 node
= node_get_next((IUnknown
*)elem2
);
5699 IHTMLDOMNode_Release(node
);
5700 IHTMLElement_Release(elem2
);
5701 IHTMLElement_Release(elem
);
5703 IHTMLDocument3_Release(doc3
);
5705 elem
= get_elem_by_id(doc
, "s", TRUE
);
5707 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
5709 test_select_put_length((IUnknown
*)elem
, 3);
5710 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
5711 test_select_put_length((IUnknown
*)elem
, 1);
5712 test_elem_all((IUnknown
*)elem
, select_types
, 1);
5713 IHTMLElement_Release(elem
);
5716 window
= get_doc_window(doc
);
5717 test_window_name(window
, NULL
);
5718 set_window_name(window
, "test name");
5719 test_window_length(window
, 1);
5720 IHTMLWindow2_Release(window
);
5723 static void test_attr(IHTMLElement
*elem
)
5725 IHTMLDOMAttribute
*attr
, *attr2
;
5728 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
5730 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
5732 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
5733 test_ifaces((IUnknown
*)attr
, attr_iids
);
5734 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
5735 test_attr_specified(attr
, VARIANT_TRUE
);
5737 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
5738 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
5739 IHTMLDOMAttribute_Release(attr2
);
5741 get_attr_node_value(attr
, &v
, VT_BSTR
);
5742 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5745 IHTMLDOMAttribute_Release(attr
);
5747 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
5748 get_attr_node_value(attr
, &v
, VT_BSTR
);
5749 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5751 test_attr_specified(attr
, VARIANT_TRUE
);
5752 IHTMLDOMAttribute_Release(attr
);
5756 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
5757 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
5758 get_attr_node_value(attr
, &v
, VT_I4
);
5759 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
5760 test_attr_specified(attr
, VARIANT_TRUE
);
5761 IHTMLDOMAttribute_Release(attr
);
5763 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
5764 test_attr_specified(attr
, VARIANT_FALSE
);
5765 IHTMLDOMAttribute_Release(attr
);
5768 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
5772 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
5773 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
5774 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5776 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5777 IHTMLElement_Release(elem
);
5780 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
5781 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
5782 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5784 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
5785 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
5786 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
5787 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
5788 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5789 IHTMLElement_Release(elem
);
5793 static void test_elems2(IHTMLDocument2
*doc
)
5795 IHTMLElement
*elem
, *elem2
, *div
;
5797 static const elem_type_t outer_types
[] = {
5802 div
= get_doc_elem_by_id(doc
, "divid");
5804 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
5805 elem2
= get_doc_elem_by_id(doc
, "innerid");
5806 ok(elem2
!= NULL
, "elem2 == NULL\n");
5807 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5808 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
5809 IHTMLElement_Release(elem2
);
5811 elem2
= get_doc_elem_by_id(doc
, "aid");
5812 ok(elem2
!= NULL
, "elem2 == NULL\n");
5813 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
5814 test_elem_all((IUnknown
*)div
, outer_types
, 1);
5815 IHTMLElement_Release(elem2
);
5817 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
5818 elem
= get_elem_by_id(doc
, "ta", TRUE
);
5820 test_textarea_value((IUnknown
*)elem
, NULL
);
5821 test_textarea_put_value((IUnknown
*)elem
, "test");
5822 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
5823 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
5824 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
5825 test_textarea_type((IUnknown
*)elem
);
5826 IHTMLElement_Release(elem
);
5829 test_elem_set_innerhtml((IUnknown
*)div
,
5830 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" /></div></textarea>");
5831 elem
= get_elem_by_id(doc
, "form", TRUE
);
5833 test_form_length((IUnknown
*)elem
, 2);
5834 test_form_item(elem
);
5835 test_form_action((IUnknown
*)elem
, NULL
);
5836 test_form_put_action((IUnknown
*)elem
, "about:blank");
5837 test_form_method((IUnknown
*)elem
, "get");
5838 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
5839 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
5840 test_form_method((IUnknown
*)elem
, "post");
5841 test_form_name((IUnknown
*)elem
, NULL
);
5842 test_form_put_name((IUnknown
*)elem
, "Name");
5843 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
5844 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
5845 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
5846 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
5847 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
5848 test_form_elements((IUnknown
*)elem
);
5849 IHTMLElement_Release(elem
);
5853 test_blocked(doc
, div
);
5855 IHTMLElement_Release(div
);
5858 static void test_create_elems(IHTMLDocument2
*doc
)
5860 IHTMLElement
*elem
, *body
, *elem2
;
5861 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
5862 IHTMLDocument5
*doc5
;
5869 static const elem_type_t types1
[] = { ET_TESTG
};
5871 elem
= test_create_elem(doc
, "TEST");
5872 test_elem_tag((IUnknown
*)elem
, "TEST");
5873 type
= get_node_type((IUnknown
*)elem
);
5874 ok(type
== 1, "type=%d\n", type
);
5875 test_ifaces((IUnknown
*)elem
, elem_iids
);
5876 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
5878 body
= doc_get_body(doc
);
5879 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5881 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
5882 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
5883 elem2
= get_elem_iface((IUnknown
*)node
);
5884 IHTMLElement_Release(elem2
);
5886 hres
= IHTMLElement_get_all(body
, &disp
);
5887 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5888 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
5889 IDispatch_Release(disp
);
5891 test_node_remove_child((IUnknown
*)body
, node
);
5893 hres
= IHTMLElement_get_all(body
, &disp
);
5894 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5895 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
5896 IDispatch_Release(disp
);
5897 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5899 IHTMLElement_Release(elem
);
5900 IHTMLDOMNode_Release(node
);
5902 node
= test_create_text(doc
, "test");
5903 test_ifaces((IUnknown
*)node
, text_iids
);
5904 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5905 test_text_length((IUnknown
*)node
, 4);
5907 V_VT(&var
) = VT_NULL
;
5908 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5909 IHTMLDOMNode_Release(node
);
5911 node
= test_create_text(doc
, "insert ");
5913 V_VT(&var
) = VT_DISPATCH
;
5914 V_DISPATCH(&var
) = (IDispatch
*)node2
;
5915 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5916 IHTMLDOMNode_Release(node
);
5917 IHTMLDOMNode_Release(node2
);
5918 IHTMLDOMNode_Release(node3
);
5920 test_elem_innertext(body
, "insert test");
5921 test_elem_innerhtml((IUnknown
*)body
, "insert test");
5923 node
= test_create_text(doc
, " Test");
5924 V_VT(&var
) = VT_DISPATCH
;
5925 V_DISPATCH(&var
) = NULL
;
5926 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5927 test_elem_innertext(body
, "insert test Test");
5928 IHTMLDOMNode_Release(node
);
5930 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
5933 str
= a2bstr("testing");
5934 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
5936 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
5939 type
= get_node_type((IUnknown
*)comment
);
5940 ok(type
== 8, "type=%d, expected 8\n", type
);
5942 test_node_get_value_str((IUnknown
*)comment
, "testing");
5943 test_elem_title((IUnknown
*)comment
, NULL
);
5944 test_elem_set_title((IUnknown
*)comment
, "comment title");
5945 test_elem_title((IUnknown
*)comment
, "comment title");
5946 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
5947 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
5948 test_comment_attrs((IUnknown
*)comment
);
5950 IHTMLDOMNode_Release(comment
);
5953 IHTMLDocument5_Release(doc5
);
5956 IHTMLElement_Release(body
);
5959 static void test_replacechild_elems(IHTMLDocument2
*doc
)
5962 IHTMLDOMNode
*node
, *node2
, *node3
;
5963 IHTMLDOMNode
*nodeBody
, *nodeNew
;
5967 body
= doc_get_body(doc
);
5969 node
= test_create_text(doc
, "insert");
5971 V_VT(&var
) = VT_NULL
;
5972 V_DISPATCH(&var
) = NULL
;
5973 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5974 IHTMLDOMNode_Release(node
);
5976 test_elem_innertext(body
, "insert");
5978 node3
= test_create_text(doc
, "replaced");
5980 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
5982 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
5983 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
5985 test_elem_innertext(body
, "replaced");
5987 IHTMLDOMNode_Release(node2
);
5988 IHTMLDOMNode_Release(node3
);
5989 IHTMLDOMNode_Release(nodeBody
);
5991 IHTMLElement_Release(body
);
5994 static void test_null_write(IHTMLDocument2
*doc
)
5998 doc_write(doc
, FALSE
, NULL
);
5999 doc_write(doc
, TRUE
, NULL
);
6001 hres
= IHTMLDocument2_write(doc
, NULL
);
6003 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
6005 hres
= IHTMLDocument2_writeln(doc
, NULL
);
6007 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
6010 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
6012 IOleCommandTarget
*cmdtrg
;
6015 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
6016 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
6018 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
6019 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
6021 IOleCommandTarget_Release(cmdtrg
);
6024 static void test_indent(IHTMLDocument2
*doc
)
6026 IHTMLElementCollection
*col
;
6027 IHTMLTxtRange
*range
;
6030 static const elem_type_t all_types
[] = {
6039 static const elem_type_t indent_types
[] = {
6050 hres
= IHTMLDocument2_get_all(doc
, &col
);
6051 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6052 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6053 IHTMLElementCollection_Release(col
);
6055 range
= test_create_body_range(doc
);
6056 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
6057 IHTMLTxtRange_Release(range
);
6059 hres
= IHTMLDocument2_get_all(doc
, &col
);
6060 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6061 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
6062 IHTMLElementCollection_Release(col
);
6065 static void test_cond_comment(IHTMLDocument2
*doc
)
6067 IHTMLElementCollection
*col
;
6070 static const elem_type_t all_types
[] = {
6078 hres
= IHTMLDocument2_get_all(doc
, &col
);
6079 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6080 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6081 IHTMLElementCollection_Release(col
);
6084 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6086 IHTMLWindow2
*frame2
, *parent
, *top
;
6087 IHTMLDocument2
*parent_doc
, *top_doc
;
6088 IHTMLWindow4
*frame
;
6089 IHTMLFrameBase
*frame_elem
;
6092 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6093 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6097 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6098 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6099 IHTMLWindow4_Release(frame
);
6103 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6104 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6105 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6106 IHTMLElement_Release(frame_elem
);
6108 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6109 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6113 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6114 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6116 IHTMLWindow2_Release(frame2
);
6120 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6121 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6122 IHTMLWindow2_Release(parent
);
6124 IHTMLWindow2_Release(frame2
);
6128 test_doc_title(parent_doc
, "frameset test");
6129 IHTMLDocument2_Release(parent_doc
);
6132 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6133 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6134 IHTMLWindow2_Release(frame2
);
6138 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6139 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6140 IHTMLWindow2_Release(top
);
6144 test_doc_title(top_doc
, "frameset test");
6145 IHTMLDocument2_Release(top_doc
);
6148 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
6150 VARIANT index_var
, result_var
;
6154 /* test result length */
6155 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6156 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6157 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6159 /* test first frame */
6160 V_VT(&index_var
) = VT_I4
;
6161 V_I4(&index_var
) = 0;
6162 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6163 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6164 if(SUCCEEDED(hres
)) {
6165 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6166 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6168 VariantClear(&result_var
);
6170 /* test second frame */
6171 V_I4(&index_var
) = 1;
6172 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6173 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6174 if(SUCCEEDED(hres
)) {
6175 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6176 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6178 VariantClear(&result_var
);
6180 /* fail on next frame */
6181 V_I4(&index_var
) = 3;
6182 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6183 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6184 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6185 VariantClear(&result_var
);
6187 /* string argument (element id lookup) */
6188 V_VT(&index_var
) = VT_BSTR
;
6189 V_BSTR(&index_var
) = a2bstr(frid
);
6190 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6191 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6192 if(SUCCEEDED(hres
)) {
6193 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6194 test_frame(V_DISPATCH(&result_var
), frid
);
6196 VariantClear(&result_var
);
6197 VariantClear(&index_var
);
6199 /* invalid argument */
6200 V_VT(&index_var
) = VT_BOOL
;
6201 V_BOOL(&index_var
) = VARIANT_TRUE
;
6202 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6203 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6204 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6205 VariantClear(&result_var
);
6208 static void test_frameset(IHTMLDocument2
*doc
)
6210 IHTMLWindow2
*window
;
6211 IHTMLFramesCollection2
*frames
;
6215 window
= get_doc_window(doc
);
6217 /* test using IHTMLFramesCollection object */
6219 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6220 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6224 test_frames_collection(frames
, "fr1");
6225 IHTMLFramesCollection2_Release(frames
);
6227 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
6228 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
6232 test_frames_collection(frames
, "fr1");
6233 IHTMLFramesCollection2_Release(frames
);
6235 /* test using IHTMLWindow2 inheritance */
6236 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
6238 /* getElementById with node name attributes */
6239 elem
= get_doc_elem_by_id(doc
, "nm1");
6240 test_elem_id((IUnknown
*)elem
, "fr1");
6242 test_framebase((IUnknown
*)elem
);
6243 test_framebase_name(elem
, "nm1");
6245 IHTMLElement_Release(elem
);
6247 /* get_name with no name attr */
6248 elem
= get_doc_elem_by_id(doc
, "fr3");
6249 test_framebase_name(elem
, NULL
);
6250 IHTMLElement_Release(elem
);
6252 IHTMLWindow2_Release(window
);
6255 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
6257 IHTMLDocument2
*frag
;
6258 IHTMLDocument3
*doc3
;
6261 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6262 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
6264 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
6265 IHTMLDocument3_Release(doc3
);
6266 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
6267 ok(frag
!= NULL
, "frag == NULL\n");
6272 static void test_docfrag(IHTMLDocument2
*doc
)
6274 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
6275 IHTMLElement
*div
, *body
, *br
;
6276 IHTMLElementCollection
*col
;
6277 IHTMLLocation
*location
;
6280 static const elem_type_t all_types
[] = {
6289 frag
= create_docfrag(doc
);
6291 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
6293 body
= (void*)0xdeadbeef;
6294 hres
= IHTMLDocument2_get_body(frag
, &body
);
6295 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
6296 ok(!body
, "body != NULL\n");
6298 location
= (void*)0xdeadbeef;
6299 hres
= IHTMLDocument2_get_location(frag
, &location
);
6300 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
6301 ok(location
== (void*)0xdeadbeef, "location changed\n");
6303 br
= test_create_elem(doc
, "BR");
6304 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
6305 IHTMLElement_Release(br
);
6307 div
= get_elem_by_id(doc
, "divid", TRUE
);
6308 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
6309 IHTMLElement_Release(div
);
6311 hres
= IHTMLDocument2_get_all(doc
, &col
);
6312 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6313 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6314 IHTMLElementCollection_Release(col
);
6316 div
= test_create_elem(frag
, "div");
6317 owner_doc
= get_owner_doc((IUnknown
*)div
);
6318 doc_node
= get_doc_node(doc
);
6319 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
6320 IHTMLDocument2_Release(doc_node
);
6321 IHTMLDocument2_Release(owner_doc
);
6322 IHTMLElement_Release(div
);
6324 IHTMLDocument2_Release(frag
);
6327 static IHTMLDocument2
*notif_doc
;
6328 static BOOL doc_complete
;
6330 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
6331 REFIID riid
, void**ppv
)
6333 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
6338 ok(0, "unexpected call\n");
6339 return E_NOINTERFACE
;
6342 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
6347 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
6352 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
6354 if(dispID
== DISPID_READYSTATE
){
6358 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
6359 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
6361 if(!strcmp_wa(state
, "complete"))
6362 doc_complete
= TRUE
;
6364 SysFreeString(state
);
6370 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
6372 ok(0, "unexpected call\n");
6376 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
6377 PropertyNotifySink_QueryInterface
,
6378 PropertyNotifySink_AddRef
,
6379 PropertyNotifySink_Release
,
6380 PropertyNotifySink_OnChanged
,
6381 PropertyNotifySink_OnRequestEdit
6384 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
6386 static IHTMLDocument2
*create_doc_with_string(const char *str
)
6388 IPersistStreamInit
*init
;
6390 IHTMLDocument2
*doc
;
6394 notif_doc
= doc
= create_document();
6398 doc_complete
= FALSE
;
6400 mem
= GlobalAlloc(0, len
);
6401 memcpy(mem
, str
, len
);
6402 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
6404 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
6406 IPersistStreamInit_Load(init
, stream
);
6407 IPersistStreamInit_Release(init
);
6408 IStream_Release(stream
);
6413 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
6415 IConnectionPointContainer
*container
;
6416 IConnectionPoint
*cp
;
6420 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
6421 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
6423 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
6424 IConnectionPointContainer_Release(container
);
6425 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
6427 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
6428 IConnectionPoint_Release(cp
);
6429 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
6432 typedef void (*domtest_t
)(IHTMLDocument2
*);
6434 static void run_domtest(const char *str
, domtest_t test
)
6436 IHTMLDocument2
*doc
;
6440 doc
= create_doc_with_string(str
);
6444 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
6446 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
6447 TranslateMessage(&msg
);
6448 DispatchMessage(&msg
);
6453 ref
= IHTMLDocument2_Release(doc
);
6454 ok(!ref
|| broken(ref
== 1), /* Vista */
6460 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
6461 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
6462 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
6466 run_domtest(doc_str1
, test_doc_elem
);
6467 run_domtest(doc_str1
, test_get_set_attr
);
6468 run_domtest(range_test_str
, test_txtrange
);
6469 run_domtest(range_test2_str
, test_txtrange2
);
6470 if (winetest_interactive
|| ! is_ie_hardened()) {
6471 run_domtest(elem_test_str
, test_elems
);
6472 run_domtest(elem_test2_str
, test_elems2
);
6474 skip("IE running in Enhanced Security Configuration\n");
6476 run_domtest(doc_blank
, test_create_elems
);
6477 run_domtest(doc_blank
, test_defaults
);
6478 run_domtest(doc_blank
, test_null_write
);
6479 run_domtest(indent_test_str
, test_indent
);
6480 run_domtest(cond_comment_str
, test_cond_comment
);
6481 run_domtest(frameset_str
, test_frameset
);
6482 run_domtest(emptydiv_str
, test_docfrag
);
6483 run_domtest(doc_blank
, test_replacechild_elems
);