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"
37 static const char doc_blank[] = "<html></html>";
38 static const char doc_str1[] = "<html><body>test</body></html>";
39 static const char range_test_str[] =
40 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
41 static const char range_test2_str[] =
42 "<html><body>abc<hr />123<br /><hr />def</body></html>";
43 static const char elem_test_str[] =
44 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
45 "<body onload=\"Testing()\">text test<!-- a comment -->"
46 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
47 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
48 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
49 "<textarea id=\"X\">text text</textarea>"
50 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
51 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
52 "<test /><object id=\"objid\" vspace=100></object><embed />"
53 "<img id=\"imgid\" name=\"WineImg\"/>"
54 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 "<form id=\"frm\"></form>"
57 static const char elem_test2_str[] =
58 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
59 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
62 static const char indent_test_str[] =
63 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
64 static const char cond_comment_str[] =
65 "<html><head><title>test</title></head><body>"
66 "<!--[if gte IE 4]> <br> <![endif]-->"
68 static const char frameset_str[] =
69 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
70 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
71 "<frame src=\"about:blank\" id=\"fr3\">"
73 static const char emptydiv_str[] =
74 "<html><head><title>emptydiv test</title></head>"
75 "<body><div id=\"divid\"></div></body></html>";
77 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
78 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
79 static WCHAR wordW[] = {'w','o','r','d',0};
113 static const IID * const none_iids[] = {
118 static const IID * const doc_node_iids[] = {
127 &IID_IConnectionPointContainer,
128 &IID_IInternetHostSecurityManager,
131 &IID_IProvideClassInfo,
135 static const IID * const doc_obj_iids[] = {
142 &IID_IConnectionPointContainer,
146 &IID_IProvideClassInfo,
150 #define ELEM_IFACES \
152 &IID_IHTMLDOMNode2, \
154 &IID_IHTMLElement2, \
155 &IID_IHTMLElement3, \
156 &IID_IHTMLElement4, \
159 static const IID * const elem_iids[] = {
161 &IID_IConnectionPointContainer,
165 static const IID * const body_iids[] = {
167 &IID_IHTMLTextContainer,
168 &IID_IHTMLBodyElement,
169 &IID_IConnectionPointContainer,
173 static const IID * const anchor_iids[] = {
175 &IID_IHTMLAnchorElement,
176 &IID_IConnectionPointContainer,
180 static const IID * const input_iids[] = {
182 &IID_IHTMLInputElement,
183 &IID_IHTMLInputTextElement,
184 &IID_IConnectionPointContainer,
188 static const IID * const select_iids[] = {
190 &IID_IHTMLSelectElement,
191 &IID_IConnectionPointContainer,
195 static const IID * const textarea_iids[] = {
197 &IID_IHTMLTextAreaElement,
198 &IID_IConnectionPointContainer,
202 static const IID * const option_iids[] = {
204 &IID_IHTMLOptionElement,
205 &IID_IConnectionPointContainer,
209 static const IID * const table_iids[] = {
212 &IID_IConnectionPointContainer,
216 static const IID * const script_iids[] = {
218 &IID_IHTMLScriptElement,
219 &IID_IConnectionPointContainer,
223 static const IID * const text_iids[] = {
226 &IID_IHTMLDOMTextNode,
230 static const IID * const attr_iids[] = {
231 &IID_IHTMLDOMAttribute,
236 static const IID * const location_iids[] = {
242 static const IID * const window_iids[] = {
247 &IID_IServiceProvider,
251 static const IID * const comment_iids[] = {
253 &IID_IHTMLCommentElement,
254 &IID_IConnectionPointContainer,
258 static const IID * const img_iids[] = {
260 &IID_IHTMLImgElement,
261 &IID_IConnectionPointContainer,
265 static const IID * const tr_iids[] = {
268 &IID_IConnectionPointContainer,
272 static const IID * const td_iids[] = {
274 &IID_IConnectionPointContainer,
278 static const IID * const frame_iids[] = {
281 &IID_IHTMLFrameBase2,
282 &IID_IConnectionPointContainer,
286 static const IID * const head_iids[] = {
288 &IID_IHTMLHeadElement,
289 &IID_IConnectionPointContainer,
293 static const IID * const title_iids[] = {
295 &IID_IHTMLTitleElement,
296 &IID_IConnectionPointContainer,
300 static const IID * const object_iids[] = {
302 &IID_IHTMLObjectElement,
303 /* FIXME: No IConnectionPointContainer */
307 static const IID * const embed_iids[] = {
309 &IID_IHTMLEmbedElement,
310 /* FIXME: No IConnectionPointContainer */
314 static const IID * const iframe_iids[] = {
317 &IID_IHTMLFrameBase2,
318 &IID_IHTMLIFrameElement,
319 &IID_IConnectionPointContainer,
323 static const IID * const form_iids[] = {
325 &IID_IHTMLFormElement,
326 &IID_IConnectionPointContainer,
330 static const IID * const styleelem_iids[] = {
332 &IID_IHTMLStyleElement,
333 &IID_IConnectionPointContainer,
337 static const IID * const generic_iids[] = {
339 &IID_IHTMLGenericElement,
340 &IID_IConnectionPointContainer,
344 static const IID * const style_iids[] = {
355 static const IID * const cstyle_iids[] = {
359 &IID_IHTMLCurrentStyle,
363 static const IID * const img_factory_iids[] = {
367 &IID_IHTMLImageElementFactory,
377 static const elem_type_info_t elem_type_infos[] = {
378 {"", none_iids, NULL},
379 {"HTML", elem_iids, NULL},
380 {"HEAD", head_iids, &DIID_DispHTMLHeadElement},
381 {"TITLE", title_iids, &DIID_DispHTMLTitleElement},
382 {"BODY", body_iids, &DIID_DispHTMLBody},
383 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
384 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
385 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
386 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
387 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
388 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
389 {"BLOCKQUOTE",elem_iids, NULL},
390 {"P", elem_iids, NULL},
391 {"BR", elem_iids, NULL},
392 {"TABLE", table_iids, &DIID_DispHTMLTable},
393 {"TBODY", elem_iids, NULL},
394 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
395 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
396 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
397 {"!", comment_iids, &DIID_DispHTMLCommentElement},
398 {"IMG", img_iids, &DIID_DispHTMLImg},
399 {"TR", tr_iids, &DIID_DispHTMLTableRow},
400 {"TD", td_iids, NULL},
401 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
402 {"FORM", form_iids, &DIID_DispHTMLFormElement},
403 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
404 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
405 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
406 {"DIV", elem_iids, NULL}
409 static const char *dbgstr_guid(REFIID riid)
413 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
414 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
415 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
416 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
421 static int strcmp_wa(LPCWSTR strw, const char *stra)
424 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
425 return lstrcmpA(stra, buf);
428 static BSTR a2bstr(const char *str)
436 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
437 ret = SysAllocStringLen(NULL, len);
438 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
443 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
445 IUnknown *unk1, *unk2;
450 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
451 IUnknown_Release(unk1);
452 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
453 IUnknown_Release(unk2);
458 static IHTMLDocument2 *create_document(void)
461 IHTMLDocument5 *doc5;
464 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
465 &IID_IHTMLDocument2, (void**)&doc);
466 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
470 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
472 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
473 IHTMLDocument2_Release(doc);
477 IHTMLDocument5_Release(doc5);
481 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
482 static IDispatchEx *_get_dispex_iface(unsigned line, IUnknown *unk)
487 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
488 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
492 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
493 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
495 const IID * const *piid;
499 for(piid = iids; *piid; piid++) {
500 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
501 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
503 IUnknown_Release(unk);
507 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
508 static void _test_no_iface(unsigned line, IUnknown *iface, REFIID iid)
513 unk = (void*)0xdeadbeef;
514 hres = IUnknown_QueryInterface(iface, iid, (void**)&unk);
515 ok_(__FILE__,line)(hres == E_NOINTERFACE, "hres = %08x, expected E_NOINTERFACE\n", hres);
516 ok_(__FILE__,line)(!unk, "unk = %p\n", unk);
519 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
520 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
522 IDispatchEx *dispex = _get_dispex_iface(line, unk);
529 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
530 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
531 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
533 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
534 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
536 if(SUCCEEDED(hres)) {
539 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
540 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
542 *iid = type_attr->guid;
546 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
547 ITypeInfo_Release(typeinfo);
550 IDispatchEx_Release(dispex);
554 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
555 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
557 IDispatchEx *dispex = _get_dispex_iface(line, unk);
558 DISPPARAMS dp = {NULL,NULL,0,0};
563 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
564 IDispatchEx_Release(dispex);
565 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
567 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
568 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
572 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
573 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
577 if(_test_get_dispid(line, unk, &iid))
578 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
581 _test_disp_value(line, unk, val);
584 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
585 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
589 if(_test_get_dispid(line, unk, &iid))
590 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
591 "unexpected guid %s\n", dbgstr_guid(&iid));
594 _test_disp_value(line, unk, val);
597 #define test_class_info(u) _test_class_info(__LINE__,u)
598 static void _test_class_info(unsigned line, IUnknown *unk)
600 IProvideClassInfo *classinfo;
605 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo, (void**)&classinfo);
606 ok_(__FILE__,line)(hres == S_OK, "Could not get IProvideClassInfo interface: %08x\n", hres);
610 hres = IProvideClassInfo_GetClassInfo(classinfo, &typeinfo);
611 ok_(__FILE__,line)(hres == S_OK, "Could not get ITypeInfo interface: %08x\n", hres);
614 IProvideClassInfo_Release(classinfo);
618 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
619 ok_(__FILE__,line)(hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
622 ok_(__FILE__,line)(IsEqualGUID(&type_attr->guid, &CLSID_HTMLDocument),
623 "unexpected guid %s\n", dbgstr_guid(&type_attr->guid));
624 ok_(__FILE__,line)(type_attr->typekind == TKIND_COCLASS,
625 "unexpected typekind %d\n", type_attr->typekind);
626 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
629 ITypeInfo_Release(typeinfo);
630 IProvideClassInfo_Release(classinfo);
633 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
634 static void _set_dispex_value(unsigned line, IUnknown *unk, const char *name, VARIANT *val)
636 IDispatchEx *dispex = _get_dispex_iface(line, unk);
637 DISPPARAMS dp = {val, NULL, 1, 0};
644 hres = IDispatchEx_GetDispID(dispex, str, fdexNameEnsure|fdexNameCaseInsensitive, &id);
646 ok_(__FILE__,line)(hres == S_OK, "GetDispID failed: %08x\n", hres);
648 memset(&ei, 0, sizeof(ei));
649 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYPUT, &dp, NULL, &ei, NULL);
650 ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres);
654 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
655 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
660 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
661 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
665 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
666 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
671 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
672 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
676 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
677 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
683 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
687 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
688 static IHTMLElement4 *_get_elem4_iface(unsigned line, IUnknown *unk)
693 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement4, (void**)&elem);
694 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement4: %08x\n", hres);
698 #define get_node_iface(u) _get_node_iface(__LINE__,u)
699 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
704 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
705 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
709 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
710 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
715 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
716 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
720 #define get_img_iface(u) _get_img_iface(__LINE__,u)
721 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
723 IHTMLImgElement *img;
726 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
727 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
731 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
732 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
734 IHTMLAnchorElement *anchor;
737 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
738 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
742 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
743 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
745 IHTMLTextAreaElement *textarea;
748 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
749 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
753 #define get_select_iface(u) _get_select_iface(__LINE__,u)
754 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
756 IHTMLSelectElement *select;
759 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
760 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
764 #define get_form_iface(u) _get_form_iface(__LINE__,u)
765 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
767 IHTMLFormElement *form;
770 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
771 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
775 #define get_text_iface(u) _get_text_iface(__LINE__,u)
776 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
778 IHTMLDOMTextNode *text;
781 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
782 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
786 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
787 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
789 IHTMLCommentElement *comment;
792 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
793 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
797 #define get_object_iface(u) _get_object_iface(__LINE__,u)
798 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
800 IHTMLObjectElement *obj;
803 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
804 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
808 #define get_style_iface(u) _get_style_iface(__LINE__,u)
809 static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
811 IHTMLStyleElement *obj;
814 hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
815 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
819 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
820 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
822 IHTMLDOMNode *node = _get_node_iface(line, unk);
826 hres = IHTMLDOMNode_get_nodeName(node, &name);
827 IHTMLDOMNode_Release(node);
828 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
829 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
834 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
835 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
837 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
838 IDispatch *disp = (void*)0xdeadbeef;
839 IHTMLDocument2 *doc = NULL;
842 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
843 IHTMLDOMNode2_Release(node);
844 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
847 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
848 IDispatch_Release(disp);
849 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
855 #define get_doc_window(d) _get_doc_window(__LINE__,d)
856 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
858 IHTMLWindow2 *window;
862 hres = IHTMLDocument2_get_parentWindow(doc, &window);
863 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
864 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
869 #define clone_node(n,d) _clone_node(__LINE__,n,d)
870 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
872 IHTMLDOMNode *node = _get_node_iface(line, unk);
873 IHTMLDOMNode *ret = NULL;
876 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
877 IHTMLDOMNode_Release(node);
878 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
879 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
885 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
886 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
888 IHTMLElement *elem = _get_elem_iface(line, unk);
892 hres = IHTMLElement_get_tagName(elem, &tag);
893 IHTMLElement_Release(elem);
894 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
895 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
900 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
901 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
903 _test_elem_tag(line, unk, elem_type_infos[type].tag);
904 _test_ifaces(line, unk, elem_type_infos[type].iids);
906 if(elem_type_infos[type].dispiid && type != ET_A)
907 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
910 #define get_node_type(n) _get_node_type(__LINE__,n)
911 static LONG _get_node_type(unsigned line, IUnknown *unk)
913 IHTMLDOMNode *node = _get_node_iface(line, unk);
917 hres = IHTMLDOMNode_get_nodeType(node, &type);
918 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
920 IHTMLDOMNode_Release(node);
925 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
926 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
928 IHTMLDOMNode *node = _get_node_iface(line, unk);
929 IHTMLDOMChildrenCollection *col = NULL;
933 hres = IHTMLDOMNode_get_childNodes(node, &disp);
934 IHTMLDOMNode_Release(node);
935 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
939 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
940 IDispatch_Release(disp);
941 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
946 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
947 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
949 IHTMLDOMNode *node = NULL;
953 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
954 ok(hres == S_OK, "item failed: %08x\n", hres);
956 node = _get_node_iface(line, (IUnknown*)disp);
957 IDispatch_Release(disp);
962 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
963 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
972 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
974 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
977 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
978 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
980 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
983 VariantClear(&value);
986 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
987 static void _test_elem_offset(unsigned line, IUnknown *unk, const char *parent_tag)
989 IHTMLElement *elem = _get_elem_iface(line, unk);
990 IHTMLElement *off_parent;
994 hres = IHTMLElement_get_offsetTop(elem, &l);
995 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
997 hres = IHTMLElement_get_offsetHeight(elem, &l);
998 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
1000 hres = IHTMLElement_get_offsetWidth(elem, &l);
1001 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
1003 hres = IHTMLElement_get_offsetLeft(elem, &l);
1004 ok_(__FILE__,line) (hres == S_OK, "get_offsetLeft failed: %08x\n", hres);
1006 hres = IHTMLElement_get_offsetParent(elem, &off_parent);
1007 ok_(__FILE__,line) (hres == S_OK, "get_offsetParent failed: %08x\n", hres);
1009 _test_elem_tag(line, (IUnknown*)off_parent, parent_tag);
1010 IHTMLElement_Release(off_parent);
1012 IHTMLElement_Release(elem);
1015 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1016 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
1018 IHTMLWindow2 *window;
1019 IHTMLDocument2 *ret;
1022 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1023 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
1025 hres = IHTMLWindow2_get_document(window, &ret);
1026 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
1027 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
1032 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1033 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
1038 hres = IHTMLWindow2_get_name(window, &name);
1039 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
1041 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
1043 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
1044 SysFreeString(name);
1047 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1048 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
1054 hres = IHTMLWindow2_put_name(window, str);
1056 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
1058 _test_window_name(line, window, name);
1061 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1062 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
1067 hres = IHTMLWindow2_get_length(window, &length);
1068 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1069 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1072 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1073 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1075 IHTMLFrameBase2 *base2;
1076 IHTMLWindow2 *window;
1079 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1080 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1083 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1084 IHTMLFrameBase2_Release(base2);
1085 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1086 ok(window != NULL, "contentWindow = NULL\n");
1091 static void test_get_set_attr(IHTMLDocument2 *doc)
1094 IHTMLDocument3 *doc3;
1099 /* grab an element to test with */
1100 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1101 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1103 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1104 IHTMLDocument3_Release(doc3);
1105 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1107 /* get a non-present attribute */
1108 bstr = a2bstr("notAnAttribute");
1109 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1110 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1111 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1113 SysFreeString(bstr);
1115 /* get a present attribute */
1116 bstr = a2bstr("scrollHeight");
1117 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1118 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1119 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1121 SysFreeString(bstr);
1123 /* create a new BSTR attribute */
1124 bstr = a2bstr("newAttribute");
1126 V_VT(&val) = VT_BSTR;
1127 V_BSTR(&val) = a2bstr("the value");
1128 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1129 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1132 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1133 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1134 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1135 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)));
1138 /* overwrite the attribute with a BOOL */
1139 V_VT(&val) = VT_BOOL;
1140 V_BOOL(&val) = VARIANT_TRUE;
1141 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1142 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1145 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1146 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1147 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1148 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1151 SysFreeString(bstr);
1153 /* case-insensitive */
1154 bstr = a2bstr("newattribute");
1155 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1156 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1157 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1158 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1160 SysFreeString(bstr);
1162 IHTMLElement_Release(elem);
1165 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1166 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1169 IHTMLDocument3 *doc3;
1172 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1173 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1174 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1175 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1176 IHTMLDocument3_Release(doc3);
1181 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1182 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1184 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1188 hres = IHTMLAnchorElement_get_href(anchor, &str);
1189 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1190 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1193 _test_disp_value(line, unk, exhref);
1196 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1197 static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhref)
1199 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1203 str = a2bstr(exhref);
1204 hres = IHTMLAnchorElement_put_href(anchor, str);
1205 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1208 _test_disp_value(line, unk, exhref);
1211 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1212 static void _test_anchor_get_target(unsigned line, IUnknown *unk, const char *target)
1214 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1218 hres = IHTMLAnchorElement_get_target(anchor, &str);
1219 ok_(__FILE__,line)(hres == S_OK, "get_target failed: %08x\n", hres);
1221 ok_(__FILE__,line)(!strcmp_wa(str, target), "target = %s, expected %s\n", wine_dbgstr_w(str), target);
1223 ok_(__FILE__,line)(str == NULL, "target = %s, expected NULL\n", wine_dbgstr_w(str));
1227 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1228 static void _test_anchor_put_target(unsigned line, IUnknown *unk, const char *target)
1230 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1234 str = target ? a2bstr(target) : NULL;
1235 hres = IHTMLAnchorElement_put_target(anchor, str);
1236 ok_(__FILE__,line)(hres == S_OK, "put_target failed: %08x\n", hres);
1241 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1242 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1247 hres = IHTMLOptionElement_get_text(option, &bstr);
1248 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1249 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1250 SysFreeString(bstr);
1253 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1254 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1259 bstr = a2bstr(text);
1260 hres = IHTMLOptionElement_put_text(option, bstr);
1261 SysFreeString(bstr);
1262 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1264 _test_option_text(line, option, text);
1267 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1268 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1273 hres = IHTMLOptionElement_get_value(option, &bstr);
1274 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1275 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1276 SysFreeString(bstr);
1279 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1280 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1285 bstr = a2bstr(value);
1286 hres = IHTMLOptionElement_put_value(option, bstr);
1287 SysFreeString(bstr);
1288 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1290 _test_option_value(line, option, value);
1293 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1294 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1296 VARIANT_BOOL b = 0x100;
1299 hres = IHTMLOptionElement_get_selected(option, &b);
1300 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1301 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1304 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1305 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1309 hres = IHTMLOptionElement_put_selected(option, b);
1310 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1311 _test_option_selected(line, option, b);
1314 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1315 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1317 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1318 BSTR value = (void*)0xdeadbeef;
1321 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1322 IHTMLTextAreaElement_Release(textarea);
1323 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1325 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1327 ok_(__FILE__,line)(!value, "value = %p\n", value);
1328 SysFreeString(value);
1331 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1332 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1334 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1335 BSTR tmp = a2bstr(value);
1338 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1339 IHTMLTextAreaElement_Release(textarea);
1340 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1343 _test_textarea_value(line, unk, value);
1346 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1347 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1349 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1350 VARIANT_BOOL b = 0x100;
1353 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1354 IHTMLTextAreaElement_Release(textarea);
1355 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1356 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1359 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1360 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1362 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1365 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1366 IHTMLTextAreaElement_Release(textarea);
1367 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1369 _test_textarea_readonly(line, unk, b);
1372 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1373 static void _test_textarea_type(unsigned line, IUnknown *unk)
1375 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1376 BSTR type = (void*)0xdeadbeef;
1379 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1380 IHTMLTextAreaElement_Release(textarea);
1381 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1382 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1383 SysFreeString(type);
1386 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1387 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1389 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1393 text = a2bstr(extext);
1394 hres = IHTMLCommentElement_get_text(comment, &text);
1395 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1396 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1398 IHTMLCommentElement_Release(comment);
1399 SysFreeString(text);
1402 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1403 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1405 IHTMLObjectElement *object = _get_object_iface(line, unk);
1410 hres = IHTMLObjectElement_get_vspace(object, &l);
1411 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1412 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1413 IHTMLObjectElement_Release(object);
1416 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1417 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1418 const char *txt, const char *val)
1420 IHTMLOptionElementFactory *factory;
1421 IHTMLOptionElement *option;
1422 IHTMLWindow2 *window;
1423 VARIANT text, value, empty;
1426 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1427 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1429 hres = IHTMLWindow2_get_Option(window, &factory);
1430 IHTMLWindow2_Release(window);
1431 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1433 V_VT(&text) = VT_BSTR;
1434 V_BSTR(&text) = a2bstr(txt);
1435 V_VT(&value) = VT_BSTR;
1436 V_BSTR(&value) = a2bstr(val);
1437 V_VT(&empty) = VT_EMPTY;
1439 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1440 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1442 IHTMLOptionElementFactory_Release(factory);
1443 VariantClear(&text);
1444 VariantClear(&value);
1446 _test_option_text(line, option, txt);
1447 _test_option_value(line, option, val);
1448 _test_option_selected(line, option, VARIANT_FALSE);
1453 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1454 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1459 hres = IHTMLImgElement_get_width(img, &found);
1460 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1461 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1464 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1465 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1469 hres = IHTMLImgElement_put_width(img, width);
1470 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1472 _test_img_width(line, img, width);
1475 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1476 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1481 hres = IHTMLImgElement_get_height(img, &found);
1482 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1483 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1486 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1487 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1491 hres = IHTMLImgElement_put_height(img, height);
1492 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1494 _test_img_height(line, img, height);
1497 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1498 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1499 LONG wdth, LONG hght)
1501 IHTMLImageElementFactory *factory;
1502 IHTMLImgElement *img;
1503 IHTMLWindow2 *window;
1504 VARIANT width, height;
1508 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1509 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1511 hres = IHTMLWindow2_get_Image(window, &factory);
1512 IHTMLWindow2_Release(window);
1513 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1515 test_ifaces((IUnknown*)factory, img_factory_iids);
1516 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1519 snprintf(buf, 16, "%d", wdth);
1520 V_VT(&width) = VT_BSTR;
1521 V_BSTR(&width) = a2bstr(buf);
1523 V_VT(&width) = VT_EMPTY;
1528 snprintf(buf, 16, "%d", hght);
1529 V_VT(&height) = VT_BSTR;
1530 V_BSTR(&height) = a2bstr(buf);
1532 V_VT(&height) = VT_EMPTY;
1536 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1537 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1539 IHTMLImageElementFactory_Release(factory);
1540 VariantClear(&width);
1541 VariantClear(&height);
1543 if(SUCCEEDED(hres)) {
1544 _test_img_width(line, img, wdth);
1545 _test_img_height(line, img, hght);
1552 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1553 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1555 LONG len = 0xdeadbeef;
1558 hres = IHTMLSelectElement_get_length(select, &len);
1559 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1560 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1563 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1564 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1566 IHTMLSelectElement *select = _get_select_iface(line, unk);
1569 hres = IHTMLSelectElement_put_length(select, length);
1570 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1571 _test_select_length(line, select, length);
1572 IHTMLSelectElement_Release(select);
1575 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1576 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1578 LONG idx = 0xdeadbeef;
1581 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1582 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1583 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1586 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1587 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1591 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1592 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1593 _test_select_selidx(line, select, index);
1596 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1597 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1602 hres = IHTMLSelectElement_get_value(select, &val);
1603 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1605 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1607 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1611 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1612 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1618 hres = IHTMLSelectElement_put_value(select, bstr);
1619 SysFreeString(bstr);
1620 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1623 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1624 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1629 hres = IHTMLSelectElement_get_type(select, &type);
1630 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1631 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1632 SysFreeString(type);
1635 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1636 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1641 hres = IHTMLTxtRange_get_text(range, &text);
1642 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1645 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1646 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1648 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1651 SysFreeString(text);
1655 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1656 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1660 hres = IHTMLTxtRange_collapse(range, b);
1661 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1662 _test_range_text(line, range, NULL);
1665 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1666 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1667 VARIANT_BOOL exb, const char *extext)
1669 VARIANT_BOOL b = 0xe0e0;
1672 hres = IHTMLTxtRange_expand(range, unit, &b);
1673 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1674 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1675 _test_range_text(line, range, extext);
1678 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1679 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1681 LONG c = 0xdeadbeef;
1684 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1685 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1686 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1687 _test_range_text(line, range, NULL);
1690 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1691 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1692 LPWSTR unit, LONG cnt, LONG excnt)
1694 LONG c = 0xdeadbeef;
1697 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1698 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1699 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1702 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1703 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1705 LONG c = 0xdeadbeef;
1708 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1709 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1710 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1713 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1714 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1717 BSTR bstr = a2bstr(text);
1719 hres = IHTMLTxtRange_put_text(range, bstr);
1720 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1721 SysFreeString(bstr);
1722 _test_range_text(line, range, NULL);
1725 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1726 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1732 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1733 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1734 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1737 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1738 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1744 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1745 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1746 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1749 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1750 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1751 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1754 test_range_inrange(range1, range2, VARIANT_TRUE);
1755 test_range_inrange(range2, range1, VARIANT_TRUE);
1759 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1760 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1765 hres = IHTMLTxtRange_parentElement(range, &elem);
1766 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1768 _test_elem_type(line, (IUnknown*)elem, type);
1770 IHTMLElement_Release(elem);
1773 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1774 static void _test_elem_collection(unsigned line, IUnknown *unk,
1775 const elem_type_t *elem_types, LONG exlen)
1777 IHTMLElementCollection *col;
1780 VARIANT name, index;
1781 IDispatch *disp, *disp2;
1784 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1785 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1787 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1789 hres = IHTMLElementCollection_get_length(col, &len);
1790 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1791 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1796 V_VT(&index) = VT_EMPTY;
1798 for(i=0; i<len; i++) {
1799 V_VT(&name) = VT_I4;
1801 disp = (void*)0xdeadbeef;
1802 hres = IHTMLElementCollection_item(col, name, index, &disp);
1803 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1804 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1805 if(FAILED(hres) || !disp)
1808 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1811 V_VT(&name) = VT_UINT;
1813 disp2 = (void*)0xdeadbeef;
1814 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1815 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1816 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1818 IDispatch_Release(disp2);
1821 IDispatch_Release(disp);
1824 V_VT(&name) = VT_I4;
1826 disp = (void*)0xdeadbeef;
1827 hres = IHTMLElementCollection_item(col, name, index, &disp);
1828 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1829 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1831 V_VT(&name) = VT_I4;
1833 disp = (void*)0xdeadbeef;
1834 hres = IHTMLElementCollection_item(col, name, index, &disp);
1835 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1836 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1838 IHTMLElementCollection_Release(col);
1841 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1842 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1844 IHTMLElement *elem = _get_elem_iface(line, unk);
1848 hres = IHTMLElement_get_all(elem, &disp);
1849 IHTMLElement_Release(elem);
1850 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1852 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1853 IDispatch_Release(disp);
1856 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1857 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1859 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1860 IHTMLElementCollection *col = NULL;
1861 elem_type_t *types = NULL;
1866 tmp = a2bstr(elem_type_infos[type].tag);
1867 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1869 IHTMLElement2_Release(elem);
1870 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1871 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1874 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1875 for(i=0; i<exlen; i++)
1879 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1881 HeapFree(GetProcessHeap(), 0, types);
1884 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1885 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1890 hres = IHTMLElement_get_innerText(elem, &text);
1891 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1892 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1893 wine_dbgstr_w(text), extext);
1894 SysFreeString(text);
1897 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1898 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1900 IHTMLDOMChildrenCollection *col;
1905 hres = IHTMLElement_put_innerText(elem, str);
1906 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1909 _test_elem_innertext(line, elem, text);
1912 col = _get_child_nodes(line, (IUnknown*)elem);
1913 ok(col != NULL, "col == NULL\n");
1915 LONG length = 0, type;
1918 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1919 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1920 ok(length == 1, "length = %d\n", length);
1922 node = _get_child_item(line, col, 0);
1923 ok(node != NULL, "node == NULL\n");
1925 type = _get_node_type(line, (IUnknown*)node);
1926 ok(type == 3, "type=%d\n", type);
1927 IHTMLDOMNode_Release(node);
1930 IHTMLDOMChildrenCollection_Release(col);
1935 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1936 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1938 IHTMLElement *elem = _get_elem_iface(line, unk);
1942 hres = IHTMLElement_get_innerHTML(elem, &html);
1943 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1945 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1947 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1949 IHTMLElement_Release(elem);
1950 SysFreeString(html);
1953 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1954 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1956 IHTMLElement *elem = _get_elem_iface(line, unk);
1960 html = a2bstr(inner_html);
1961 hres = IHTMLElement_put_innerHTML(elem, html);
1962 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1964 IHTMLElement_Release(elem);
1965 SysFreeString(html);
1968 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1969 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1971 IHTMLElement *elem = _get_elem_iface(line, unk);
1975 html = a2bstr(outer_html);
1976 hres = IHTMLElement_put_outerHTML(elem, html);
1977 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1979 IHTMLElement_Release(elem);
1980 SysFreeString(html);
1983 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1984 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1986 IHTMLElement *elem = _get_elem_iface(line, unk);
1990 hres = IHTMLElement_get_outerHTML(elem, &html);
1991 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1992 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1994 IHTMLElement_Release(elem);
1995 SysFreeString(html);
1998 #define get_first_child(n) _get_first_child(__LINE__,n)
1999 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
2001 IHTMLDOMNode *node = _get_node_iface(line, unk);
2002 IHTMLDOMNode *child = NULL;
2005 hres = IHTMLDOMNode_get_firstChild(node, &child);
2006 IHTMLDOMNode_Release(node);
2007 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
2012 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2013 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2015 IHTMLDOMNode *node = _get_node_iface(line, unk);
2016 VARIANT_BOOL b = 0xdead;
2019 hres = IHTMLDOMNode_hasChildNodes(node, &b);
2020 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
2021 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
2023 IHTMLDOMNode_Release(node);
2026 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2027 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
2029 IHTMLDOMNode *node = _get_node_iface(line, unk);
2030 IHTMLDOMNode *parent;
2033 hres = IHTMLDOMNode_get_parentNode(node, &parent);
2034 IHTMLDOMNode_Release(node);
2035 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
2040 #define node_get_next(u) _node_get_next(__LINE__,u)
2041 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
2043 IHTMLDOMNode *node = _get_node_iface(line, unk);
2047 hres = IHTMLDOMNode_get_nextSibling(node, &next);
2048 IHTMLDOMNode_Release(node);
2049 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
2054 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2055 static IHTMLDOMNode *_node_get_prev(unsigned line, IUnknown *unk)
2057 IHTMLDOMNode *node = _get_node_iface(line, unk);
2061 hres = IHTMLDOMNode_get_previousSibling(node, &prev);
2062 IHTMLDOMNode_Release(node);
2063 ok_(__FILE__,line) (hres == S_OK, "get_previousSibling failed: %08x\n", hres);
2068 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2069 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
2071 IHTMLElement *elem = _get_elem_iface(line, unk);
2072 IHTMLElement *parent;
2075 hres = IHTMLElement_get_parentElement(elem, &parent);
2076 IHTMLElement_Release(elem);
2077 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
2082 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2083 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2085 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2086 VARIANT_BOOL disabled = 100;
2090 hres = IHTMLElement3_get_disabled(elem3, &disabled);
2091 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2092 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2093 IHTMLElement3_Release(elem3);
2096 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2097 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
2099 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2103 hres = IHTMLElement3_put_disabled(elem3, b);
2104 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2106 IHTMLElement3_Release(elem3);
2107 _test_elem3_get_disabled(line, unk, b);
2110 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2111 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2113 VARIANT_BOOL disabled = 100;
2116 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2117 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2118 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2120 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2123 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2124 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2126 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2130 hres = IHTMLDOMTextNode_get_length(text, &length);
2131 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2132 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2133 IHTMLDOMTextNode_Release(text);
2136 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2137 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2141 hres = IHTMLSelectElement_put_disabled(select, b);
2142 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2144 _test_select_get_disabled(line, select, b);
2147 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2148 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2150 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2151 IHTMLTextContainer *txtcont;
2152 LONG l = -1, l2 = -1;
2155 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2156 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2157 IHTMLElement2_Release(elem);
2159 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2160 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2162 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2163 IHTMLTextContainer_Release(txtcont);
2164 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2165 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2170 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2171 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2173 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2174 IHTMLTextContainer *txtcont;
2175 LONG l = -1, l2 = -1;
2178 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2179 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2180 IHTMLElement2_Release(elem);
2182 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2183 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2185 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2186 IHTMLTextContainer_Release(txtcont);
2187 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2188 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2193 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2194 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2196 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2197 IHTMLTextContainer *txtcont;
2198 LONG l = -1, l2 = -1;
2201 hres = IHTMLElement2_get_scrollTop(elem, &l);
2202 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2203 IHTMLElement2_Release(elem);
2205 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2206 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2208 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2209 IHTMLTextContainer_Release(txtcont);
2210 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2211 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2216 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2217 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2219 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2220 IHTMLTextContainer *txtcont;
2221 LONG l = -1, l2 = -1;
2224 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2225 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2227 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2228 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2229 IHTMLElement2_Release(elem);
2231 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2232 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2234 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2235 IHTMLTextContainer_Release(txtcont);
2236 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2237 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2240 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2241 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc, const char *broken_src)
2243 IHTMLImgElement *img = _get_img_iface(line, unk);
2247 hres = IHTMLImgElement_get_src(img, &src);
2248 IHTMLImgElement_Release(img);
2249 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2250 ok_(__FILE__,line) (!strcmp_wa(src, exsrc) || (broken_src && broken(!strcmp_wa(src, broken_src))),
2251 "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2255 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2256 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2258 IHTMLImgElement *img = _get_img_iface(line, unk);
2263 hres = IHTMLImgElement_put_src(img, tmp);
2264 IHTMLImgElement_Release(img);
2266 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2269 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2270 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2272 IHTMLImgElement *img = _get_img_iface(line, unk);
2276 hres = IHTMLImgElement_get_alt(img, &alt);
2277 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2279 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2281 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2285 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2286 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2288 IHTMLImgElement *img = _get_img_iface(line, unk);
2293 hres = IHTMLImgElement_put_alt(img, tmp);
2294 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2297 _test_img_alt(line, unk, alt);
2300 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2301 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2303 IHTMLImgElement *img = _get_img_iface(line, unk);
2307 hres = IHTMLImgElement_get_name(img, &sName);
2308 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2309 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2310 IHTMLImgElement_Release(img);
2311 SysFreeString(sName);
2314 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2315 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2320 hres = IHTMLInputElement_get_type(input, &type);
2321 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2322 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2323 SysFreeString(type);
2326 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2327 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2329 BSTR name = (BSTR)0xdeadbeef;
2332 hres = IHTMLInputElement_get_name(input, &name);
2333 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2335 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2337 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2338 SysFreeString(name);
2341 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2342 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2344 BSTR tmp = a2bstr(name);
2347 hres = IHTMLInputElement_put_name(input, tmp);
2348 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2351 _test_input_name(line, input, name);
2354 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2355 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2357 VARIANT_BOOL disabled = 100;
2360 hres = IHTMLInputElement_get_disabled(input, &disabled);
2361 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2362 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2364 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2367 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2368 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2372 hres = IHTMLInputElement_put_disabled(input, b);
2373 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2375 _test_input_get_disabled(line, input, b);
2378 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2379 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2381 VARIANT_BOOL checked = 100;
2384 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2385 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2386 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2389 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2390 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2394 hres = IHTMLInputElement_put_defaultChecked(input, b);
2395 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2397 _test_input_get_defaultchecked(line, input, b);
2400 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2401 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2403 VARIANT_BOOL checked = 100;
2406 hres = IHTMLInputElement_get_checked(input, &checked);
2407 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2408 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2411 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2412 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2416 hres = IHTMLInputElement_put_checked(input, b);
2417 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2419 _test_input_get_checked(line, input, b);
2422 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2423 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2425 IHTMLInputElement *input;
2429 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2430 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2434 hres = IHTMLInputElement_get_value(input, &bstr);
2435 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2437 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2439 ok_(__FILE__,line) (!bstr, "exval != NULL\n");
2440 SysFreeString(bstr);
2441 IHTMLInputElement_Release(input);
2444 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2445 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2447 IHTMLInputElement *input;
2451 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2452 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2457 hres = IHTMLInputElement_put_value(input, bstr);
2458 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2459 SysFreeString(bstr);
2460 IHTMLInputElement_Release(input);
2462 _test_input_value(line, unk, val);
2465 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2466 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2471 hres = IHTMLInputElement_get_src(input, &src);
2472 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2474 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2476 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2480 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2481 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2487 hres = IHTMLInputElement_put_src(input, tmp);
2489 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2491 _test_input_src(line, input, src);
2494 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2495 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2497 IHTMLElement *elem = _get_elem_iface(line, unk);
2498 BSTR class = (void*)0xdeadbeef;
2501 hres = IHTMLElement_get_className(elem, &class);
2502 IHTMLElement_Release(elem);
2503 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2505 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2507 ok_(__FILE__,line) (!class, "class != NULL\n");
2508 SysFreeString(class);
2511 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2512 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2514 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2518 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2519 IHTMLElement2_Release(elem2);
2520 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2521 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2524 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2525 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2527 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2530 hres = IHTMLElement2_put_tabIndex(elem2, index);
2531 IHTMLElement2_Release(elem2);
2532 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2534 _test_elem_tabindex(line, unk, index);
2537 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2538 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2540 IHTMLStyleElement *style = _get_style_iface(line, unk);
2544 hres = IHTMLStyleElement_get_media(style, &media);
2545 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2547 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2549 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2551 IHTMLStyleElement_Release(style);
2552 SysFreeString(media);
2555 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2556 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2558 IHTMLStyleElement *style = _get_style_iface(line, unk);
2562 str = a2bstr(media);
2563 hres = IHTMLStyleElement_put_media(style, str);
2564 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2565 IHTMLStyleElement_Release(style);
2568 _test_style_media(line, unk, media);
2571 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2572 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2574 IHTMLStyleElement *style = _get_style_iface(line, unk);
2578 hres = IHTMLStyleElement_get_type(style, &type);
2579 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2581 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2583 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2585 IHTMLStyleElement_Release(style);
2586 SysFreeString(type);
2589 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2590 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2592 IHTMLStyleElement *style = _get_style_iface(line, unk);
2597 hres = IHTMLStyleElement_put_type(style, str);
2598 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2599 IHTMLStyleElement_Release(style);
2602 _test_style_type(line, unk, type);
2605 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2606 static void _test_elem_filters(unsigned line, IUnknown *unk)
2608 IHTMLElement *elem = _get_elem_iface(line, unk);
2610 IHTMLFiltersCollection *filters;
2612 hres = IHTMLElement_get_filters(elem, &filters);
2613 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2614 "get_filters failed: %08x\n", hres);
2618 IDispatchEx *dispex;
2620 hres = IHTMLFiltersCollection_get_length(filters, &len);
2621 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2622 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2624 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2625 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2626 "Could not get IDispatchEx interface: %08x\n", hres);
2627 if(SUCCEEDED(hres)) {
2628 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2629 IDispatchEx_Release(dispex);
2632 IHTMLFiltersCollection_Release(filters);
2635 IHTMLElement_Release(elem);
2638 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2639 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2641 IHTMLElement *elem = _get_elem_iface(line, unk);
2645 tmp = class ? a2bstr(class) : NULL;
2646 hres = IHTMLElement_put_className(elem, tmp);
2647 IHTMLElement_Release(elem);
2648 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2651 _test_elem_class(line, unk, class);
2654 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2655 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2657 IHTMLElement *elem = _get_elem_iface(line, unk);
2658 BSTR id = (void*)0xdeadbeef;
2661 hres = IHTMLElement_get_id(elem, &id);
2662 IHTMLElement_Release(elem);
2663 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2666 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2668 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2673 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2674 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2676 IHTMLElement *elem = _get_elem_iface(line, unk);
2677 BSTR tmp = a2bstr(new_id);
2680 hres = IHTMLElement_put_id(elem, tmp);
2681 IHTMLElement_Release(elem);
2683 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2685 _test_elem_id(line, unk, new_id);
2688 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2689 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2691 IHTMLElement *elem = _get_elem_iface(line, unk);
2695 hres = IHTMLElement_get_title(elem, &title);
2696 IHTMLElement_Release(elem);
2697 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2699 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2701 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2703 SysFreeString(title);
2706 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2707 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2709 IHTMLElement *elem = _get_elem_iface(line, unk);
2713 tmp = a2bstr(title);
2714 hres = IHTMLElement_put_title(elem, tmp);
2715 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2717 IHTMLElement_Release(elem);
2721 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2722 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2724 IHTMLDOMNode *node = _get_node_iface(line, unk);
2728 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2729 IHTMLDOMNode_Release(node);
2730 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2733 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2734 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2736 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2742 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2743 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2745 IHTMLDOMNode *node = _get_node_iface(line, unk);
2749 V_VT(&var) = VT_BSTR;
2750 V_BSTR(&var) = a2bstr(val);
2752 hres = IHTMLDOMNode_put_nodeValue(node, var);
2753 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2754 IHTMLDOMNode_Release(node);
2758 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2759 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2761 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2765 hres = IHTMLElement2_get_clientWidth(elem, &l);
2766 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2767 hres = IHTMLElement2_get_clientHeight(elem, &l);
2768 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2770 IHTMLElement2_Release(elem);
2773 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2774 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2776 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2780 hres = IHTMLElement2_get_clientLeft(elem, &l);
2781 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2782 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2784 hres = IHTMLElement2_get_clientTop(elem, &l);
2785 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2786 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2788 IHTMLElement2_Release(elem);
2791 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2792 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2794 IHTMLFormElement *form = _get_form_iface(line, unk);
2795 LONG len = 0xdeadbeef;
2798 hres = IHTMLFormElement_get_length(form, &len);
2799 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2800 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2802 IHTMLFormElement_Release(form);
2805 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2806 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2808 IHTMLFormElement *form = _get_form_iface(line, unk);
2809 BSTR action = (void*)0xdeadbeef;
2812 hres = IHTMLFormElement_get_action(form, &action);
2813 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2815 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2817 ok_(__FILE__,line)(!action, "action=%p\n", action);
2819 SysFreeString(action);
2820 IHTMLFormElement_Release(form);
2823 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2824 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2826 IHTMLFormElement *form = _get_form_iface(line, unk);
2827 BSTR tmp = a2bstr(action);
2830 hres = IHTMLFormElement_put_action(form, tmp);
2831 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2833 IHTMLFormElement_Release(form);
2835 _test_form_action(line, unk, action);
2838 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2839 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2841 IHTMLFormElement *form = _get_form_iface(line, unk);
2842 BSTR method = (void*)0xdeadbeef;
2845 hres = IHTMLFormElement_get_method(form, &method);
2846 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2848 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2850 ok_(__FILE__,line)(!method, "method=%p\n", method);
2852 SysFreeString(method);
2853 IHTMLFormElement_Release(form);
2856 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2857 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2859 IHTMLFormElement *form = _get_form_iface(line, unk);
2860 BSTR tmp = a2bstr(method);
2863 hres = IHTMLFormElement_put_method(form, tmp);
2864 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2866 IHTMLFormElement_Release(form);
2868 if(exp_hres == S_OK)
2869 _test_form_method(line, unk, method);
2872 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2873 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2875 IHTMLFormElement *form = _get_form_iface(line, unk);
2876 BSTR name = (void*)0xdeadbeef;
2879 hres = IHTMLFormElement_get_name(form, &name);
2880 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2882 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2884 ok_(__FILE__,line)(!name, "name=%p\n", name);
2886 SysFreeString(name);
2887 IHTMLFormElement_Release(form);
2890 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2891 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2893 IHTMLFormElement *form = _get_form_iface(line, unk);
2894 BSTR tmp = a2bstr(name);
2897 hres = IHTMLFormElement_put_name(form, tmp);
2898 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2900 IHTMLFormElement_Release(form);
2902 _test_form_name(line, unk, name);
2905 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2906 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2908 IHTMLFormElement *form = _get_form_iface(line, unk);
2909 BSTR encoding = (void*)0xdeadbeef;
2912 hres = IHTMLFormElement_get_encoding(form, &encoding);
2913 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2915 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2917 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2919 SysFreeString(encoding);
2920 IHTMLFormElement_Release(form);
2923 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2924 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2926 IHTMLFormElement *form = _get_form_iface(line, unk);
2927 BSTR tmp = a2bstr(encoding);
2930 hres = IHTMLFormElement_put_encoding(form, tmp);
2931 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2933 IHTMLFormElement_Release(form);
2935 if(exp_hres == S_OK)
2936 _test_form_encoding(line, unk, encoding);
2939 #define test_form_elements(a) _test_form_elements(__LINE__,a)
2940 static void _test_form_elements(unsigned line, IUnknown *unk)
2942 IHTMLFormElement *form = _get_form_iface(line, unk);
2947 hres = IHTMLFormElement_get_elements(form, &disp);
2948 ok_(__FILE__,line)(hres == S_OK, "get_elements failed: %08x\n", hres);
2949 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
2950 ok_(__FILE__,line)(iface_cmp((IUnknown*)form, (IUnknown*)disp), "disp != form\n");
2952 IDispatch_Release(disp);
2953 IHTMLFormElement_Release(form);
2956 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2957 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2959 IHTMLElement *elem = _get_elem_iface(line, unk);
2960 IHTMLDocument2 *doc;
2965 hres = IHTMLElement_get_document(elem, &disp);
2966 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2967 ok(disp != NULL, "disp == NULL\n");
2969 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2970 IDispatch_Release(disp);
2971 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2976 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
2977 static IHTMLDOMAttribute *_get_elem_attr_node(unsigned line, IUnknown *unk, const char *attr_name, BOOL expect_success)
2979 IHTMLElement4 *elem = _get_elem4_iface(line, unk);
2980 BSTR str = a2bstr(attr_name);
2981 IHTMLDOMAttribute *attr;
2984 attr = (void*)0xdeadbeef;
2985 hres = IHTMLElement4_getAttributeNode(elem, str, &attr);
2986 ok_(__FILE__,line)(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
2988 ok_(__FILE__,line)(attr != NULL, "attr = NULL\n");
2990 ok_(__FILE__,line)(!attr, "attr = %p\n", attr);
2992 IHTMLElement4_Release(elem);
2997 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
2998 static void _get_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT *v, VARTYPE vt)
3002 hres = IHTMLDOMAttribute_get_nodeValue(attr, v);
3003 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
3004 ok_(__FILE__,line) (V_VT(v) == vt, "vt=%d, expected %d\n", V_VT(v), vt);
3007 #define get_window_doc(e) _get_window_doc(__LINE__,e)
3008 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
3010 IHTMLDocument2 *doc;
3014 hres = IHTMLWindow2_get_document(window, &doc);
3015 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3016 ok(doc != NULL, "disp == NULL\n");
3021 #define doc_get_body(d) _doc_get_body(__LINE__,d)
3022 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
3027 hres = IHTMLDocument2_get_body(doc, &elem);
3028 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
3029 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
3034 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
3035 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
3037 IHTMLElement *elem = NULL;
3042 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
3043 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3044 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
3050 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
3051 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
3053 IHTMLDocument3 *doc3;
3054 IHTMLDOMNode *node = NULL;
3058 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3059 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
3062 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
3063 IHTMLDocument3_Release(doc3);
3065 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3066 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
3071 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
3072 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
3074 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3075 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
3076 IHTMLDOMNode *new_child = NULL;
3079 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
3080 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
3081 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3082 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3084 IHTMLDOMNode_Release(node);
3085 IHTMLDOMNode_Release(child);
3090 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
3091 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
3093 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3094 IHTMLDOMNode *new_child = NULL;
3097 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
3098 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
3099 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3100 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3102 IHTMLDOMNode_Release(node);
3107 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
3108 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
3110 IHTMLDOMNode *node = _get_node_iface(line, unk);
3111 IHTMLDOMNode *new_node = NULL;
3114 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
3115 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
3116 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
3117 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
3119 IHTMLDOMNode_Release(node);
3120 IHTMLDOMNode_Release(new_node);
3123 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
3124 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
3129 hres = IHTMLDocument2_get_title(doc, &title);
3130 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3131 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
3132 SysFreeString(title);
3135 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3136 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3141 tmp = a2bstr(title);
3142 hres = IHTMLDocument2_put_title(doc, tmp);
3143 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3147 static void test_elem_bounding_client_rect(IUnknown *unk)
3149 IHTMLRect *rect, *rect2;
3150 IHTMLElement2 *elem2;
3154 elem2 = get_elem2_iface(unk);
3155 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3156 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3157 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3158 IHTMLElement2_Release(elem2);
3159 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3160 ok(rect != NULL, "rect == NULL\n");
3161 ok(rect != rect2, "rect == rect2\n");
3162 IHTMLRect_Release(rect2);
3164 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3167 hres = IHTMLRect_get_top(rect, &l);
3168 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3169 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3172 hres = IHTMLRect_get_left(rect, &l);
3173 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3174 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3177 hres = IHTMLRect_get_bottom(rect, &l);
3178 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3179 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3182 hres = IHTMLRect_get_right(rect, &l);
3183 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3184 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3186 IHTMLRect_Release(rect);
3189 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3190 const elem_type_t *elem_types, LONG len)
3193 VARIANT name, index;
3197 V_VT(&index) = VT_EMPTY;
3198 V_VT(&name) = VT_BSTR;
3199 V_BSTR(&name) = a2bstr(n);
3201 hres = IHTMLElementCollection_item(col, name, index, &disp);
3202 ok(hres == S_OK, "item failed: %08x\n", hres);
3204 test_elem_collection((IUnknown*)disp, elem_types, len);
3205 IDispatch_Release(disp);
3206 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3210 V_VT(&index) = VT_I4;
3212 for(i=0; i<len; i++) {
3214 disp = (void*)0xdeadbeef;
3215 hres = IHTMLElementCollection_item(col, name, index, &disp);
3216 ok(hres == S_OK, "item failed: %08x\n", hres);
3217 ok(disp != NULL, "disp == NULL\n");
3218 if(FAILED(hres) || !disp)
3221 test_elem_type((IUnknown*)disp, elem_types[i]);
3223 IDispatch_Release(disp);
3227 disp = (void*)0xdeadbeef;
3228 hres = IHTMLElementCollection_item(col, name, index, &disp);
3229 ok(hres == S_OK, "item failed: %08x\n", hres);
3230 ok(disp == NULL, "disp != NULL\n");
3233 disp = (void*)0xdeadbeef;
3234 hres = IHTMLElementCollection_item(col, name, index, &disp);
3235 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3236 ok(disp == NULL, "disp != NULL\n");
3239 SysFreeString(V_BSTR(&name));
3242 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3244 IHTMLElementCollection *col;
3246 IDispatch *disp = (void*)0xdeadbeef;
3247 VARIANT name, index;
3250 hres = IHTMLDocument2_get_all(doc, &col);
3251 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3252 ok(col != NULL, "col == NULL\n");
3253 if(FAILED(hres) || !col)
3256 V_VT(&index) = VT_EMPTY;
3257 V_VT(&name) = VT_BSTR;
3258 V_BSTR(&name) = a2bstr(id);
3260 hres = IHTMLElementCollection_item(col, name, index, &disp);
3261 IHTMLElementCollection_Release(col);
3262 SysFreeString(V_BSTR(&name));
3263 ok(hres == S_OK, "item failed: %08x\n", hres);
3264 if(!expect_success) {
3265 ok(disp == NULL, "disp != NULL\n");
3269 ok(disp != NULL, "disp == NULL\n");
3273 elem = get_elem_iface((IUnknown*)disp);
3274 IDispatch_Release(disp);
3279 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3281 IHTMLDocument3 *doc3;
3286 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3287 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3290 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3292 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3294 IHTMLDocument3_Release(doc3);
3299 static void test_select_elem(IHTMLSelectElement *select)
3301 IDispatch *disp, *disp2;
3302 VARIANT name, index;
3305 test_select_type(select, "select-one");
3306 test_select_length(select, 2);
3307 test_select_selidx(select, 0);
3308 test_select_put_selidx(select, 1);
3310 test_select_set_value(select, "val1");
3311 test_select_value(select, "val1");
3313 test_select_get_disabled(select, VARIANT_FALSE);
3314 test_select_set_disabled(select, VARIANT_TRUE);
3315 test_select_set_disabled(select, VARIANT_FALSE);
3318 hres = IHTMLSelectElement_get_options(select, &disp);
3319 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3320 ok(disp != NULL, "options == NULL\n");
3321 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3322 IDispatch_Release(disp);
3324 V_VT(&index) = VT_EMPTY;
3325 V_VT(&name) = VT_I4;
3327 disp = (void*)0xdeadbeef;
3328 hres = IHTMLSelectElement_item(select, name, index, &disp);
3329 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3330 ok(!disp, "disp = %p\n", disp);
3333 disp = (void*)0xdeadbeef;
3334 hres = IHTMLSelectElement_item(select, name, index, &disp);
3335 ok(hres == S_OK, "item failed: %08x\n", hres);
3336 ok(!disp, "disp = %p\n", disp);
3339 hres = IHTMLSelectElement_item(select, name, index, NULL);
3340 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3343 hres = IHTMLSelectElement_item(select, name, index, &disp);
3344 ok(hres == S_OK, "item failed: %08x\n", hres);
3345 ok(disp != NULL, "disp = NULL\n");
3346 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3348 V_VT(&index) = VT_I4;
3351 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3352 ok(hres == S_OK, "item failed: %08x\n", hres);
3353 ok(disp2 != NULL, "disp = NULL\n");
3354 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3355 IDispatch_Release(disp2);
3356 IDispatch_Release(disp);
3359 static void test_form_item(IHTMLElement *elem)
3361 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3362 IDispatch *disp, *disp2;
3363 VARIANT name, index;
3366 V_VT(&index) = VT_EMPTY;
3367 V_VT(&name) = VT_I4;
3369 disp = (void*)0xdeadbeef;
3370 hres = IHTMLFormElement_item(form, name, index, &disp);
3371 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3372 ok(!disp, "disp = %p\n", disp);
3375 disp = (void*)0xdeadbeef;
3376 hres = IHTMLFormElement_item(form, name, index, &disp);
3377 ok(hres == S_OK, "item failed: %08x\n", hres);
3378 ok(!disp, "disp = %p\n", disp);
3381 hres = IHTMLFormElement_item(form, name, index, NULL);
3382 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3385 hres = IHTMLFormElement_item(form, name, index, &disp);
3386 ok(hres == S_OK, "item failed: %08x\n", hres);
3387 ok(disp != NULL, "disp = NULL\n");
3388 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3390 V_VT(&index) = VT_I4;
3393 hres = IHTMLFormElement_item(form, name, index, &disp2);
3394 ok(hres == S_OK, "item failed: %08x\n", hres);
3395 ok(disp2 != NULL, "disp = NULL\n");
3396 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3397 IDispatch_Release(disp2);
3398 IDispatch_Release(disp);
3401 static void test_create_option_elem(IHTMLDocument2 *doc)
3403 IHTMLOptionElement *option;
3405 option = create_option_elem(doc, "test text", "test value");
3407 test_option_put_text(option, "new text");
3408 test_option_put_value(option, "new value");
3409 test_option_put_selected(option, VARIANT_TRUE);
3410 test_option_put_selected(option, VARIANT_FALSE);
3412 IHTMLOptionElement_Release(option);
3415 static void test_create_img_elem(IHTMLDocument2 *doc)
3417 IHTMLImgElement *img;
3419 img = create_img_elem(doc, 10, 15);
3422 test_img_put_width(img, 5);
3423 test_img_put_height(img, 20);
3425 IHTMLImgElement_Release(img);
3429 img = create_img_elem(doc, -1, -1);
3432 test_img_put_width(img, 5);
3433 test_img_put_height(img, 20);
3435 IHTMLImgElement_Release(img);
3439 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3441 IHTMLBodyElement *body;
3442 IHTMLTxtRange *range;
3446 elem = doc_get_body(doc);
3447 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3448 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3449 IHTMLElement_Release(elem);
3451 hres = IHTMLBodyElement_createTextRange(body, &range);
3452 IHTMLBodyElement_Release(body);
3453 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3458 static void test_txtrange(IHTMLDocument2 *doc)
3460 IHTMLTxtRange *body_range, *range, *range2;
3461 IHTMLSelectionObject *selection;
3462 IDispatch *disp_range;
3465 body_range = test_create_body_range(doc);
3467 test_range_text(body_range, "test abc 123\r\nit's text");
3469 hres = IHTMLTxtRange_duplicate(body_range, &range);
3470 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3472 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3473 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3474 test_range_isequal(range, range2, VARIANT_TRUE);
3476 test_range_text(range, "test abc 123\r\nit's text");
3477 test_range_text(body_range, "test abc 123\r\nit's text");
3479 test_range_collapse(range, TRUE);
3480 test_range_isequal(range, range2, VARIANT_FALSE);
3481 test_range_inrange(range, range2, VARIANT_FALSE);
3482 test_range_inrange(range2, range, VARIANT_TRUE);
3483 IHTMLTxtRange_Release(range2);
3485 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3486 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3487 test_range_move(range, characterW, 2, 2);
3488 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3490 test_range_collapse(range, FALSE);
3491 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3493 test_range_collapse(range, FALSE);
3494 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3495 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3496 test_range_move(range, characterW, 2, 2);
3497 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3498 test_range_moveend(range, characterW, -5, -5);
3499 test_range_text(range, NULL);
3500 test_range_moveend(range, characterW, 3, 3);
3501 test_range_text(range, "c 1");
3502 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3503 test_range_collapse(range, TRUE);
3504 test_range_move(range, characterW, 4, 4);
3505 test_range_moveend(range, characterW, 1, 1);
3506 test_range_text(range, " ");
3507 test_range_move(range, wordW, 1, 1);
3508 test_range_moveend(range, characterW, 2, 2);
3509 test_range_text(range, "ab");
3511 IHTMLTxtRange_Release(range);
3513 hres = IHTMLTxtRange_duplicate(body_range, &range);
3514 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3516 test_range_text(range, "test abc 123\r\nit's text");
3517 test_range_move(range, characterW, 3, 3);
3518 test_range_moveend(range, characterW, 1, 1);
3519 test_range_text(range, "t");
3520 test_range_moveend(range, characterW, 3, 3);
3521 test_range_text(range, "t ab");
3522 test_range_moveend(range, characterW, -2, -2);
3523 test_range_text(range, "t ");
3524 test_range_move(range, characterW, 6, 6);
3525 test_range_moveend(range, characterW, 3, 3);
3526 test_range_text(range, "123");
3527 test_range_moveend(range, characterW, 2, 2);
3528 test_range_text(range, "123\r\ni");
3530 IHTMLTxtRange_Release(range);
3532 hres = IHTMLTxtRange_duplicate(body_range, &range);
3533 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3535 test_range_move(range, wordW, 1, 1);
3536 test_range_moveend(range, characterW, 2, 2);
3537 test_range_text(range, "ab");
3539 test_range_move(range, characterW, -2, -2);
3540 test_range_moveend(range, characterW, 2, 2);
3541 test_range_text(range, "t ");
3543 test_range_move(range, wordW, 3, 3);
3544 test_range_move(range, wordW, -2, -2);
3545 test_range_moveend(range, characterW, 2, 2);
3546 test_range_text(range, "ab");
3548 test_range_move(range, characterW, -6, -5);
3549 test_range_moveend(range, characterW, -1, 0);
3550 test_range_moveend(range, characterW, -6, 0);
3551 test_range_move(range, characterW, 2, 2);
3552 test_range_moveend(range, characterW, 2, 2);
3553 test_range_text(range, "st");
3554 test_range_moveend(range, characterW, -6, -4);
3555 test_range_moveend(range, characterW, 2, 2);
3557 IHTMLTxtRange_Release(range);
3559 hres = IHTMLTxtRange_duplicate(body_range, &range);
3560 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3562 test_range_move(range, wordW, 2, 2);
3563 test_range_moveend(range, characterW, 2, 2);
3564 test_range_text(range, "12");
3566 test_range_move(range, characterW, 15, 14);
3567 test_range_move(range, characterW, -2, -2);
3568 test_range_moveend(range, characterW, 3, 2);
3569 test_range_text(range, "t");
3570 test_range_moveend(range, characterW, -1, -1);
3571 test_range_text(range, "t");
3572 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3573 test_range_move(range, characterW, -2, -2);
3574 test_range_moveend(range, characterW, 2, 2);
3575 test_range_text(range, "s ");
3576 test_range_move(range, characterW, 100, 7);
3577 test_range_move(range, wordW, 1, 0);
3578 test_range_move(range, characterW, -2, -2);
3579 test_range_moveend(range, characterW, 3, 2);
3580 test_range_text(range, "t");
3582 IHTMLTxtRange_Release(range);
3584 hres = IHTMLTxtRange_duplicate(body_range, &range);
3585 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3587 test_range_collapse(range, TRUE);
3588 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3589 test_range_put_text(range, "word");
3590 test_range_text(body_range, "wordabc 123\r\nit's text");
3591 test_range_text(range, NULL);
3592 test_range_moveend(range, characterW, 3, 3);
3593 test_range_text(range, "abc");
3594 test_range_movestart(range, characterW, -2, -2);
3595 test_range_text(range, "rdabc");
3596 test_range_movestart(range, characterW, 3, 3);
3597 test_range_text(range, "bc");
3598 test_range_movestart(range, characterW, 4, 4);
3599 test_range_text(range, NULL);
3600 test_range_movestart(range, characterW, -3, -3);
3601 test_range_text(range, "c 1");
3602 test_range_movestart(range, characterW, -7, -6);
3603 test_range_text(range, "wordabc 1");
3604 test_range_movestart(range, characterW, 100, 22);
3605 test_range_text(range, NULL);
3607 IHTMLTxtRange_Release(range);
3608 IHTMLTxtRange_Release(body_range);
3610 hres = IHTMLDocument2_get_selection(doc, &selection);
3611 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3613 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3614 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3615 IHTMLSelectionObject_Release(selection);
3617 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3618 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3619 IDispatch_Release(disp_range);
3621 test_range_text(range, NULL);
3622 test_range_moveend(range, characterW, 3, 3);
3623 test_range_text(range, "wor");
3624 test_range_parent(range, ET_BODY);
3625 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3626 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3627 test_range_move(range, characterW, 3, 3);
3628 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3629 test_range_moveend(range, characterW, -4, -4);
3630 test_range_put_text(range, "abc def ");
3631 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3632 test_range_move(range, wordW, 1, 1);
3633 test_range_movestart(range, characterW, -1, -1);
3634 test_range_text(range, " ");
3635 test_range_move(range, wordW, 1, 1);
3636 test_range_moveend(range, characterW, 3, 3);
3637 test_range_text(range, "def");
3638 test_range_put_text(range, "xyz");
3639 test_range_moveend(range, characterW, 1, 1);
3640 test_range_move(range, wordW, 1, 1);
3641 test_range_moveend(range, characterW, 2, 2);
3642 test_range_text(range, "ab");
3644 IHTMLTxtRange_Release(range);
3647 static void test_txtrange2(IHTMLDocument2 *doc)
3649 IHTMLTxtRange *range;
3651 range = test_create_body_range(doc);
3653 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3654 test_range_move(range, characterW, 5, 5);
3655 test_range_moveend(range, characterW, 1, 1);
3656 test_range_text(range, "2");
3657 test_range_move(range, characterW, -3, -3);
3658 test_range_moveend(range, characterW, 3, 3);
3659 test_range_text(range, "c\r\n\r\n1");
3660 test_range_collapse(range, VARIANT_FALSE);
3661 test_range_moveend(range, characterW, 4, 4);
3662 test_range_text(range, "23");
3663 test_range_moveend(range, characterW, 1, 1);
3664 test_range_text(range, "23\r\n\r\n\r\nd");
3665 test_range_moveend(range, characterW, -1, -1);
3666 test_range_text(range, "23");
3667 test_range_moveend(range, characterW, -1, -1);
3668 test_range_text(range, "23");
3669 test_range_moveend(range, characterW, -2, -2);
3670 test_range_text(range, "2");
3672 IHTMLTxtRange_Release(range);
3675 static void test_compatmode(IHTMLDocument2 *doc)
3677 IHTMLDocument5 *doc5;
3681 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3682 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3686 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3687 IHTMLDocument5_Release(doc5);
3688 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3689 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3690 SysFreeString(mode);
3693 static void test_location(IHTMLDocument2 *doc)
3695 IHTMLLocation *location, *location2;
3696 IHTMLWindow2 *window;
3701 hres = IHTMLDocument2_get_location(doc, &location);
3702 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3704 hres = IHTMLDocument2_get_location(doc, &location2);
3705 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3707 ok(location == location2, "location != location2\n");
3708 IHTMLLocation_Release(location2);
3710 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3711 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3713 hres = IHTMLWindow2_get_location(window, &location2);
3714 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3715 ok(location == location2, "location != location2\n");
3716 IHTMLLocation_Release(location2);
3718 test_ifaces((IUnknown*)location, location_iids);
3719 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3721 hres = IHTMLLocation_get_pathname(location, &str);
3722 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3723 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3726 hres = IHTMLLocation_get_href(location, NULL);
3727 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3729 hres = IHTMLLocation_get_href(location, &str);
3730 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3731 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3734 ref = IHTMLLocation_Release(location);
3735 ok(!ref, "location chould be destroyed here\n");
3738 static void test_plugins_col(IOmNavigator *nav)
3740 IHTMLPluginsCollection *col, *col2;
3744 hres = IOmNavigator_get_plugins(nav, &col);
3745 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3747 hres = IOmNavigator_get_plugins(nav, &col2);
3748 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3749 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3750 IHTMLPluginsCollection_Release(col2);
3752 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3754 ref = IHTMLPluginsCollection_Release(col);
3755 ok(!ref, "ref=%d\n", ref);
3758 static void test_mime_types_col(IOmNavigator *nav)
3760 IHTMLMimeTypesCollection *col, *col2;
3765 hres = IOmNavigator_get_mimeTypes(nav, &col);
3766 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
3768 hres = IOmNavigator_get_mimeTypes(nav, &col2);
3769 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
3770 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3771 IHTMLMimeTypesCollection_Release(col2);
3773 test_disp((IUnknown*)col, &IID_IHTMLMimeTypesCollection, "[object]");
3775 length = 0xdeadbeef;
3776 hres = IHTMLMimeTypesCollection_get_length(col, &length);
3777 ok(hres == S_OK, "get_length failed: %08x\n", hres);
3778 ok(!length, "length = %d\n", length);
3780 ref = IHTMLMimeTypesCollection_Release(col);
3781 ok(!ref, "ref=%d\n", ref);
3784 static void test_navigator(IHTMLDocument2 *doc)
3786 IHTMLWindow2 *window;
3787 IOmNavigator *navigator, *navigator2;
3794 static const WCHAR v40[] = {'4','.','0'};
3796 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3797 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3799 hres = IHTMLWindow2_get_navigator(window, &navigator);
3800 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3801 ok(navigator != NULL, "navigator == NULL\n");
3802 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3804 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3805 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3806 ok(navigator != navigator2, "navigator2 != navihgator\n");
3808 IHTMLWindow2_Release(window);
3809 IOmNavigator_Release(navigator2);
3811 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3812 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3813 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3814 SysFreeString(bstr);
3817 hres = IOmNavigator_get_appName(navigator, &bstr);
3818 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3819 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3820 SysFreeString(bstr);
3823 hres = IOmNavigator_get_platform(navigator, &bstr);
3824 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3825 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "Win64" : "Win32")
3826 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3827 SysFreeString(bstr);
3830 hres = IOmNavigator_get_cpuClass(navigator, &bstr);
3831 ok(hres == S_OK, "get_cpuClass failed: %08x\n", hres);
3832 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr));
3833 SysFreeString(bstr);
3836 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3837 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3838 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3839 SysFreeString(bstr);
3841 hres = IOmNavigator_toString(navigator, NULL);
3842 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3845 hres = IOmNavigator_toString(navigator, &bstr);
3846 ok(hres == S_OK, "toString failed: %08x\n", hres);
3847 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3848 SysFreeString(bstr);
3851 hres = ObtainUserAgentString(0, buf, &size);
3852 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3855 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3856 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3857 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3858 SysFreeString(bstr);
3860 if(!strncmp(buf, "Mozilla/", 8)) {
3862 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3863 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3864 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3865 SysFreeString(bstr);
3867 skip("nonstandard user agent\n");
3870 test_plugins_col(navigator);
3871 test_mime_types_col(navigator);
3873 ref = IOmNavigator_Release(navigator);
3874 ok(!ref, "navigator should be destroyed here\n");
3877 static void test_screen(IHTMLWindow2 *window)
3879 IHTMLScreen *screen, *screen2;
3880 IDispatchEx *dispex;
3887 hres = IHTMLWindow2_get_screen(window, &screen);
3888 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3889 ok(screen != NULL, "screen == NULL\n");
3892 hres = IHTMLWindow2_get_screen(window, &screen2);
3893 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3894 ok(screen2 != NULL, "screen == NULL\n");
3895 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3896 IHTMLScreen_Release(screen2);
3898 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3899 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3900 if(SUCCEEDED(hres)) {
3901 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3902 IDispatchEx_Release(dispex);
3905 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3907 exl = GetDeviceCaps(hdc, HORZRES);
3909 hres = IHTMLScreen_get_width(screen, &l);
3910 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3911 ok(l == exl, "width = %d, expected %d\n", l, exl);
3913 exl = GetDeviceCaps(hdc, VERTRES);
3915 hres = IHTMLScreen_get_height(screen, &l);
3916 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3917 ok(l == exl, "height = %d, expected %d\n", l, exl);
3919 exl = GetDeviceCaps(hdc, BITSPIXEL);
3921 hres = IHTMLScreen_get_colorDepth(screen, &l);
3922 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3923 ok(l == exl, "height = %d, expected %d\n", l, exl);
3927 SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0);
3930 hres = IHTMLScreen_get_availHeight(screen, &l);
3931 ok(hres == S_OK, "get_availHeight failed: %08x\n", hres);
3932 ok(l == work_area.bottom-work_area.top, "availHeight = %d, expected %d\n", l, work_area.bottom-work_area.top);
3935 hres = IHTMLScreen_get_availWidth(screen, &l);
3936 ok(hres == S_OK, "get_availWidth failed: %08x\n", hres);
3937 ok(l == work_area.right-work_area.left, "availWidth = %d, expected %d\n", l, work_area.right-work_area.left);
3939 IHTMLScreen_Release(screen);
3942 static void test_default_selection(IHTMLDocument2 *doc)
3944 IHTMLSelectionObject *selection;
3945 IHTMLTxtRange *range;
3950 hres = IHTMLDocument2_get_selection(doc, &selection);
3951 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
3953 hres = IHTMLSelectionObject_get_type(selection, &str);
3954 ok(hres == S_OK, "get_type failed: %08x\n", hres);
3955 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
3958 hres = IHTMLSelectionObject_createRange(selection, &disp);
3959 IHTMLSelectionObject_Release(selection);
3960 ok(hres == S_OK, "createRange failed: %08x\n", hres);
3962 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
3963 IDispatch_Release(disp);
3964 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
3966 test_range_text(range, NULL);
3967 IHTMLTxtRange_Release(range);
3970 static void test_doc_elem(IHTMLDocument2 *doc)
3972 IHTMLDocument2 *doc_node, *owner_doc;
3974 IHTMLDocument3 *doc3;
3977 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3978 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
3980 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
3981 IHTMLDocument3_Release(doc3);
3982 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
3984 test_node_name((IUnknown*)elem, "HTML");
3985 test_elem_tag((IUnknown*)elem, "HTML");
3987 doc_node = get_doc_node(doc);
3988 owner_doc = get_owner_doc((IUnknown*)elem);
3989 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
3990 IHTMLDocument2_Release(owner_doc);
3992 owner_doc = get_owner_doc((IUnknown*)doc_node);
3993 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
3994 IHTMLDocument2_Release(doc_node);
3996 test_elem_client_rect((IUnknown*)elem);
3998 IHTMLElement_Release(elem);
4001 static void test_default_body(IHTMLBodyElement *body)
4008 bstr = (void*)0xdeadbeef;
4009 hres = IHTMLBodyElement_get_background(body, &bstr);
4010 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4011 ok(bstr == NULL, "bstr != NULL\n");
4013 l = elem_get_scroll_height((IUnknown*)body);
4014 ok(l != -1, "scrollHeight == -1\n");
4015 l = elem_get_scroll_width((IUnknown*)body);
4016 ok(l != -1, "scrollWidth == -1\n");
4017 l = elem_get_scroll_top((IUnknown*)body);
4018 ok(!l, "scrollTop = %d\n", l);
4019 elem_get_scroll_left((IUnknown*)body);
4021 /* get_text tests */
4022 hres = IHTMLBodyElement_get_text(body, &v);
4023 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4024 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4025 ok(bstr == NULL, "bstr != NULL\n");
4027 /* get_text - Invalid Text */
4029 V_BSTR(&v) = a2bstr("Invalid");
4030 hres = IHTMLBodyElement_put_text(body, v);
4031 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4035 hres = IHTMLBodyElement_get_text(body, &v);
4036 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4037 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4038 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
4041 /* get_text - Valid Text */
4043 V_BSTR(&v) = a2bstr("#FF0000");
4044 hres = IHTMLBodyElement_put_text(body, v);
4045 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4049 hres = IHTMLBodyElement_get_text(body, &v);
4050 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4051 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4052 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
4056 static void test_body_funs(IHTMLBodyElement *body)
4058 VARIANT vbg, vDefaultbg;
4061 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4062 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4063 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4064 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
4066 V_VT(&vbg) = VT_BSTR;
4067 V_BSTR(&vbg) = a2bstr("red");
4068 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4069 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4072 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4073 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4074 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4075 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4078 /* Restore Originial */
4079 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4080 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4081 VariantClear(&vDefaultbg);
4084 static void test_window(IHTMLDocument2 *doc)
4086 IHTMLWindow2 *window, *window2, *self;
4087 IHTMLDocument2 *doc2 = NULL;
4093 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4094 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4095 test_ifaces((IUnknown*)window, window_iids);
4096 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4098 hres = IHTMLWindow2_get_document(window, &doc2);
4099 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4100 ok(doc2 != NULL, "doc2 == NULL\n");
4102 test_ifaces((IUnknown*)doc2, doc_node_iids);
4103 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4104 test_class_info((IUnknown*)doc2);
4106 test_ifaces((IUnknown*)doc, doc_obj_iids);
4107 test_disp((IUnknown*)doc, &DIID_DispHTMLDocument, "[object]");
4108 test_class_info((IUnknown*)doc);
4110 unk = (void*)0xdeadbeef;
4111 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4112 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4113 ok(!unk, "unk = %p\n", unk);
4115 IHTMLDocument_Release(doc2);
4117 hres = IHTMLWindow2_get_window(window, &window2);
4118 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4119 ok(window2 != NULL, "window2 == NULL\n");
4121 hres = IHTMLWindow2_get_self(window, &self);
4122 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4123 ok(window2 != NULL, "self == NULL\n");
4125 ok(self == window2, "self != window2\n");
4127 IHTMLWindow2_Release(window2);
4128 IHTMLWindow2_Release(self);
4131 hres = IHTMLDocument2_get_Script(doc, &disp);
4132 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4133 ok(disp == (void*)window, "disp != window\n");
4134 IDispatch_Release(disp);
4136 hres = IHTMLWindow2_toString(window, NULL);
4137 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4140 hres = IHTMLWindow2_toString(window, &str);
4141 ok(hres == S_OK, "toString failed: %08x\n", hres);
4142 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4145 test_window_name(window, NULL);
4146 set_window_name(window, "test");
4147 test_window_length(window, 0);
4148 test_screen(window);
4150 IHTMLWindow2_Release(window);
4153 static void test_defaults(IHTMLDocument2 *doc)
4155 IHTMLStyleSheetsCollection *stylesheetcol;
4156 IHTMLCurrentStyle *cstyle;
4157 IHTMLBodyElement *body;
4158 IHTMLElement2 *elem2;
4163 IHTMLElementCollection *collection;
4165 elem = doc_get_body(doc);
4167 hres = IHTMLDocument2_get_images(doc, NULL);
4168 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4170 hres = IHTMLDocument2_get_images(doc, &collection);
4171 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4174 test_elem_collection((IUnknown*)collection, NULL, 0);
4175 IHTMLElementCollection_Release(collection);
4178 hres = IHTMLDocument2_get_applets(doc, NULL);
4179 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4181 hres = IHTMLDocument2_get_applets(doc, &collection);
4182 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4185 test_elem_collection((IUnknown*)collection, NULL, 0);
4186 IHTMLElementCollection_Release(collection);
4189 hres = IHTMLDocument2_get_links(doc, NULL);
4190 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4192 hres = IHTMLDocument2_get_links(doc, &collection);
4193 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4196 test_elem_collection((IUnknown*)collection, NULL, 0);
4197 IHTMLElementCollection_Release(collection);
4200 hres = IHTMLDocument2_get_forms(doc, NULL);
4201 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4203 hres = IHTMLDocument2_get_forms(doc, &collection);
4204 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4207 test_elem_collection((IUnknown*)collection, NULL, 0);
4208 IHTMLElementCollection_Release(collection);
4211 hres = IHTMLDocument2_get_anchors(doc, NULL);
4212 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4214 hres = IHTMLDocument2_get_anchors(doc, &collection);
4215 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4218 test_elem_collection((IUnknown*)collection, NULL, 0);
4219 IHTMLElementCollection_Release(collection);
4222 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4223 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4224 test_default_body(body);
4225 test_body_funs(body);
4226 IHTMLBodyElement_Release(body);
4228 hres = IHTMLElement_get_style(elem, &style);
4229 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4231 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4232 test_ifaces((IUnknown*)style, style_iids);
4233 IHTMLStyle_Release(style);
4236 test_compatmode(doc);
4238 test_navigator(doc);
4240 elem2 = get_elem2_iface((IUnknown*)elem);
4241 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4242 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4243 if(SUCCEEDED(hres)) {
4244 test_disp((IUnknown*)cstyle, &DIID_DispHTMLCurrentStyle, "[object]");
4245 test_ifaces((IUnknown*)cstyle, cstyle_iids);
4246 IHTMLCurrentStyle_Release(cstyle);
4248 IHTMLElement2_Release(elem2);
4250 IHTMLElement_Release(elem);
4252 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4253 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4256 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4257 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4258 ok(l == 0, "length = %d\n", l);
4260 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4262 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
4263 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
4265 test_default_selection(doc);
4266 test_doc_title(doc, "");
4269 static void test_tr_elem(IHTMLElement *elem)
4271 IHTMLElementCollection *col;
4275 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4277 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4278 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4283 hres = IHTMLTableRow_get_cells(row, &col);
4284 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4285 ok(col != NULL, "get_cells returned NULL\n");
4287 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4288 IHTMLElementCollection_Release(col);
4290 IHTMLTable_Release(row);
4293 static void test_table_elem(IHTMLElement *elem)
4295 IHTMLElementCollection *col;
4300 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4301 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4303 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4304 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4309 hres = IHTMLTable_get_rows(table, &col);
4310 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4311 ok(col != NULL, "get_ros returned NULL\n");
4313 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4314 IHTMLElementCollection_Release(col);
4316 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4318 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4319 test_elem_tag((IUnknown*)node, "TABLE");
4320 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4321 IHTMLDOMNode_Release(node);
4323 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4324 test_elem_tag((IUnknown*)node, "TABLE");
4325 test_elem_all((IUnknown*)node, NULL, 0);
4326 IHTMLDOMNode_Release(node);
4328 IHTMLTable_Release(table);
4331 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4340 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4341 SafeArrayAccessData(sa, (void**)&var);
4342 V_VT(var) = VT_BSTR;
4343 V_BSTR(var) = a2bstr(text);
4344 SafeArrayUnaccessData(sa);
4347 hres = IHTMLDocument2_writeln(doc, sa);
4349 hres = IHTMLDocument2_write(doc, sa);
4350 ok(hres == S_OK, "write failed: %08x\n", hres);
4352 SafeArrayDestroy(sa);
4355 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
4357 IHTMLDocument2 *window_doc, *elem_doc;
4358 IHTMLFrameElement3 *frame_elem3;
4359 IHTMLWindow2 *content_window;
4362 content_window = get_frame_content_window(frame_elem);
4363 window_doc = get_window_doc(content_window);
4364 IHTMLWindow2_Release(content_window);
4366 elem_doc = get_elem_doc(frame_elem);
4367 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
4370 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
4371 if(SUCCEEDED(hres)) {
4372 IDispatch *disp = NULL;
4374 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
4375 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
4376 ok(disp != NULL, "contentDocument == NULL\n");
4377 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
4379 IDispatch_Release(disp);
4380 IHTMLFrameElement3_Release(frame_elem3);
4382 win_skip("IHTMLFrameElement3 not supported\n");
4386 IHTMLDocument2_Release(elem_doc);
4387 IHTMLDocument2_Release(window_doc);
4390 static void test_iframe_elem(IHTMLElement *elem)
4392 IHTMLDocument2 *content_doc, *owner_doc;
4393 IHTMLElementCollection *col;
4394 IHTMLWindow2 *content_window;
4400 static const elem_type_t all_types[] = {
4408 test_frame_doc((IUnknown*)elem, TRUE);
4410 content_window = get_frame_content_window((IUnknown*)elem);
4411 test_window_length(content_window, 0);
4413 content_doc = get_window_doc(content_window);
4414 IHTMLWindow2_Release(content_window);
4416 str = a2bstr("text/html");
4417 V_VT(&errv) = VT_ERROR;
4419 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4421 ok(hres == S_OK, "open failed: %08x\n", hres);
4422 ok(disp != NULL, "disp == NULL\n");
4423 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4424 IDispatch_Release(disp);
4426 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4427 doc_write(content_doc, TRUE, "</html>");
4429 hres = IHTMLDocument2_get_all(content_doc, &col);
4430 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4431 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4432 IHTMLElementCollection_Release(col);
4434 hres = IHTMLDocument2_close(content_doc);
4435 ok(hres == S_OK, "close failed: %08x\n", hres);
4437 owner_doc = get_owner_doc((IUnknown*)content_doc);
4438 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4440 IHTMLDocument2_Release(content_doc);
4443 static void test_stylesheet(IDispatch *disp)
4445 IHTMLStyleSheetRulesCollection *col = NULL;
4446 IHTMLStyleSheet *stylesheet;
4449 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4450 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4452 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4453 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4454 ok(col != NULL, "col == NULL\n");
4456 IHTMLStyleSheetRulesCollection_Release(col);
4457 IHTMLStyleSheet_Release(stylesheet);
4460 static void test_stylesheets(IHTMLDocument2 *doc)
4462 IHTMLStyleSheetsCollection *col = NULL;
4467 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4468 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4469 ok(col != NULL, "col == NULL\n");
4471 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
4473 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4474 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4475 ok(len == 1, "len=%d\n", len);
4481 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4482 ok(hres == S_OK, "item failed: %08x\n", hres);
4483 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4484 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4485 test_stylesheet(V_DISPATCH(&res));
4492 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4493 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4494 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4495 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4498 IHTMLStyleSheetsCollection_Release(col);
4501 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4503 IDispatchEx *dispex;
4505 DISPPARAMS dp = {NULL, NULL, 0, 0};
4513 static const WCHAR w0[] = {'0',0};
4514 static const WCHAR w100[] = {'1','0','0',0};
4516 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4517 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4519 bstr = SysAllocString(w0);
4520 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4521 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4522 SysFreeString(bstr);
4525 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4526 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4527 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4528 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4529 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4530 type = get_node_type((IUnknown*)node);
4531 ok(type == 3, "type=%d\n", type);
4532 IHTMLDOMNode_Release(node);
4535 bstr = SysAllocString(w100);
4536 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4537 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4538 SysFreeString(bstr);
4540 IDispatchEx_Release(dispex);
4545 static void test_elems(IHTMLDocument2 *doc)
4547 IHTMLElementCollection *col;
4548 IHTMLDOMChildrenCollection *child_col;
4549 IHTMLElement *elem, *elem2, *elem3;
4550 IHTMLDOMNode *node, *node2;
4551 IHTMLWindow2 *window;
4555 IHTMLElementCollection *collection;
4556 IHTMLDocument3 *doc3;
4559 static const elem_type_t all_types[] = {
4587 static const elem_type_t item_types[] = {
4593 hres = IHTMLDocument2_get_all(doc, &col);
4594 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4595 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4596 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4597 IHTMLElementCollection_Release(col);
4599 hres = IHTMLDocument2_get_images(doc, &collection);
4600 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4603 static const elem_type_t images_types[] = {ET_IMG};
4604 test_elem_collection((IUnknown*)collection, images_types, 1);
4606 IHTMLElementCollection_Release(collection);
4609 hres = IHTMLDocument2_get_links(doc, &collection);
4610 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4613 static const elem_type_t images_types[] = {ET_A};
4614 test_elem_collection((IUnknown*)collection, images_types, 1);
4616 IHTMLElementCollection_Release(collection);
4619 hres = IHTMLDocument2_get_anchors(doc, &collection);
4620 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4623 static const elem_type_t anchor_types[] = {ET_A};
4624 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4626 IHTMLElementCollection_Release(collection);
4629 elem = get_doc_elem(doc);
4630 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4631 IHTMLElement_Release(elem);
4633 get_elem_by_id(doc, "xxx", FALSE);
4634 elem = get_doc_elem_by_id(doc, "xxx");
4635 ok(!elem, "elem != NULL\n");
4637 elem = get_doc_elem_by_id(doc, "s");
4638 ok(elem != NULL, "elem == NULL\n");
4640 test_elem_type((IUnknown*)elem, ET_SELECT);
4641 test_elem_attr(elem, "xxx", NULL);
4642 test_elem_attr(elem, "id", "s");
4643 test_elem_class((IUnknown*)elem, NULL);
4644 test_elem_set_class((IUnknown*)elem, "cl");
4645 test_elem_set_class((IUnknown*)elem, NULL);
4646 test_elem_tabindex((IUnknown*)elem, 0);
4647 test_elem_set_tabindex((IUnknown*)elem, 1);
4648 test_elem_filters((IUnknown*)elem);
4650 node = test_node_get_parent((IUnknown*)elem);
4651 ok(node != NULL, "node == NULL\n");
4652 test_node_name((IUnknown*)node, "BODY");
4653 node2 = test_node_get_parent((IUnknown*)node);
4654 IHTMLDOMNode_Release(node);
4655 ok(node2 != NULL, "node == NULL\n");
4656 test_node_name((IUnknown*)node2, "HTML");
4657 node = test_node_get_parent((IUnknown*)node2);
4658 IHTMLDOMNode_Release(node2);
4659 ok(node != NULL, "node == NULL\n");
4662 test_node_name((IUnknown*)node, "#document");
4663 type = get_node_type((IUnknown*)node);
4664 ok(type == 9, "type=%d, expected 9\n", type);
4665 node2 = test_node_get_parent((IUnknown*)node);
4666 IHTMLDOMNode_Release(node);
4667 ok(node2 == NULL, "node != NULL\n");
4670 elem2 = test_elem_get_parent((IUnknown*)elem);
4671 ok(elem2 != NULL, "elem2 == NULL\n");
4672 test_node_name((IUnknown*)elem2, "BODY");
4673 elem3 = test_elem_get_parent((IUnknown*)elem2);
4674 IHTMLElement_Release(elem2);
4675 ok(elem3 != NULL, "elem3 == NULL\n");
4676 test_node_name((IUnknown*)elem3, "HTML");
4677 elem2 = test_elem_get_parent((IUnknown*)elem3);
4678 IHTMLElement_Release(elem3);
4679 ok(elem2 == NULL, "elem2 != NULL\n");
4681 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4682 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4683 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4685 test_elem_innertext(elem, "opt1opt2");
4687 IHTMLElement_Release(elem);
4690 elem = get_elem_by_id(doc, "s", TRUE);
4692 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
4693 IHTMLDocument2 *doc_node, *elem_doc;
4695 test_select_elem(select);
4697 test_elem_title((IUnknown*)select, NULL);
4698 test_elem_set_title((IUnknown*)select, "Title");
4699 test_elem_title((IUnknown*)select, "Title");
4700 test_elem_offset((IUnknown*)select, "BODY");
4701 test_elem_bounding_client_rect((IUnknown*)select);
4703 node = get_first_child((IUnknown*)select);
4704 ok(node != NULL, "node == NULL\n");
4706 test_elem_type((IUnknown*)node, ET_OPTION);
4707 IHTMLDOMNode_Release(node);
4710 type = get_node_type((IUnknown*)select);
4711 ok(type == 1, "type=%d\n", type);
4713 IHTMLSelectElement_Release(select);
4715 elem_doc = get_elem_doc((IUnknown*)elem);
4717 doc_node = get_doc_node(doc);
4718 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
4719 IHTMLDocument2_Release(doc_node);
4720 IHTMLDocument2_Release(elem_doc);
4722 IHTMLElement_Release(elem);
4725 elem = get_elem_by_id(doc, "sc", TRUE);
4727 IHTMLScriptElement *script;
4730 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4731 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4737 hres = IHTMLScriptElement_put_type (script, NULL);
4738 ok(hres == S_OK, "put_type failed: %08x\n", hres);
4739 hres = IHTMLScriptElement_get_type(script, &type);
4740 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4741 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
4743 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
4744 ok(hres == S_OK, "put_type failed: %08x\n", hres);
4745 hres = IHTMLScriptElement_get_type(script, &type);
4746 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4747 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4749 SysFreeString(type);
4752 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4753 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4755 hres = IHTMLScriptElement_get_defer(script, &vb);
4756 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4757 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4759 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4760 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4762 str = (BSTR)0xdeadbeef;
4763 hres = IHTMLScriptElement_get_src(script, &str);
4764 ok(hres == S_OK, "get_src failed: %08x\n", hres);
4765 ok(!str, "src = %s\n", wine_dbgstr_w(str));
4768 IHTMLScriptElement_Release(script);
4771 elem = get_elem_by_id(doc, "in", TRUE);
4773 IHTMLInputElement *input;
4775 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4776 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4778 test_elem_id((IUnknown*)elem, "in");
4779 test_elem_put_id((IUnknown*)elem, "newin");
4780 test_input_get_disabled(input, VARIANT_FALSE);
4781 test_input_set_disabled(input, VARIANT_TRUE);
4782 test_input_set_disabled(input, VARIANT_FALSE);
4783 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4784 test_input_get_disabled(input, VARIANT_TRUE);
4785 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4786 test_input_get_disabled(input, VARIANT_FALSE);
4787 test_elem_client_size((IUnknown*)elem);
4788 test_input_type(input, "text");
4790 test_node_get_value_str((IUnknown*)elem, NULL);
4791 test_node_put_value_str((IUnknown*)elem, "test");
4792 test_node_get_value_str((IUnknown*)elem, NULL);
4793 test_input_value((IUnknown*)elem, NULL);
4794 test_input_put_value((IUnknown*)elem, "test");
4795 test_elem_class((IUnknown*)elem, "testclass");
4796 test_elem_tabindex((IUnknown*)elem, 2);
4797 test_elem_set_tabindex((IUnknown*)elem, 3);
4798 test_elem_title((IUnknown*)elem, "test title");
4800 test_input_get_defaultchecked(input, VARIANT_FALSE);
4801 test_input_set_defaultchecked(input, VARIANT_TRUE);
4802 test_input_set_defaultchecked(input, VARIANT_FALSE);
4804 test_input_get_checked(input, VARIANT_FALSE);
4805 test_input_set_checked(input, VARIANT_TRUE);
4806 test_input_set_checked(input, VARIANT_FALSE);
4808 test_input_name(input, NULL);
4809 test_input_set_name(input, "test");
4811 test_input_src(input, NULL);
4812 test_input_set_src(input, "about:blank");
4814 IHTMLInputElement_Release(input);
4815 IHTMLElement_Release(elem);
4818 elem = get_elem_by_id(doc, "imgid", TRUE);
4820 test_img_src((IUnknown*)elem, "", NULL);
4821 test_img_set_src((IUnknown*)elem, "about:blank");
4822 test_img_src((IUnknown*)elem, "about:blank", NULL);
4823 test_img_alt((IUnknown*)elem, NULL);
4824 test_img_set_alt((IUnknown*)elem, "alt test");
4825 test_img_name((IUnknown*)elem, "WineImg");
4826 IHTMLElement_Release(elem);
4829 elem = get_elem_by_id(doc, "styleid", TRUE);
4831 test_style_media((IUnknown*)elem, NULL);
4832 test_style_put_media((IUnknown*)elem, "screen");
4833 test_style_type((IUnknown*)elem, NULL);
4834 test_style_put_type((IUnknown*)elem, "text/css");
4835 IHTMLElement_Release(elem);
4838 elem = get_doc_elem_by_id(doc, "tbl");
4839 ok(elem != NULL, "elem == NULL\n");
4841 test_table_elem(elem);
4842 IHTMLElement_Release(elem);
4845 elem = get_doc_elem_by_id(doc, "row2");
4846 ok(elem != NULL, "elem == NULL\n");
4849 IHTMLElement_Release(elem);
4852 elem = get_doc_elem_by_id(doc, "ifr");
4853 ok(elem != NULL, "elem == NULL\n");
4855 test_iframe_elem(elem);
4856 IHTMLElement_Release(elem);
4859 elem = get_doc_elem_by_id(doc, "objid");
4860 ok(elem != NULL, "elem == NULL\n");
4862 test_object_vspace((IUnknown*)elem, 100);
4863 IHTMLElement_Release(elem);
4866 elem = get_elem_by_id(doc, "a", TRUE);
4868 test_anchor_href((IUnknown*)elem, "http://test/");
4870 /* Change the href */
4871 test_anchor_put_href((IUnknown*)elem, "http://test1/");
4872 test_anchor_href((IUnknown*)elem, "http://test1/");
4874 /* Restore the href */
4875 test_anchor_put_href((IUnknown*)elem, "http://test/");
4876 test_anchor_href((IUnknown*)elem, "http://test/");
4879 test_anchor_get_target((IUnknown*)elem, NULL);
4881 /* Change the target */
4882 test_anchor_put_target((IUnknown*)elem, "wine");
4883 test_anchor_get_target((IUnknown*)elem, "wine");
4885 /* Restore the target */
4886 test_anchor_put_target((IUnknown*)elem, NULL);
4887 test_anchor_get_target((IUnknown*)elem, NULL);
4889 IHTMLElement_Release(elem);
4892 elem = doc_get_body(doc);
4894 node = get_first_child((IUnknown*)elem);
4895 ok(node != NULL, "node == NULL\n");
4897 test_ifaces((IUnknown*)node, text_iids);
4898 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
4900 node2 = get_first_child((IUnknown*)node);
4901 ok(!node2, "node2 != NULL\n");
4903 type = get_node_type((IUnknown*)node);
4904 ok(type == 3, "type=%d\n", type);
4906 test_node_get_value_str((IUnknown*)node, "text test");
4907 test_node_put_value_str((IUnknown*)elem, "test text");
4908 test_node_get_value_str((IUnknown*)node, "text test");
4910 IHTMLDOMNode_Release(node);
4913 child_col = get_child_nodes((IUnknown*)elem);
4914 ok(child_col != NULL, "child_coll == NULL\n");
4918 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
4920 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
4921 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4922 ok(length, "length=0\n");
4925 node = get_child_item(child_col, 0);
4926 ok(node != NULL, "node == NULL\n");
4930 type = get_node_type((IUnknown*)node);
4931 ok(type == 3, "type=%d\n", type);
4932 node2 = node_get_next((IUnknown*)node);
4934 prev = node_get_prev((IUnknown*)node2);
4935 ok(iface_cmp((IUnknown*)node, (IUnknown*)prev), "node != prev\n");
4936 IHTMLDOMNode_Release(prev);
4938 IHTMLDOMNode_Release(node);
4941 node = get_child_item(child_col, 1);
4942 ok(node != NULL, "node == NULL\n");
4944 type = get_node_type((IUnknown*)node);
4945 ok(type == 8, "type=%d\n", type);
4947 test_elem_id((IUnknown*)node, NULL);
4948 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
4949 IHTMLDOMNode_Release(node2);
4950 IHTMLDOMNode_Release(node);
4953 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
4954 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4956 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
4957 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4959 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
4960 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4962 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
4963 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4965 test_child_col_disp(child_col);
4967 IHTMLDOMChildrenCollection_Release(child_col);
4970 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
4971 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
4972 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
4974 IHTMLElement_Release(elem);
4976 elem = get_doc_elem_by_id(doc, "frm");
4977 ok(elem != NULL, "elem == NULL\n");
4979 test_form_length((IUnknown*)elem, 0);
4980 test_form_elements((IUnknown*)elem);
4981 IHTMLElement_Release(elem);
4984 test_stylesheets(doc);
4985 test_create_option_elem(doc);
4986 test_create_img_elem(doc);
4988 elem = get_doc_elem_by_id(doc, "tbl");
4989 ok(elem != NULL, "elem = NULL\n");
4990 test_elem_set_innertext(elem, "inner text");
4991 IHTMLElement_Release(elem);
4993 test_doc_title(doc, "test");
4994 test_doc_set_title(doc, "test title");
4995 test_doc_title(doc, "test title");
4998 hres = IHTMLDocument2_get_Script(doc, &disp);
4999 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5002 IDispatchEx *dispex;
5003 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5004 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5008 BSTR str = a2bstr("Testing");
5009 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5010 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5011 ok(pid != -1, "pid == -1\n");
5013 IDispatchEx_Release(dispex);
5016 IDispatch_Release(disp);
5018 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5019 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5021 str = a2bstr("img");
5022 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5023 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5027 static const elem_type_t img_types[] = { ET_IMG };
5029 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5030 IHTMLElementCollection_Release(col);
5033 elem = get_doc_elem_by_id(doc, "y");
5034 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5035 test_elem_innerhtml((IUnknown*)elem, "inner html");
5036 test_elem_set_innerhtml((IUnknown*)elem, "");
5037 test_elem_innerhtml((IUnknown*)elem, NULL);
5038 node = node_get_next((IUnknown*)elem);
5039 ok(!node, "node = %p\n", node);
5041 elem2 = get_doc_elem_by_id(doc, "x");
5042 test_elem_tag((IUnknown*)elem2, "A");
5043 node = node_get_next((IUnknown*)elem2);
5044 IHTMLDOMNode_Release(node);
5045 IHTMLElement_Release(elem2);
5046 IHTMLElement_Release(elem);
5048 IHTMLDocument3_Release(doc3);
5050 elem = get_elem_by_id(doc, "s", TRUE);
5052 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
5054 test_select_put_length((IUnknown*)elem, 3);
5055 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
5056 test_select_put_length((IUnknown*)elem, 1);
5057 test_elem_all((IUnknown*)elem, select_types, 1);
5058 IHTMLElement_Release(elem);
5061 window = get_doc_window(doc);
5062 test_window_name(window, NULL);
5063 set_window_name(window, "test name");
5064 test_window_length(window, 1);
5065 IHTMLWindow2_Release(window);
5068 static void test_attr(IHTMLElement *elem)
5070 IHTMLDOMAttribute *attr, *attr2;
5073 get_elem_attr_node((IUnknown*)elem, "noattr", FALSE);
5075 attr = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
5077 test_disp((IUnknown*)attr, &DIID_DispHTMLDOMAttribute, "[object]");
5078 test_ifaces((IUnknown*)attr, attr_iids);
5079 test_no_iface((IUnknown*)attr, &IID_IHTMLDOMNode);
5081 attr2 = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
5082 ok(iface_cmp((IUnknown*)attr, (IUnknown*)attr2), "attr != attr2\n");
5083 IHTMLDOMAttribute_Release(attr2);
5085 get_attr_node_value(attr, &v, VT_BSTR);
5086 ok(!strcmp_wa(V_BSTR(&v), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5089 IHTMLDOMAttribute_Release(attr);
5091 attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
5092 get_attr_node_value(attr, &v, VT_BSTR);
5093 ok(!V_BSTR(&v), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5095 IHTMLDOMAttribute_Release(attr);
5099 set_dispex_value((IUnknown*)elem, "dispprop", &v);
5100 attr = get_elem_attr_node((IUnknown*)elem, "dispprop", TRUE);
5101 get_attr_node_value(attr, &v, VT_I4);
5102 ok(V_I4(&v) == 100, "V_I4(v) = %d\n", V_I4(&v));
5103 IHTMLDOMAttribute_Release(attr);
5106 static void test_blocked(IHTMLDocument2 *doc, IHTMLElement *outer_elem)
5110 test_elem_set_innerhtml((IUnknown*)outer_elem,
5111 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
5112 elem = get_elem_by_id(doc, "imgid", TRUE);
5114 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5115 IHTMLElement_Release(elem);
5118 test_elem_set_innerhtml((IUnknown*)outer_elem,
5119 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
5120 elem = get_elem_by_id(doc, "imgid", TRUE);
5122 test_img_src((IUnknown*)elem, "blocke::http://www.winehq.org/img.png", NULL);
5123 test_img_set_src((IUnknown*)elem, "BLOCKED:http://www.winehq.org/img.png");
5124 test_img_src((IUnknown*)elem, "blocked:http://www.winehq.org/img.png", NULL);
5125 test_img_set_src((IUnknown*)elem, "blocked::http://www.winehq.org/img.png");
5126 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5127 IHTMLElement_Release(elem);
5131 static void test_elems2(IHTMLDocument2 *doc)
5133 IHTMLElement *elem, *elem2, *div;
5135 static const elem_type_t outer_types[] = {
5140 div = get_doc_elem_by_id(doc, "divid");
5142 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
5143 elem2 = get_doc_elem_by_id(doc, "innerid");
5144 ok(elem2 != NULL, "elem2 == NULL\n");
5145 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5146 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5147 IHTMLElement_Release(elem2);
5149 elem2 = get_doc_elem_by_id(doc, "aid");
5150 ok(elem2 != NULL, "elem2 == NULL\n");
5151 test_elem_set_outerhtml((IUnknown*)elem2, "");
5152 test_elem_all((IUnknown*)div, outer_types, 1);
5153 IHTMLElement_Release(elem2);
5155 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
5156 elem = get_elem_by_id(doc, "ta", TRUE);
5158 test_textarea_value((IUnknown*)elem, NULL);
5159 test_textarea_put_value((IUnknown*)elem, "test");
5160 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
5161 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
5162 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
5163 test_textarea_type((IUnknown*)elem);
5164 IHTMLElement_Release(elem);
5167 test_elem_set_innerhtml((IUnknown*)div,
5168 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" /></div></textarea>");
5169 elem = get_elem_by_id(doc, "form", TRUE);
5171 test_form_length((IUnknown*)elem, 2);
5172 test_form_item(elem);
5173 test_form_action((IUnknown*)elem, NULL);
5174 test_form_put_action((IUnknown*)elem, "about:blank");
5175 test_form_method((IUnknown*)elem, "get");
5176 test_form_put_method((IUnknown*)elem, S_OK, "post");
5177 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
5178 test_form_method((IUnknown*)elem, "post");
5179 test_form_name((IUnknown*)elem, NULL);
5180 test_form_put_name((IUnknown*)elem, "Name");
5181 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
5182 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
5183 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
5184 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
5185 test_form_encoding((IUnknown*)elem, "multipart/form-data");
5186 test_form_elements((IUnknown*)elem);
5187 IHTMLElement_Release(elem);
5191 test_blocked(doc, div);
5193 IHTMLElement_Release(div);
5196 static void test_create_elems(IHTMLDocument2 *doc)
5198 IHTMLElement *elem, *body, *elem2;
5199 IHTMLDOMNode *node, *node2, *node3, *comment;
5200 IHTMLDocument5 *doc5;
5207 static const elem_type_t types1[] = { ET_TESTG };
5209 elem = test_create_elem(doc, "TEST");
5210 test_elem_tag((IUnknown*)elem, "TEST");
5211 type = get_node_type((IUnknown*)elem);
5212 ok(type == 1, "type=%d\n", type);
5213 test_ifaces((IUnknown*)elem, elem_iids);
5214 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5216 body = doc_get_body(doc);
5217 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5219 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5220 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5221 elem2 = get_elem_iface((IUnknown*)node);
5222 IHTMLElement_Release(elem2);
5224 hres = IHTMLElement_get_all(body, &disp);
5225 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5226 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5227 IDispatch_Release(disp);
5229 test_node_remove_child((IUnknown*)body, node);
5231 hres = IHTMLElement_get_all(body, &disp);
5232 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5233 test_elem_collection((IUnknown*)disp, NULL, 0);
5234 IDispatch_Release(disp);
5235 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5237 IHTMLElement_Release(elem);
5238 IHTMLDOMNode_Release(node);
5240 node = test_create_text(doc, "test");
5241 test_ifaces((IUnknown*)node, text_iids);
5242 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5243 test_text_length((IUnknown*)node, 4);
5245 V_VT(&var) = VT_NULL;
5246 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5247 IHTMLDOMNode_Release(node);
5249 node = test_create_text(doc, "insert ");
5251 V_VT(&var) = VT_DISPATCH;
5252 V_DISPATCH(&var) = (IDispatch*)node2;
5253 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5254 IHTMLDOMNode_Release(node);
5255 IHTMLDOMNode_Release(node2);
5256 IHTMLDOMNode_Release(node3);
5258 test_elem_innertext(body, "insert test");
5259 test_elem_innerhtml((IUnknown*)body, "insert test");
5261 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5264 str = a2bstr("testing");
5265 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5267 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5270 type = get_node_type((IUnknown*)comment);
5271 ok(type == 8, "type=%d, expected 8\n", type);
5273 test_node_get_value_str((IUnknown*)comment, "testing");
5274 test_elem_title((IUnknown*)comment, NULL);
5275 test_elem_set_title((IUnknown*)comment, "comment title");
5276 test_elem_title((IUnknown*)comment, "comment title");
5277 test_comment_text((IUnknown*)comment, "<!--testing-->");
5278 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
5280 IHTMLDOMNode_Release(comment);
5283 IHTMLDocument5_Release(doc5);
5286 IHTMLElement_Release(body);
5289 static void test_null_write(IHTMLDocument2 *doc)
5293 doc_write(doc, FALSE, NULL);
5294 doc_write(doc, TRUE, NULL);
5296 hres = IHTMLDocument2_write(doc, NULL);
5298 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
5300 hres = IHTMLDocument2_writeln(doc, NULL);
5302 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
5305 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5307 IOleCommandTarget *cmdtrg;
5310 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5311 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5313 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5314 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5316 IOleCommandTarget_Release(cmdtrg);
5319 static void test_indent(IHTMLDocument2 *doc)
5321 IHTMLElementCollection *col;
5322 IHTMLTxtRange *range;
5325 static const elem_type_t all_types[] = {
5334 static const elem_type_t indent_types[] = {
5345 hres = IHTMLDocument2_get_all(doc, &col);
5346 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5347 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5348 IHTMLElementCollection_Release(col);
5350 range = test_create_body_range(doc);
5351 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5352 IHTMLTxtRange_Release(range);
5354 hres = IHTMLDocument2_get_all(doc, &col);
5355 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5356 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5357 IHTMLElementCollection_Release(col);
5360 static void test_cond_comment(IHTMLDocument2 *doc)
5362 IHTMLElementCollection *col;
5365 static const elem_type_t all_types[] = {
5373 hres = IHTMLDocument2_get_all(doc, &col);
5374 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5375 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5376 IHTMLElementCollection_Release(col);
5379 static void test_frame(IDispatch *disp, const char *exp_id)
5381 IHTMLWindow2 *frame2, *parent, *top;
5382 IHTMLDocument2 *parent_doc, *top_doc;
5383 IHTMLWindow4 *frame;
5384 IHTMLFrameBase *frame_elem;
5387 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5388 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5392 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5393 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5394 IHTMLWindow4_Release(frame);
5398 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
5399 test_frame_doc((IUnknown*)frame_elem, FALSE);
5400 test_elem_id((IUnknown*)frame_elem, exp_id);
5401 IHTMLElement_Release(frame_elem);
5403 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5404 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5408 hres = IHTMLWindow2_get_parent(frame2, &parent);
5409 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5411 IHTMLWindow2_Release(frame2);
5415 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5416 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5417 IHTMLWindow2_Release(parent);
5419 IHTMLWindow2_Release(frame2);
5423 test_doc_title(parent_doc, "frameset test");
5424 IHTMLDocument2_Release(parent_doc);
5427 hres = IHTMLWindow2_get_top(frame2, &top);
5428 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5429 IHTMLWindow2_Release(frame2);
5433 hres = IHTMLWindow2_get_document(top, &top_doc);
5434 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5435 IHTMLWindow2_Release(top);
5439 test_doc_title(top_doc, "frameset test");
5440 IHTMLDocument2_Release(top_doc);
5443 static void test_frameset(IHTMLDocument2 *doc)
5445 IHTMLWindow2 *window;
5446 IHTMLFramesCollection2 *frames;
5448 IHTMLFrameBase *fbase;
5450 VARIANT index_var, result_var;
5454 window = get_doc_window(doc);
5456 /* test using IHTMLFramesCollection object */
5458 hres = IHTMLWindow2_get_frames(window, &frames);
5459 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5460 IHTMLWindow2_Release(window);
5464 /* test result length */
5465 hres = IHTMLFramesCollection2_get_length(frames, &length);
5466 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5467 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
5469 /* test first frame */
5470 V_VT(&index_var) = VT_I4;
5471 V_I4(&index_var) = 0;
5472 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5473 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5474 if(SUCCEEDED(hres)) {
5475 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5476 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5478 VariantClear(&result_var);
5480 /* test second frame */
5481 V_I4(&index_var) = 1;
5482 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5483 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5484 if(SUCCEEDED(hres)) {
5485 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5486 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5488 VariantClear(&result_var);
5490 /* fail on next frame */
5491 V_I4(&index_var) = 3;
5492 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5493 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5494 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5495 VariantClear(&result_var);
5497 /* string argument (element id lookup) */
5498 V_VT(&index_var) = VT_BSTR;
5499 V_BSTR(&index_var) = a2bstr("fr1");
5500 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5501 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5502 if(SUCCEEDED(hres)) {
5503 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5504 test_frame(V_DISPATCH(&result_var), "fr1");
5506 VariantClear(&result_var);
5507 VariantClear(&index_var);
5509 /* invalid argument */
5510 V_VT(&index_var) = VT_BOOL;
5511 V_BOOL(&index_var) = VARIANT_TRUE;
5512 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5513 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5514 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5515 VariantClear(&result_var);
5517 IHTMLFramesCollection2_Release(frames);
5519 /* test using IHTMLWindow2 inheritance */
5521 /* test result length */
5522 hres = IHTMLWindow2_get_length(window, &length);
5523 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5524 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
5526 /* test first frame */
5527 V_VT(&index_var) = VT_I4;
5528 V_I4(&index_var) = 0;
5529 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5530 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5531 if(SUCCEEDED(hres)) {
5532 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5533 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5535 VariantClear(&result_var);
5537 /* test second frame */
5538 V_I4(&index_var) = 1;
5539 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5540 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5541 if(SUCCEEDED(hres)) {
5542 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5543 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5545 VariantClear(&result_var);
5547 /* fail on next frame */
5548 V_I4(&index_var) = 3;
5549 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5550 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5551 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5552 VariantClear(&result_var);
5554 /* string argument (element id lookup) */
5555 V_VT(&index_var) = VT_BSTR;
5556 V_BSTR(&index_var) = a2bstr("fr2");
5557 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5558 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5559 if(SUCCEEDED(hres)) {
5560 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5561 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5563 VariantClear(&result_var);
5564 VariantClear(&index_var);
5566 /* invalid argument */
5567 V_VT(&index_var) = VT_BOOL;
5568 V_BOOL(&index_var) = VARIANT_TRUE;
5569 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5570 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5571 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5572 VariantClear(&result_var);
5574 /* getElementById with node name attributes */
5575 elem = get_doc_elem_by_id(doc, "nm1");
5576 test_elem_id((IUnknown*)elem, "fr1");
5578 /* get/put scrolling */
5579 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
5580 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
5582 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
5583 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
5584 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
5588 hres = IHTMLFrameBase_put_scrolling(fbase, str);
5589 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
5592 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
5593 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
5594 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
5597 str = a2bstr("junk");
5598 hres = IHTMLFrameBase_put_scrolling(fbase, str);
5599 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
5600 "with E_INVALIDARG, instead: 0x%08x\n", hres);
5603 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
5604 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
5605 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
5609 hres = IHTMLFrameBase_get_name(fbase, &str);
5610 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
5611 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
5614 IHTMLFrameBase_Release(fbase);
5615 IHTMLElement_Release(elem);
5617 /* get_name with no name attr */
5618 elem = get_doc_elem_by_id(doc, "fr3");
5619 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
5620 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
5622 hres = IHTMLFrameBase_get_name(fbase, &str);
5623 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
5624 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
5627 IHTMLFrameBase_Release(fbase);
5628 IHTMLElement_Release(elem);
5631 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
5633 IHTMLDocument2 *frag;
5634 IHTMLDocument3 *doc3;
5637 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5638 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
5640 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
5641 IHTMLDocument3_Release(doc3);
5642 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
5643 ok(frag != NULL, "frag == NULL\n");
5648 static void test_docfrag(IHTMLDocument2 *doc)
5650 IHTMLElement *div, *body, *br;
5651 IHTMLElementCollection *col;
5652 IHTMLLocation *location;
5653 IHTMLDocument2 *frag;
5656 static const elem_type_t all_types[] = {
5665 frag = create_docfrag(doc);
5667 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
5669 body = (void*)0xdeadbeef;
5670 hres = IHTMLDocument2_get_body(frag, &body);
5671 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5672 ok(!body, "body != NULL\n");
5674 location = (void*)0xdeadbeef;
5675 hres = IHTMLDocument2_get_location(frag, &location);
5676 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
5677 ok(location == (void*)0xdeadbeef, "location changed\n");
5679 br = test_create_elem(doc, "BR");
5680 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
5681 IHTMLElement_Release(br);
5683 div = get_elem_by_id(doc, "divid", TRUE);
5684 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
5685 IHTMLElement_Release(div);
5687 hres = IHTMLDocument2_get_all(doc, &col);
5688 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5689 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5690 IHTMLElementCollection_Release(col);
5692 IHTMLDocument2_Release(frag);
5695 static IHTMLDocument2 *notif_doc;
5696 static BOOL doc_complete;
5698 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5699 REFIID riid, void**ppv)
5701 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5706 ok(0, "unexpected call\n");
5707 return E_NOINTERFACE;
5710 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5715 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5720 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5722 if(dispID == DISPID_READYSTATE){
5726 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5727 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5729 if(!strcmp_wa(state, "complete"))
5730 doc_complete = TRUE;
5732 SysFreeString(state);
5738 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5740 ok(0, "unexpected call\n");
5744 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5745 PropertyNotifySink_QueryInterface,
5746 PropertyNotifySink_AddRef,
5747 PropertyNotifySink_Release,
5748 PropertyNotifySink_OnChanged,
5749 PropertyNotifySink_OnRequestEdit
5752 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5754 static IHTMLDocument2 *create_doc_with_string(const char *str)
5756 IPersistStreamInit *init;
5758 IHTMLDocument2 *doc;
5762 notif_doc = doc = create_document();
5766 doc_complete = FALSE;
5768 mem = GlobalAlloc(0, len);
5769 memcpy(mem, str, len);
5770 CreateStreamOnHGlobal(mem, TRUE, &stream);
5772 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5774 IPersistStreamInit_Load(init, stream);
5775 IPersistStreamInit_Release(init);
5776 IStream_Release(stream);
5781 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5783 IConnectionPointContainer *container;
5784 IConnectionPoint *cp;
5788 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5789 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5791 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5792 IConnectionPointContainer_Release(container);
5793 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5795 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5796 IConnectionPoint_Release(cp);
5797 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5800 typedef void (*domtest_t)(IHTMLDocument2*);
5802 static void run_domtest(const char *str, domtest_t test)
5804 IHTMLDocument2 *doc;
5808 doc = create_doc_with_string(str);
5812 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5814 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5815 TranslateMessage(&msg);
5816 DispatchMessage(&msg);
5821 ref = IHTMLDocument2_Release(doc);
5822 ok(!ref || broken(ref == 1), /* Vista */
5830 run_domtest(doc_str1, test_doc_elem);
5831 run_domtest(doc_str1, test_get_set_attr);
5832 run_domtest(range_test_str, test_txtrange);
5833 run_domtest(range_test2_str, test_txtrange2);
5834 if (winetest_interactive || ! is_ie_hardened()) {
5835 run_domtest(elem_test_str, test_elems);
5836 run_domtest(elem_test2_str, test_elems2);
5838 skip("IE running in Enhanced Security Configuration\n");
5840 run_domtest(doc_blank, test_create_elems);
5841 run_domtest(doc_blank, test_defaults);
5842 run_domtest(doc_blank, test_null_write);
5843 run_domtest(indent_test_str, test_indent);
5844 run_domtest(cond_comment_str, test_cond_comment);
5845 run_domtest(frameset_str, test_frameset);
5846 run_domtest(emptydiv_str, test_docfrag);