2 * Copyright 2007-2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
34 #include "mshtml_test.h"
39 static INT (WINAPI *pLCIDToLocaleName)(LCID,LPWSTR,INT,DWORD);
40 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void);
42 static const char doc_blank[] = "<html></html>";
43 static const char doc_str1[] = "<html><body>test</body></html>";
44 static const char range_test_str[] =
45 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
46 static const char range_test2_str[] =
47 "<html><body>abc<hr />123<br /><hr />def</body></html>";
48 static const char elem_test_str[] =
49 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
50 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
51 "<body onload=\"Testing()\">text test<!-- a comment -->"
52 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
53 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
54 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
55 "<textarea id=\"X\">text text</textarea>"
56 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
57 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
58 "<test /><object id=\"objid\" vspace=100></object><embed />"
59 "<img id=\"imgid\" name=\"WineImg\"/>"
60 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
61 "<form id=\"frm\"></form>"
62 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
64 static const char elem_test2_str[] =
65 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
66 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
69 static const char indent_test_str[] =
70 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
71 static const char cond_comment_str[] =
72 "<html><head><title>test</title></head><body>"
73 "<!--[if gte IE 4]> <br> <![endif]-->"
75 static const char frameset_str[] =
76 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
77 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
78 "<frame src=\"about:blank\" id=\"fr3\">"
80 static const char emptydiv_str[] =
81 "<html><head><title>emptydiv test</title></head>"
82 "<body><div id=\"divid\"></div></body></html>";
84 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
85 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
86 static WCHAR wordW[] = {'w','o','r','d',0};
121 static const IID * const none_iids[] = {
126 static const IID * const doc_node_iids[] = {
135 &IID_IConnectionPointContainer,
136 &IID_IInternetHostSecurityManager,
139 &IID_IProvideClassInfo,
143 static const IID * const doc_obj_iids[] = {
150 &IID_IConnectionPointContainer,
154 &IID_IProvideClassInfo,
155 &IID_ITargetContainer,
159 #define ELEM_IFACES \
161 &IID_IHTMLDOMNode2, \
163 &IID_IHTMLElement2, \
164 &IID_IHTMLElement3, \
165 &IID_IHTMLElement4, \
168 static const IID * const elem_iids[] = {
170 &IID_IConnectionPointContainer,
174 static const IID * const body_iids[] = {
176 &IID_IHTMLTextContainer,
177 &IID_IHTMLBodyElement,
178 &IID_IConnectionPointContainer,
182 static const IID * const anchor_iids[] = {
184 &IID_IHTMLAnchorElement,
185 &IID_IConnectionPointContainer,
189 static const IID * const input_iids[] = {
191 &IID_IHTMLInputElement,
192 &IID_IHTMLInputTextElement,
193 &IID_IConnectionPointContainer,
197 static const IID * const select_iids[] = {
199 &IID_IHTMLSelectElement,
200 &IID_IConnectionPointContainer,
204 static const IID * const textarea_iids[] = {
206 &IID_IHTMLTextAreaElement,
207 &IID_IConnectionPointContainer,
211 static const IID * const option_iids[] = {
213 &IID_IHTMLOptionElement,
214 &IID_IConnectionPointContainer,
218 static const IID * const table_iids[] = {
223 &IID_IConnectionPointContainer,
227 static const IID * const script_iids[] = {
229 &IID_IHTMLScriptElement,
230 &IID_IConnectionPointContainer,
234 static const IID * const text_iids[] = {
237 &IID_IHTMLDOMTextNode,
241 static const IID * const attr_iids[] = {
242 &IID_IHTMLDOMAttribute,
247 static const IID * const location_iids[] = {
253 static const IID * const window_iids[] = {
258 &IID_IServiceProvider,
262 static const IID * const comment_iids[] = {
264 &IID_IHTMLCommentElement,
265 &IID_IConnectionPointContainer,
269 static const IID * const img_iids[] = {
271 &IID_IHTMLImgElement,
272 &IID_IConnectionPointContainer,
276 static const IID * const tr_iids[] = {
279 &IID_IConnectionPointContainer,
283 static const IID * const td_iids[] = {
286 &IID_IConnectionPointContainer,
290 static const IID * const frame_iids[] = {
293 &IID_IHTMLFrameBase2,
294 &IID_IConnectionPointContainer,
298 static const IID * const head_iids[] = {
300 &IID_IHTMLHeadElement,
301 &IID_IConnectionPointContainer,
305 static const IID * const title_iids[] = {
307 &IID_IHTMLTitleElement,
308 &IID_IConnectionPointContainer,
312 static const IID * const meta_iids[] = {
314 &IID_IHTMLMetaElement,
315 &IID_IConnectionPointContainer,
319 static const IID * const object_iids[] = {
321 &IID_IHTMLObjectElement,
322 &IID_IHTMLObjectElement2,
323 /* FIXME: No IConnectionPointContainer */
327 static const IID * const embed_iids[] = {
329 &IID_IHTMLEmbedElement,
330 /* FIXME: No IConnectionPointContainer */
334 static const IID * const iframe_iids[] = {
337 &IID_IHTMLFrameBase2,
338 &IID_IHTMLIFrameElement,
339 &IID_IConnectionPointContainer,
343 static const IID * const form_iids[] = {
345 &IID_IHTMLFormElement,
346 &IID_IConnectionPointContainer,
350 static const IID * const styleelem_iids[] = {
352 &IID_IHTMLStyleElement,
353 &IID_IConnectionPointContainer,
357 static const IID * const generic_iids[] = {
359 &IID_IHTMLGenericElement,
360 &IID_IConnectionPointContainer,
364 static const IID * const style_iids[] = {
375 static const IID * const cstyle_iids[] = {
379 &IID_IHTMLCurrentStyle,
380 &IID_IHTMLCurrentStyle2,
381 &IID_IHTMLCurrentStyle3,
385 static const IID * const img_factory_iids[] = {
389 &IID_IHTMLImageElementFactory,
399 static const elem_type_info_t elem_type_infos[] = {
400 {"", none_iids, NULL},
401 {"HTML", elem_iids, NULL},
402 {"HEAD", head_iids, &DIID_DispHTMLHeadElement},
403 {"TITLE", title_iids, &DIID_DispHTMLTitleElement},
404 {"BODY", body_iids, &DIID_DispHTMLBody},
405 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
406 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
407 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
408 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
409 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
410 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
411 {"BLOCKQUOTE",elem_iids, NULL},
412 {"P", elem_iids, NULL},
413 {"BR", elem_iids, NULL},
414 {"TABLE", table_iids, &DIID_DispHTMLTable},
415 {"TBODY", elem_iids, NULL},
416 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
417 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
418 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
419 {"!", comment_iids, &DIID_DispHTMLCommentElement},
420 {"IMG", img_iids, &DIID_DispHTMLImg},
421 {"TR", tr_iids, &DIID_DispHTMLTableRow},
422 {"TD", td_iids, &DIID_DispHTMLTableCell},
423 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
424 {"FORM", form_iids, &DIID_DispHTMLFormElement},
425 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
426 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
427 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
428 {"DIV", elem_iids, NULL},
429 {"META", meta_iids, &DIID_DispHTMLMetaElement}
432 static const char *dbgstr_guid(REFIID riid)
436 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
437 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
438 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
439 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
444 static int strcmp_wa(LPCWSTR strw, const char *stra)
447 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
448 return lstrcmpA(stra, buf);
451 static BSTR a2bstr(const char *str)
459 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
460 ret = SysAllocStringLen(NULL, len);
461 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
466 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
468 IUnknown *unk1, *unk2;
473 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
474 IUnknown_Release(unk1);
475 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
476 IUnknown_Release(unk2);
481 static IHTMLDocument2 *create_document(void)
484 IHTMLDocument5 *doc5;
487 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
488 &IID_IHTMLDocument2, (void**)&doc);
489 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
493 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
495 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
496 IHTMLDocument2_Release(doc);
500 IHTMLDocument5_Release(doc5);
504 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
505 static IDispatchEx *_get_dispex_iface(unsigned line, IUnknown *unk)
510 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
511 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
515 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
516 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
518 const IID * const *piid;
522 for(piid = iids; *piid; piid++) {
523 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
524 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
526 IUnknown_Release(unk);
530 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
531 static void _test_no_iface(unsigned line, IUnknown *iface, REFIID iid)
536 unk = (void*)0xdeadbeef;
537 hres = IUnknown_QueryInterface(iface, iid, (void**)&unk);
538 ok_(__FILE__,line)(hres == E_NOINTERFACE, "hres = %08x, expected E_NOINTERFACE\n", hres);
539 ok_(__FILE__,line)(!unk, "unk = %p\n", unk);
542 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
543 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
545 IDispatchEx *dispex = _get_dispex_iface(line, unk);
552 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
553 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
554 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
556 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
557 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
559 if(SUCCEEDED(hres)) {
562 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
563 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
565 *iid = type_attr->guid;
569 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
570 ITypeInfo_Release(typeinfo);
573 IDispatchEx_Release(dispex);
577 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
578 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
580 IDispatchEx *dispex = _get_dispex_iface(line, unk);
581 DISPPARAMS dp = {NULL,NULL,0,0};
586 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
587 IDispatchEx_Release(dispex);
588 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
590 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
591 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
595 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
596 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
600 if(_test_get_dispid(line, unk, &iid))
601 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
604 _test_disp_value(line, unk, val);
607 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
608 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
612 if(_test_get_dispid(line, unk, &iid))
613 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
614 "unexpected guid %s\n", dbgstr_guid(&iid));
617 _test_disp_value(line, unk, val);
620 #define test_class_info(u) _test_class_info(__LINE__,u)
621 static void _test_class_info(unsigned line, IUnknown *unk)
623 IProvideClassInfo *classinfo;
628 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo, (void**)&classinfo);
629 ok_(__FILE__,line)(hres == S_OK, "Could not get IProvideClassInfo interface: %08x\n", hres);
633 hres = IProvideClassInfo_GetClassInfo(classinfo, &typeinfo);
634 ok_(__FILE__,line)(hres == S_OK, "Could not get ITypeInfo interface: %08x\n", hres);
637 IProvideClassInfo_Release(classinfo);
641 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
642 ok_(__FILE__,line)(hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
645 ok_(__FILE__,line)(IsEqualGUID(&type_attr->guid, &CLSID_HTMLDocument),
646 "unexpected guid %s\n", dbgstr_guid(&type_attr->guid));
647 ok_(__FILE__,line)(type_attr->typekind == TKIND_COCLASS,
648 "unexpected typekind %d\n", type_attr->typekind);
649 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
652 ITypeInfo_Release(typeinfo);
653 IProvideClassInfo_Release(classinfo);
656 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
657 static void _set_dispex_value(unsigned line, IUnknown *unk, const char *name, VARIANT *val)
659 IDispatchEx *dispex = _get_dispex_iface(line, unk);
660 DISPPARAMS dp = {val, NULL, 1, 0};
667 hres = IDispatchEx_GetDispID(dispex, str, fdexNameEnsure|fdexNameCaseInsensitive, &id);
669 ok_(__FILE__,line)(hres == S_OK, "GetDispID failed: %08x\n", hres);
671 memset(&ei, 0, sizeof(ei));
672 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYPUT, &dp, NULL, &ei, NULL);
673 ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres);
677 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
678 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
683 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
684 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
688 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
689 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
694 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
695 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
699 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
700 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
705 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
706 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
710 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
711 static IHTMLElement4 *_get_elem4_iface(unsigned line, IUnknown *unk)
716 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement4, (void**)&elem);
717 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement4: %08x\n", hres);
721 #define get_node_iface(u) _get_node_iface(__LINE__,u)
722 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
727 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
728 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
732 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
733 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
738 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
739 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
743 #define get_img_iface(u) _get_img_iface(__LINE__,u)
744 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
746 IHTMLImgElement *img;
749 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
750 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
754 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
755 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
757 IHTMLAnchorElement *anchor;
760 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
761 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
765 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
766 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
768 IHTMLTextAreaElement *textarea;
771 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
772 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
776 #define get_select_iface(u) _get_select_iface(__LINE__,u)
777 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
779 IHTMLSelectElement *select;
782 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
783 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
787 #define get_form_iface(u) _get_form_iface(__LINE__,u)
788 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
790 IHTMLFormElement *form;
793 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
794 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
798 #define get_text_iface(u) _get_text_iface(__LINE__,u)
799 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
801 IHTMLDOMTextNode *text;
804 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
805 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
809 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
810 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
812 IHTMLCommentElement *comment;
815 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
816 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
820 #define get_object_iface(u) _get_object_iface(__LINE__,u)
821 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
823 IHTMLObjectElement *obj;
826 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
827 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
831 #define get_style_iface(u) _get_style_iface(__LINE__,u)
832 static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
834 IHTMLStyleElement *obj;
837 hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
838 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
842 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
843 static IHTMLMetaElement *_get_metaelem_iface(unsigned line, IUnknown *unk)
845 IHTMLMetaElement *ret;
848 hres = IUnknown_QueryInterface(unk, &IID_IHTMLMetaElement, (void**)&ret);
849 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLMetaElement: %08x\n", hres);
853 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
854 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
856 IHTMLDOMNode *node = _get_node_iface(line, unk);
860 hres = IHTMLDOMNode_get_nodeName(node, &name);
861 IHTMLDOMNode_Release(node);
862 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
863 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
868 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
869 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
871 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
872 IDispatch *disp = (void*)0xdeadbeef;
873 IHTMLDocument2 *doc = NULL;
876 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
877 IHTMLDOMNode2_Release(node);
878 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
881 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
882 IDispatch_Release(disp);
883 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
889 #define get_doc_window(d) _get_doc_window(__LINE__,d)
890 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
892 IHTMLWindow2 *window;
896 hres = IHTMLDocument2_get_parentWindow(doc, &window);
897 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
898 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
903 #define clone_node(n,d) _clone_node(__LINE__,n,d)
904 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
906 IHTMLDOMNode *node = _get_node_iface(line, unk);
907 IHTMLDOMNode *ret = NULL;
910 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
911 IHTMLDOMNode_Release(node);
912 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
913 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
919 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
920 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
922 IHTMLElement *elem = _get_elem_iface(line, unk);
926 hres = IHTMLElement_get_tagName(elem, &tag);
927 IHTMLElement_Release(elem);
928 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
929 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
934 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
935 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
937 _test_elem_tag(line, unk, elem_type_infos[type].tag);
938 _test_ifaces(line, unk, elem_type_infos[type].iids);
940 if(elem_type_infos[type].dispiid && type != ET_A)
941 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
944 #define get_node_type(n) _get_node_type(__LINE__,n)
945 static LONG _get_node_type(unsigned line, IUnknown *unk)
947 IHTMLDOMNode *node = _get_node_iface(line, unk);
951 hres = IHTMLDOMNode_get_nodeType(node, &type);
952 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
954 IHTMLDOMNode_Release(node);
959 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
960 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
962 IHTMLDOMNode *node = _get_node_iface(line, unk);
963 IHTMLDOMChildrenCollection *col = NULL;
967 hres = IHTMLDOMNode_get_childNodes(node, &disp);
968 IHTMLDOMNode_Release(node);
969 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
973 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
974 IDispatch_Release(disp);
975 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
980 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
981 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
983 IHTMLDOMNode *node = NULL;
987 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
988 ok(hres == S_OK, "item failed: %08x\n", hres);
990 node = _get_node_iface(line, (IUnknown*)disp);
991 IDispatch_Release(disp);
996 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
997 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
1003 VariantInit(&value);
1006 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
1008 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
1011 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
1012 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
1014 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
1017 VariantClear(&value);
1020 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1021 static void _test_elem_offset(unsigned line, IUnknown *unk, const char *parent_tag)
1023 IHTMLElement *elem = _get_elem_iface(line, unk);
1024 IHTMLElement *off_parent;
1028 hres = IHTMLElement_get_offsetTop(elem, &l);
1029 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
1031 hres = IHTMLElement_get_offsetHeight(elem, &l);
1032 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
1034 hres = IHTMLElement_get_offsetWidth(elem, &l);
1035 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
1037 hres = IHTMLElement_get_offsetLeft(elem, &l);
1038 ok_(__FILE__,line) (hres == S_OK, "get_offsetLeft failed: %08x\n", hres);
1040 hres = IHTMLElement_get_offsetParent(elem, &off_parent);
1041 ok_(__FILE__,line) (hres == S_OK, "get_offsetParent failed: %08x\n", hres);
1043 _test_elem_tag(line, (IUnknown*)off_parent, parent_tag);
1044 IHTMLElement_Release(off_parent);
1046 IHTMLElement_Release(elem);
1049 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1050 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
1052 IHTMLWindow2 *window;
1053 IHTMLDocument2 *ret;
1056 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1057 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
1059 hres = IHTMLWindow2_get_document(window, &ret);
1060 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
1061 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
1066 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1067 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
1072 hres = IHTMLWindow2_get_name(window, &name);
1073 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
1075 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
1077 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
1078 SysFreeString(name);
1081 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1082 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
1088 hres = IHTMLWindow2_put_name(window, str);
1090 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
1092 _test_window_name(line, window, name);
1095 #define test_window_status(d) _test_window_status(__LINE__,d)
1096 static void _test_window_status(unsigned line, IHTMLWindow2 *window)
1101 status = (void*)0xdeadbeef;
1102 hres = IHTMLWindow2_get_status(window, &status);
1103 ok_(__FILE__,line)(hres == S_OK, "get_status failed: %08x\n", hres);
1104 ok_(__FILE__,line)(!status, "status = %s\n", wine_dbgstr_w(status));
1105 SysFreeString(status);
1108 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1109 static void _set_window_status(unsigned line, IHTMLWindow2 *window, const char *status)
1114 str = a2bstr(status);
1115 hres = IHTMLWindow2_put_status(window, str);
1117 ok_(__FILE__,line)(hres == S_OK, "put_status failed: %08x\n", hres);
1120 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1121 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
1126 hres = IHTMLWindow2_get_length(window, &length);
1127 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1128 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1131 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1132 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1134 IHTMLFrameBase2 *base2;
1135 IHTMLWindow2 *window;
1138 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1139 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1142 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1143 IHTMLFrameBase2_Release(base2);
1144 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1145 ok(window != NULL, "contentWindow = NULL\n");
1150 static void test_get_set_attr(IHTMLDocument2 *doc)
1153 IHTMLDocument3 *doc3;
1158 /* grab an element to test with */
1159 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1160 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1162 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1163 IHTMLDocument3_Release(doc3);
1164 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1166 /* get a non-present attribute */
1167 bstr = a2bstr("notAnAttribute");
1168 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1169 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1170 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1172 SysFreeString(bstr);
1174 /* get a present attribute */
1175 bstr = a2bstr("scrollHeight");
1176 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1177 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1178 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1180 SysFreeString(bstr);
1182 /* create a new BSTR attribute */
1183 bstr = a2bstr("newAttribute");
1185 V_VT(&val) = VT_BSTR;
1186 V_BSTR(&val) = a2bstr("the value");
1187 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1188 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1191 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1192 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1193 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1194 ok(strcmp_wa(V_BSTR(&val), "the value") == 0, "variant value should have been L\"the value\", was %s\n", wine_dbgstr_w(V_BSTR(&val)));
1197 /* overwrite the attribute with a BOOL */
1198 V_VT(&val) = VT_BOOL;
1199 V_BOOL(&val) = VARIANT_TRUE;
1200 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1201 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1204 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1205 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1206 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1207 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1210 SysFreeString(bstr);
1212 /* case-insensitive */
1213 bstr = a2bstr("newattribute");
1214 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1215 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1216 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1217 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1219 SysFreeString(bstr);
1221 IHTMLElement_Release(elem);
1224 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1225 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1228 IHTMLDocument3 *doc3;
1231 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1232 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1233 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1234 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1235 IHTMLDocument3_Release(doc3);
1240 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1241 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1243 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1247 hres = IHTMLAnchorElement_get_href(anchor, &str);
1248 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1249 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1252 _test_disp_value(line, unk, exhref);
1255 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1256 static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhref)
1258 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1262 str = a2bstr(exhref);
1263 hres = IHTMLAnchorElement_put_href(anchor, str);
1264 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1267 _test_disp_value(line, unk, exhref);
1270 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1271 static void _test_anchor_get_target(unsigned line, IUnknown *unk, const char *target)
1273 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1277 hres = IHTMLAnchorElement_get_target(anchor, &str);
1278 ok_(__FILE__,line)(hres == S_OK, "get_target failed: %08x\n", hres);
1280 ok_(__FILE__,line)(!strcmp_wa(str, target), "target = %s, expected %s\n", wine_dbgstr_w(str), target);
1282 ok_(__FILE__,line)(str == NULL, "target = %s, expected NULL\n", wine_dbgstr_w(str));
1286 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1287 static void _test_anchor_put_target(unsigned line, IUnknown *unk, const char *target)
1289 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1293 str = target ? a2bstr(target) : NULL;
1294 hres = IHTMLAnchorElement_put_target(anchor, str);
1295 ok_(__FILE__,line)(hres == S_OK, "put_target failed: %08x\n", hres);
1300 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1301 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1306 hres = IHTMLOptionElement_get_text(option, &bstr);
1307 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1308 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1309 SysFreeString(bstr);
1312 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1313 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1318 bstr = a2bstr(text);
1319 hres = IHTMLOptionElement_put_text(option, bstr);
1320 SysFreeString(bstr);
1321 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1323 _test_option_text(line, option, text);
1326 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1327 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1332 hres = IHTMLOptionElement_get_value(option, &bstr);
1333 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1334 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1335 SysFreeString(bstr);
1338 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1339 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1344 bstr = a2bstr(value);
1345 hres = IHTMLOptionElement_put_value(option, bstr);
1346 SysFreeString(bstr);
1347 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1349 _test_option_value(line, option, value);
1352 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1353 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1355 VARIANT_BOOL b = 0x100;
1358 hres = IHTMLOptionElement_get_selected(option, &b);
1359 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1360 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1363 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1364 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1368 hres = IHTMLOptionElement_put_selected(option, b);
1369 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1370 _test_option_selected(line, option, b);
1373 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1374 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1376 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1377 BSTR value = (void*)0xdeadbeef;
1380 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1381 IHTMLTextAreaElement_Release(textarea);
1382 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1384 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1386 ok_(__FILE__,line)(!value, "value = %p\n", value);
1387 SysFreeString(value);
1390 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1391 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1393 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1394 BSTR tmp = a2bstr(value);
1397 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1398 IHTMLTextAreaElement_Release(textarea);
1399 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1402 _test_textarea_value(line, unk, value);
1405 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1406 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1408 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1409 VARIANT_BOOL b = 0x100;
1412 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1413 IHTMLTextAreaElement_Release(textarea);
1414 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1415 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1418 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1419 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1421 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1424 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1425 IHTMLTextAreaElement_Release(textarea);
1426 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1428 _test_textarea_readonly(line, unk, b);
1431 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1432 static void _test_textarea_type(unsigned line, IUnknown *unk)
1434 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1435 BSTR type = (void*)0xdeadbeef;
1438 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1439 IHTMLTextAreaElement_Release(textarea);
1440 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1441 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1442 SysFreeString(type);
1445 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1446 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1448 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1452 text = a2bstr(extext);
1453 hres = IHTMLCommentElement_get_text(comment, &text);
1454 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1455 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1457 IHTMLCommentElement_Release(comment);
1458 SysFreeString(text);
1461 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1462 static void _test_comment_attrs(unsigned line, IUnknown *unk)
1464 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1465 IHTMLElement *elem = _get_elem_iface(__LINE__,unk);
1466 IHTMLElement4 *elem4 = _get_elem4_iface(__LINE__,unk);
1467 IHTMLDOMAttribute *attr;
1468 BSTR name = a2bstr("test");
1472 hres = IHTMLElement4_getAttributeNode(elem4, name, &attr);
1473 ok(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
1474 ok(attr == NULL, "attr != NULL\n");
1478 hres = IHTMLElement_setAttribute(elem, name, val, 0);
1479 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1481 hres = IHTMLElement4_getAttributeNode(elem4, name, &attr);
1482 ok(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
1483 ok(attr != NULL, "attr == NULL\n");
1485 IHTMLDOMAttribute_Release(attr);
1486 IHTMLCommentElement_Release(comment);
1487 IHTMLElement_Release(elem);
1488 IHTMLElement4_Release(elem);
1489 SysFreeString(name);
1492 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1493 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1495 IHTMLObjectElement *object = _get_object_iface(line, unk);
1500 hres = IHTMLObjectElement_get_vspace(object, &l);
1501 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1502 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1503 IHTMLObjectElement_Release(object);
1506 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1507 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1508 const char *txt, const char *val)
1510 IHTMLOptionElementFactory *factory;
1511 IHTMLOptionElement *option;
1512 IHTMLWindow2 *window;
1513 VARIANT text, value, empty;
1516 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1517 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1519 hres = IHTMLWindow2_get_Option(window, &factory);
1520 IHTMLWindow2_Release(window);
1521 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1523 V_VT(&text) = VT_BSTR;
1524 V_BSTR(&text) = a2bstr(txt);
1525 V_VT(&value) = VT_BSTR;
1526 V_BSTR(&value) = a2bstr(val);
1527 V_VT(&empty) = VT_EMPTY;
1529 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1530 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1532 IHTMLOptionElementFactory_Release(factory);
1533 VariantClear(&text);
1534 VariantClear(&value);
1536 _test_option_text(line, option, txt);
1537 _test_option_value(line, option, val);
1538 _test_option_selected(line, option, VARIANT_FALSE);
1543 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1544 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1549 hres = IHTMLImgElement_get_width(img, &found);
1550 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1551 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1554 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1555 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1559 hres = IHTMLImgElement_put_width(img, width);
1560 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1562 _test_img_width(line, img, width);
1565 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1566 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1571 hres = IHTMLImgElement_get_height(img, &found);
1572 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1573 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1576 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1577 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1581 hres = IHTMLImgElement_put_height(img, height);
1582 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1584 _test_img_height(line, img, height);
1587 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1588 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1589 LONG wdth, LONG hght)
1591 IHTMLImageElementFactory *factory;
1592 IHTMLImgElement *img;
1593 IHTMLWindow2 *window;
1594 VARIANT width, height;
1598 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1599 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1601 hres = IHTMLWindow2_get_Image(window, &factory);
1602 IHTMLWindow2_Release(window);
1603 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1605 test_ifaces((IUnknown*)factory, img_factory_iids);
1606 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1609 snprintf(buf, 16, "%d", wdth);
1610 V_VT(&width) = VT_BSTR;
1611 V_BSTR(&width) = a2bstr(buf);
1613 V_VT(&width) = VT_EMPTY;
1618 snprintf(buf, 16, "%d", hght);
1619 V_VT(&height) = VT_BSTR;
1620 V_BSTR(&height) = a2bstr(buf);
1622 V_VT(&height) = VT_EMPTY;
1626 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1627 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1629 IHTMLImageElementFactory_Release(factory);
1630 VariantClear(&width);
1631 VariantClear(&height);
1633 if(SUCCEEDED(hres)) {
1634 _test_img_width(line, img, wdth);
1635 _test_img_height(line, img, hght);
1642 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1643 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1645 LONG len = 0xdeadbeef;
1648 hres = IHTMLSelectElement_get_length(select, &len);
1649 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1650 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1653 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1654 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1656 IHTMLSelectElement *select = _get_select_iface(line, unk);
1659 hres = IHTMLSelectElement_put_length(select, length);
1660 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1661 _test_select_length(line, select, length);
1662 IHTMLSelectElement_Release(select);
1665 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1666 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1668 LONG idx = 0xdeadbeef;
1671 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1672 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1673 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1676 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1677 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1681 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1682 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1683 _test_select_selidx(line, select, index);
1686 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1687 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1692 hres = IHTMLSelectElement_get_value(select, &val);
1693 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1695 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1697 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1701 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1702 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1708 hres = IHTMLSelectElement_put_value(select, bstr);
1709 SysFreeString(bstr);
1710 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1713 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1714 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1719 hres = IHTMLSelectElement_get_type(select, &type);
1720 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1721 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1722 SysFreeString(type);
1725 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1726 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1731 hres = IHTMLTxtRange_get_text(range, &text);
1732 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1735 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1736 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1738 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1741 SysFreeString(text);
1745 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1746 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1750 hres = IHTMLTxtRange_collapse(range, b);
1751 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1752 _test_range_text(line, range, NULL);
1755 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1756 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1757 VARIANT_BOOL exb, const char *extext)
1759 VARIANT_BOOL b = 0xe0e0;
1762 hres = IHTMLTxtRange_expand(range, unit, &b);
1763 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1764 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1765 _test_range_text(line, range, extext);
1768 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1769 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1771 LONG c = 0xdeadbeef;
1774 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1775 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1776 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1777 _test_range_text(line, range, NULL);
1780 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1781 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1782 LPWSTR unit, LONG cnt, LONG excnt)
1784 LONG c = 0xdeadbeef;
1787 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1788 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1789 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1792 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1793 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1795 LONG c = 0xdeadbeef;
1798 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1799 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1800 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1803 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1804 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1807 BSTR bstr = a2bstr(text);
1809 hres = IHTMLTxtRange_put_text(range, bstr);
1810 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1811 SysFreeString(bstr);
1812 _test_range_text(line, range, NULL);
1815 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1816 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1822 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1823 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1824 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1827 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1828 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1834 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1835 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1836 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1839 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1840 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1841 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1844 test_range_inrange(range1, range2, VARIANT_TRUE);
1845 test_range_inrange(range2, range1, VARIANT_TRUE);
1849 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1850 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1855 hres = IHTMLTxtRange_parentElement(range, &elem);
1856 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1858 _test_elem_type(line, (IUnknown*)elem, type);
1860 IHTMLElement_Release(elem);
1863 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1864 static void _test_elem_collection(unsigned line, IUnknown *unk,
1865 const elem_type_t *elem_types, LONG exlen)
1867 IHTMLElementCollection *col;
1870 VARIANT name, index;
1871 IDispatch *disp, *disp2;
1874 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1875 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1877 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1879 hres = IHTMLElementCollection_get_length(col, &len);
1880 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1881 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1886 V_VT(&index) = VT_EMPTY;
1888 for(i=0; i<len; i++) {
1889 V_VT(&name) = VT_I4;
1891 disp = (void*)0xdeadbeef;
1892 hres = IHTMLElementCollection_item(col, name, index, &disp);
1893 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1894 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1895 if(FAILED(hres) || !disp)
1898 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1901 V_VT(&name) = VT_UINT;
1903 disp2 = (void*)0xdeadbeef;
1904 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1905 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1906 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1908 IDispatch_Release(disp2);
1911 IDispatch_Release(disp);
1914 V_VT(&name) = VT_I4;
1916 disp = (void*)0xdeadbeef;
1917 hres = IHTMLElementCollection_item(col, name, index, &disp);
1918 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1919 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1921 V_VT(&name) = VT_I4;
1923 disp = (void*)0xdeadbeef;
1924 hres = IHTMLElementCollection_item(col, name, index, &disp);
1925 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1926 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1928 IHTMLElementCollection_Release(col);
1931 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1932 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1934 IHTMLElement *elem = _get_elem_iface(line, unk);
1938 hres = IHTMLElement_get_all(elem, &disp);
1939 IHTMLElement_Release(elem);
1940 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1942 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1943 IDispatch_Release(disp);
1946 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1947 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1949 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1950 IHTMLElementCollection *col = NULL;
1951 elem_type_t *types = NULL;
1956 tmp = a2bstr(elem_type_infos[type].tag);
1957 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1959 IHTMLElement2_Release(elem);
1960 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1961 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1964 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1965 for(i=0; i<exlen; i++)
1969 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1971 HeapFree(GetProcessHeap(), 0, types);
1974 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1975 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1980 hres = IHTMLElement_get_innerText(elem, &text);
1981 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1982 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1983 wine_dbgstr_w(text), extext);
1984 SysFreeString(text);
1987 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1988 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1990 IHTMLDOMChildrenCollection *col;
1995 hres = IHTMLElement_put_innerText(elem, str);
1996 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1999 _test_elem_innertext(line, elem, text);
2002 col = _get_child_nodes(line, (IUnknown*)elem);
2003 ok(col != NULL, "col == NULL\n");
2005 LONG length = 0, type;
2008 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
2009 ok(hres == S_OK, "get_length failed: %08x\n", hres);
2010 ok(length == 1, "length = %d\n", length);
2012 node = _get_child_item(line, col, 0);
2013 ok(node != NULL, "node == NULL\n");
2015 type = _get_node_type(line, (IUnknown*)node);
2016 ok(type == 3, "type=%d\n", type);
2017 IHTMLDOMNode_Release(node);
2020 IHTMLDOMChildrenCollection_Release(col);
2025 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2026 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
2028 IHTMLElement *elem = _get_elem_iface(line, unk);
2032 hres = IHTMLElement_get_innerHTML(elem, &html);
2033 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
2035 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
2037 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
2039 IHTMLElement_Release(elem);
2040 SysFreeString(html);
2043 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2044 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
2046 IHTMLElement *elem = _get_elem_iface(line, unk);
2050 html = a2bstr(inner_html);
2051 hres = IHTMLElement_put_innerHTML(elem, html);
2052 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
2054 IHTMLElement_Release(elem);
2055 SysFreeString(html);
2058 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2059 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
2061 IHTMLElement *elem = _get_elem_iface(line, unk);
2065 html = a2bstr(outer_html);
2066 hres = IHTMLElement_put_outerHTML(elem, html);
2067 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
2069 IHTMLElement_Release(elem);
2070 SysFreeString(html);
2073 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2074 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
2076 IHTMLElement *elem = _get_elem_iface(line, unk);
2080 hres = IHTMLElement_get_outerHTML(elem, &html);
2081 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
2082 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
2084 IHTMLElement_Release(elem);
2085 SysFreeString(html);
2088 #define get_first_child(n) _get_first_child(__LINE__,n)
2089 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
2091 IHTMLDOMNode *node = _get_node_iface(line, unk);
2092 IHTMLDOMNode *child = NULL;
2095 hres = IHTMLDOMNode_get_firstChild(node, &child);
2096 IHTMLDOMNode_Release(node);
2097 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
2102 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2103 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2105 IHTMLDOMNode *node = _get_node_iface(line, unk);
2106 VARIANT_BOOL b = 0xdead;
2109 hres = IHTMLDOMNode_hasChildNodes(node, &b);
2110 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
2111 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
2113 IHTMLDOMNode_Release(node);
2116 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2117 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
2119 IHTMLDOMNode *node = _get_node_iface(line, unk);
2120 IHTMLDOMNode *parent;
2123 hres = IHTMLDOMNode_get_parentNode(node, &parent);
2124 IHTMLDOMNode_Release(node);
2125 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
2130 #define node_get_next(u) _node_get_next(__LINE__,u)
2131 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
2133 IHTMLDOMNode *node = _get_node_iface(line, unk);
2137 hres = IHTMLDOMNode_get_nextSibling(node, &next);
2138 IHTMLDOMNode_Release(node);
2139 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
2144 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2145 static IHTMLDOMNode *_node_get_prev(unsigned line, IUnknown *unk)
2147 IHTMLDOMNode *node = _get_node_iface(line, unk);
2151 hres = IHTMLDOMNode_get_previousSibling(node, &prev);
2152 IHTMLDOMNode_Release(node);
2153 ok_(__FILE__,line) (hres == S_OK, "get_previousSibling failed: %08x\n", hres);
2158 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2159 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
2161 IHTMLElement *elem = _get_elem_iface(line, unk);
2162 IHTMLElement *parent;
2165 hres = IHTMLElement_get_parentElement(elem, &parent);
2166 IHTMLElement_Release(elem);
2167 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
2172 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2173 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2175 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2176 VARIANT_BOOL disabled = 100;
2180 hres = IHTMLElement3_get_disabled(elem3, &disabled);
2181 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2182 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2183 IHTMLElement3_Release(elem3);
2186 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2187 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
2189 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2193 hres = IHTMLElement3_put_disabled(elem3, b);
2194 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2196 IHTMLElement3_Release(elem3);
2197 _test_elem3_get_disabled(line, unk, b);
2200 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2201 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2203 VARIANT_BOOL disabled = 100;
2206 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2207 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2208 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2210 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2213 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2214 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2216 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2220 hres = IHTMLDOMTextNode_get_length(text, &length);
2221 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2222 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2223 IHTMLDOMTextNode_Release(text);
2226 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2227 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2231 hres = IHTMLSelectElement_put_disabled(select, b);
2232 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2234 _test_select_get_disabled(line, select, b);
2237 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2238 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2240 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2241 IHTMLTextContainer *txtcont;
2242 LONG l = -1, l2 = -1;
2245 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2246 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2247 IHTMLElement2_Release(elem);
2249 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2250 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2252 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2253 IHTMLTextContainer_Release(txtcont);
2254 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2255 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2260 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2261 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2263 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2264 IHTMLTextContainer *txtcont;
2265 LONG l = -1, l2 = -1;
2268 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2269 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2270 IHTMLElement2_Release(elem);
2272 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2273 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2275 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2276 IHTMLTextContainer_Release(txtcont);
2277 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2278 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2283 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2284 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2286 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2287 IHTMLTextContainer *txtcont;
2288 LONG l = -1, l2 = -1;
2291 hres = IHTMLElement2_get_scrollTop(elem, &l);
2292 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2293 IHTMLElement2_Release(elem);
2295 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2296 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2298 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2299 IHTMLTextContainer_Release(txtcont);
2300 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2301 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2306 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2307 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2309 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2310 IHTMLTextContainer *txtcont;
2311 LONG l = -1, l2 = -1;
2314 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2315 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2317 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2318 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2319 IHTMLElement2_Release(elem);
2321 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2322 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2324 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2325 IHTMLTextContainer_Release(txtcont);
2326 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2327 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2330 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2331 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc, const char *broken_src)
2333 IHTMLImgElement *img = _get_img_iface(line, unk);
2337 hres = IHTMLImgElement_get_src(img, &src);
2338 IHTMLImgElement_Release(img);
2339 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2340 ok_(__FILE__,line) (!strcmp_wa(src, exsrc) || (broken_src && broken(!strcmp_wa(src, broken_src))),
2341 "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2345 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2346 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2348 IHTMLImgElement *img = _get_img_iface(line, unk);
2353 hres = IHTMLImgElement_put_src(img, tmp);
2354 IHTMLImgElement_Release(img);
2356 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2359 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2360 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2362 IHTMLImgElement *img = _get_img_iface(line, unk);
2366 hres = IHTMLImgElement_get_alt(img, &alt);
2367 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2369 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2371 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2375 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2376 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2378 IHTMLImgElement *img = _get_img_iface(line, unk);
2383 hres = IHTMLImgElement_put_alt(img, tmp);
2384 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2387 _test_img_alt(line, unk, alt);
2390 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2391 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2393 IHTMLImgElement *img = _get_img_iface(line, unk);
2397 hres = IHTMLImgElement_get_name(img, &sName);
2398 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2399 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2400 IHTMLImgElement_Release(img);
2401 SysFreeString(sName);
2404 static void test_dynamic_properties(IHTMLElement *elem)
2406 static const WCHAR attr1W[] = {'a','t','t','r','1',0};
2407 IDispatchEx *dispex;
2408 BSTR name, attr1 = SysAllocString(attr1W);
2412 DISPID id = DISPID_STARTENUM;
2415 hres = IHTMLElement_QueryInterface(elem, &IID_IDispatchEx, (void**)&dispex);
2416 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
2418 hres = IHTMLElement_removeAttribute(elem, attr1, 0, &succ);
2419 ok(hres == S_OK, "removeAttribute failed: %08x\n", hres);
2420 ok(succ, "removeAttribute set succ to FALSE\n");
2423 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumAll, id, &id);
2424 ok(hres==S_OK || hres==S_FALSE, "GetNextDispID failed: %08x\n", hres);
2428 hres = IDispatchEx_GetMemberName(dispex, id, &name);
2429 ok(hres == S_OK, "GetMemberName failed: %08x\n", hres);
2431 if(!strcmp_wa(name, "attr1"))
2432 ok(0, "attr1 should be removed\n");
2433 else if(!strcmp_wa(name, "attr2") || !strcmp_wa(name, "attr3"))
2435 SysFreeString(name);
2437 ok(checked_no == 2, "checked_no=%d, expected 2\n", checked_no);
2438 IDispatchEx_Release(dispex);
2440 V_VT(&val) = VT_BSTR;
2441 V_BSTR(&val) = attr1;
2442 hres = IHTMLElement_setAttribute(elem, attr1, val, 0);
2443 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
2444 SysFreeString(attr1);
2447 static void test_attr_collection_disp(IDispatch *disp)
2449 IDispatchEx *dispex;
2450 IHTMLDOMAttribute *attr;
2451 DISPPARAMS dp = {NULL, NULL, 0, 0};
2458 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
2459 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
2462 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
2463 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2464 SysFreeString(bstr);
2467 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
2468 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2469 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
2470 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
2473 bstr = a2bstr("attr1");
2474 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
2475 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2476 SysFreeString(bstr);
2479 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
2480 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2481 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
2482 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
2483 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLDOMAttribute, (void**)&attr);
2484 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
2485 hres = IHTMLDOMAttribute_get_nodeName(attr, &bstr);
2486 ok(hres == S_OK, "get_nodeName failed: %08x\n", hres);
2487 ok(!strcmp_wa(bstr, "attr1"), "node name is %s, expected attr1\n", wine_dbgstr_w(bstr));
2488 SysFreeString(bstr);
2489 IHTMLDOMAttribute_Release(attr);
2492 IDispatchEx_Release(dispex);
2495 static void test_attr_collection(IHTMLElement *elem)
2497 static const WCHAR testW[] = {'t','e','s','t',0};
2500 IDispatch *disp, *attr;
2501 IHTMLDOMAttribute *dom_attr;
2502 IHTMLAttributeCollection *attr_col;
2503 BSTR name = SysAllocString(testW);
2505 LONG i, len, checked;
2508 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLDOMNode, (void**)&node);
2509 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
2511 hres = IHTMLDOMNode_get_attributes(node, &disp);
2512 ok(hres == S_OK, "get_attributes failed: %08x\n", hres);
2514 hres = IHTMLDOMNode_get_attributes(node, &attr);
2515 ok(hres == S_OK, "get_attributes failed: %08x\n", hres);
2516 ok(iface_cmp((IUnknown*)disp, (IUnknown*)attr), "disp != attr\n");
2517 IDispatch_Release(attr);
2518 IHTMLDOMNode_Release(node);
2520 hres = IDispatch_QueryInterface(disp, &IID_IHTMLAttributeCollection, (void**)&attr_col);
2521 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
2523 hres = IHTMLAttributeCollection_get_length(attr_col, &i);
2524 ok(hres == S_OK, "get_length failed: %08x\n", hres);
2528 hres = IHTMLElement_setAttribute(elem, name, val, 0);
2529 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
2530 SysFreeString(name);
2532 hres = IHTMLAttributeCollection_get_length(attr_col, &len);
2533 ok(hres == S_OK, "get_length failed: %08x\n", hres);
2534 ok(len == i+1, "get_length returned %d, expected %d\n", len, i+1);
2537 for(i=0; i<len; i++) {
2540 hres = IHTMLAttributeCollection_item(attr_col, &id, &attr);
2541 ok(hres == S_OK, "%d) item failed: %08x\n", i, hres);
2543 hres = IDispatch_QueryInterface(attr, &IID_IHTMLDOMAttribute, (void**)&dom_attr);
2544 ok(hres == S_OK, "%d) QueryInterface failed: %08x\n", i, hres);
2545 IDispatch_Release(attr);
2547 hres = IHTMLDOMAttribute_get_nodeName(dom_attr, &name);
2548 ok(hres == S_OK, "%d) get_nodeName failed: %08x\n", i, hres);
2550 if(!strcmp_wa(name, "id")) {
2552 hres = IHTMLDOMAttribute_get_nodeValue(dom_attr, &val);
2553 ok(hres == S_OK, "%d) get_nodeValue failed: %08x\n", i, hres);
2554 ok(V_VT(&val) == VT_BSTR, "id: V_VT(&val) = %d\n", V_VT(&val));
2555 ok(!strcmp_wa(V_BSTR(&val), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val)));
2556 } else if(!strcmp_wa(name, "attr1")) {
2558 hres = IHTMLDOMAttribute_get_nodeValue(dom_attr, &val);
2559 ok(hres == S_OK, "%d) get_nodeValue failed: %08x\n", i, hres);
2560 ok(V_VT(&val) == VT_BSTR, "attr1: V_VT(&val) = %d\n", V_VT(&val));
2561 ok(!strcmp_wa(V_BSTR(&val), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val)));
2562 } else if(!strcmp_wa(name, "attr2")) {
2564 hres = IHTMLDOMAttribute_get_nodeValue(dom_attr, &val);
2565 ok(hres == S_OK, "%d) get_nodeValue failed: %08x\n", i, hres);
2566 ok(V_VT(&val) == VT_BSTR, "attr2: V_VT(&val) = %d\n", V_VT(&val));
2567 ok(!V_BSTR(&val), "attr2: V_BSTR(&val) != NULL\n");
2568 } else if(!strcmp_wa(name, "attr3")) {
2570 hres = IHTMLDOMAttribute_get_nodeValue(dom_attr, &val);
2571 ok(hres == S_OK, "%d) get_nodeValue failed: %08x\n", i, hres);
2572 ok(V_VT(&val) == VT_BSTR, "attr3: V_VT(&val) = %d\n", V_VT(&val));
2573 ok(!strcmp_wa(V_BSTR(&val), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val)));
2574 } else if(!strcmp_wa(name, "test")) {
2576 hres = IHTMLDOMAttribute_get_nodeValue(dom_attr, &val);
2577 ok(hres == S_OK, "%d) get_nodeValue failed: %08x\n", i, hres);
2578 ok(V_VT(&val) == VT_I4, "test: V_VT(&val) = %d\n", V_VT(&val));
2579 ok(V_I4(&val) == 1, "test: V_I4(&val) = %d\n", V_I4(&val));
2582 IHTMLDOMAttribute_Release(dom_attr);
2583 SysFreeString(name);
2586 ok(checked==5, "invalid number of specified attributes (%d)\n", checked);
2589 hres = IHTMLAttributeCollection_item(attr_col, &id, &attr);
2590 ok(hres == E_INVALIDARG, "item failed: %08x\n", hres);
2592 V_VT(&id) = VT_BSTR;
2593 V_BSTR(&id) = a2bstr("nonexisting");
2594 hres = IHTMLAttributeCollection_item(attr_col, &id, &attr);
2595 ok(hres == E_INVALIDARG, "item failed: %08x\n", hres);
2598 test_attr_collection_disp(disp);
2600 IDispatch_Release(disp);
2601 IHTMLAttributeCollection_Release(attr_col);
2604 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2605 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2610 hres = IHTMLInputElement_get_type(input, &type);
2611 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2612 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2613 SysFreeString(type);
2616 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2617 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2619 BSTR name = (BSTR)0xdeadbeef;
2622 hres = IHTMLInputElement_get_name(input, &name);
2623 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2625 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2627 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2628 SysFreeString(name);
2631 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2632 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2634 BSTR tmp = a2bstr(name);
2637 hres = IHTMLInputElement_put_name(input, tmp);
2638 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2641 _test_input_name(line, input, name);
2644 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2645 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2647 VARIANT_BOOL disabled = 100;
2650 hres = IHTMLInputElement_get_disabled(input, &disabled);
2651 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2652 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2654 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2657 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2658 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2662 hres = IHTMLInputElement_put_disabled(input, b);
2663 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2665 _test_input_get_disabled(line, input, b);
2668 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2669 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2671 VARIANT_BOOL checked = 100;
2674 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2675 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2676 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2679 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2680 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2684 hres = IHTMLInputElement_put_defaultChecked(input, b);
2685 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2687 _test_input_get_defaultchecked(line, input, b);
2690 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2691 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2693 VARIANT_BOOL checked = 100;
2696 hres = IHTMLInputElement_get_checked(input, &checked);
2697 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2698 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2701 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2702 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2706 hres = IHTMLInputElement_put_checked(input, b);
2707 ok_(__FILE__,line) (hres == S_OK, "put_checked failed: %08x\n", hres);
2709 _test_input_get_checked(line, input, b);
2712 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
2713 static void _test_input_maxlength(unsigned line, IHTMLInputElement *input, LONG exl)
2715 LONG maxlength = 0xdeadbeef;
2718 hres = IHTMLInputElement_get_maxLength(input, &maxlength);
2719 ok_(__FILE__,line) (hres == S_OK, "get_maxLength failed: %08x\n", hres);
2720 ok_(__FILE__,line) (maxlength == exl, "maxLength=%x, expected %d\n", maxlength, exl);
2723 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
2724 static void _test_input_set_maxlength(unsigned line, IHTMLInputElement *input, LONG l)
2728 hres = IHTMLInputElement_put_maxLength(input, l);
2729 ok_(__FILE__,line) (hres == S_OK, "put_maxLength failed: %08x\n", hres);
2731 _test_input_maxlength(line, input, l);
2734 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2735 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2737 IHTMLInputElement *input;
2741 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2742 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2746 hres = IHTMLInputElement_get_value(input, &bstr);
2747 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2749 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2751 ok_(__FILE__,line) (!bstr, "exval != NULL\n");
2752 SysFreeString(bstr);
2753 IHTMLInputElement_Release(input);
2756 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2757 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2759 IHTMLInputElement *input;
2763 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2764 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2769 hres = IHTMLInputElement_put_value(input, bstr);
2770 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2771 SysFreeString(bstr);
2772 IHTMLInputElement_Release(input);
2774 _test_input_value(line, unk, val);
2777 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2778 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2783 hres = IHTMLInputElement_get_src(input, &src);
2784 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2786 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2788 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2792 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2793 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2799 hres = IHTMLInputElement_put_src(input, tmp);
2801 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2803 _test_input_src(line, input, src);
2806 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2807 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2809 IHTMLElement *elem = _get_elem_iface(line, unk);
2810 BSTR class = (void*)0xdeadbeef;
2813 hres = IHTMLElement_get_className(elem, &class);
2814 IHTMLElement_Release(elem);
2815 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2817 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2819 ok_(__FILE__,line) (!class, "class != NULL\n");
2820 SysFreeString(class);
2823 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2824 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2826 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2830 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2831 IHTMLElement2_Release(elem2);
2832 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2833 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2836 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2837 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2839 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2842 hres = IHTMLElement2_put_tabIndex(elem2, index);
2843 IHTMLElement2_Release(elem2);
2844 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2846 _test_elem_tabindex(line, unk, index);
2849 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2850 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2852 IHTMLStyleElement *style = _get_style_iface(line, unk);
2856 hres = IHTMLStyleElement_get_media(style, &media);
2857 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2859 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2861 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2863 IHTMLStyleElement_Release(style);
2864 SysFreeString(media);
2867 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2868 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2870 IHTMLStyleElement *style = _get_style_iface(line, unk);
2874 str = a2bstr(media);
2875 hres = IHTMLStyleElement_put_media(style, str);
2876 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2877 IHTMLStyleElement_Release(style);
2880 _test_style_media(line, unk, media);
2883 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2884 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2886 IHTMLStyleElement *style = _get_style_iface(line, unk);
2890 hres = IHTMLStyleElement_get_type(style, &type);
2891 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2893 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2895 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2897 IHTMLStyleElement_Release(style);
2898 SysFreeString(type);
2901 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2902 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2904 IHTMLStyleElement *style = _get_style_iface(line, unk);
2909 hres = IHTMLStyleElement_put_type(style, str);
2910 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2911 IHTMLStyleElement_Release(style);
2914 _test_style_type(line, unk, type);
2917 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2918 static void _test_elem_filters(unsigned line, IUnknown *unk)
2920 IHTMLElement *elem = _get_elem_iface(line, unk);
2922 IHTMLFiltersCollection *filters;
2924 hres = IHTMLElement_get_filters(elem, &filters);
2925 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2926 "get_filters failed: %08x\n", hres);
2930 IDispatchEx *dispex;
2932 hres = IHTMLFiltersCollection_get_length(filters, &len);
2933 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2934 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2936 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2937 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2938 "Could not get IDispatchEx interface: %08x\n", hres);
2939 if(SUCCEEDED(hres)) {
2940 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2941 IDispatchEx_Release(dispex);
2944 IHTMLFiltersCollection_Release(filters);
2947 IHTMLElement_Release(elem);
2950 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2951 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2953 IHTMLElement *elem = _get_elem_iface(line, unk);
2957 tmp = class ? a2bstr(class) : NULL;
2958 hres = IHTMLElement_put_className(elem, tmp);
2959 IHTMLElement_Release(elem);
2960 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2963 _test_elem_class(line, unk, class);
2966 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2967 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2969 IHTMLElement *elem = _get_elem_iface(line, unk);
2970 BSTR id = (void*)0xdeadbeef;
2973 hres = IHTMLElement_get_id(elem, &id);
2974 IHTMLElement_Release(elem);
2975 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2978 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2980 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2985 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2986 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2988 IHTMLElement *elem = _get_elem_iface(line, unk);
2989 BSTR tmp = a2bstr(new_id);
2992 hres = IHTMLElement_put_id(elem, tmp);
2993 IHTMLElement_Release(elem);
2995 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2997 _test_elem_id(line, unk, new_id);
3000 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
3001 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
3003 IHTMLElement *elem = _get_elem_iface(line, unk);
3007 hres = IHTMLElement_get_title(elem, &title);
3008 IHTMLElement_Release(elem);
3009 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3011 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
3013 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
3015 SysFreeString(title);
3018 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
3019 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
3021 IHTMLElement *elem = _get_elem_iface(line, unk);
3025 tmp = a2bstr(title);
3026 hres = IHTMLElement_put_title(elem, tmp);
3027 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3029 IHTMLElement_Release(elem);
3033 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
3034 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
3036 IHTMLDOMNode *node = _get_node_iface(line, unk);
3040 hres = IHTMLDOMNode_get_nodeValue(node, &var);
3041 IHTMLDOMNode_Release(node);
3042 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
3045 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
3046 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
3048 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
3054 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
3055 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
3057 IHTMLDOMNode *node = _get_node_iface(line, unk);
3061 V_VT(&var) = VT_BSTR;
3062 V_BSTR(&var) = a2bstr(val);
3064 hres = IHTMLDOMNode_put_nodeValue(node, var);
3065 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
3066 IHTMLDOMNode_Release(node);
3070 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
3071 static void _test_elem_client_size(unsigned line, IUnknown *unk)
3073 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
3077 hres = IHTMLElement2_get_clientWidth(elem, &l);
3078 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
3079 hres = IHTMLElement2_get_clientHeight(elem, &l);
3080 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
3082 IHTMLElement2_Release(elem);
3085 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
3086 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
3088 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
3092 hres = IHTMLElement2_get_clientLeft(elem, &l);
3093 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
3094 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
3096 hres = IHTMLElement2_get_clientTop(elem, &l);
3097 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
3098 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
3100 IHTMLElement2_Release(elem);
3103 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
3104 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
3106 IHTMLFormElement *form = _get_form_iface(line, unk);
3107 LONG len = 0xdeadbeef;
3110 hres = IHTMLFormElement_get_length(form, &len);
3111 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
3112 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
3114 IHTMLFormElement_Release(form);
3117 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
3118 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
3120 IHTMLFormElement *form = _get_form_iface(line, unk);
3121 BSTR action = (void*)0xdeadbeef;
3124 hres = IHTMLFormElement_get_action(form, &action);
3125 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
3127 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
3129 ok_(__FILE__,line)(!action, "action=%p\n", action);
3131 SysFreeString(action);
3132 IHTMLFormElement_Release(form);
3135 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
3136 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
3138 IHTMLFormElement *form = _get_form_iface(line, unk);
3139 BSTR tmp = a2bstr(action);
3142 hres = IHTMLFormElement_put_action(form, tmp);
3143 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
3145 IHTMLFormElement_Release(form);
3147 _test_form_action(line, unk, action);
3150 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
3151 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
3153 IHTMLFormElement *form = _get_form_iface(line, unk);
3154 BSTR method = (void*)0xdeadbeef;
3157 hres = IHTMLFormElement_get_method(form, &method);
3158 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
3160 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
3162 ok_(__FILE__,line)(!method, "method=%p\n", method);
3164 SysFreeString(method);
3165 IHTMLFormElement_Release(form);
3168 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
3169 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
3171 IHTMLFormElement *form = _get_form_iface(line, unk);
3172 BSTR tmp = a2bstr(method);
3175 hres = IHTMLFormElement_put_method(form, tmp);
3176 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
3178 IHTMLFormElement_Release(form);
3180 if(exp_hres == S_OK)
3181 _test_form_method(line, unk, method);
3184 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
3185 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
3187 IHTMLFormElement *form = _get_form_iface(line, unk);
3188 BSTR name = (void*)0xdeadbeef;
3191 hres = IHTMLFormElement_get_name(form, &name);
3192 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
3194 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
3196 ok_(__FILE__,line)(!name, "name=%p\n", name);
3198 SysFreeString(name);
3199 IHTMLFormElement_Release(form);
3202 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
3203 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
3205 IHTMLFormElement *form = _get_form_iface(line, unk);
3206 BSTR tmp = a2bstr(name);
3209 hres = IHTMLFormElement_put_name(form, tmp);
3210 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
3212 IHTMLFormElement_Release(form);
3214 _test_form_name(line, unk, name);
3217 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
3218 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
3220 IHTMLFormElement *form = _get_form_iface(line, unk);
3221 BSTR encoding = (void*)0xdeadbeef;
3224 hres = IHTMLFormElement_get_encoding(form, &encoding);
3225 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
3227 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
3229 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
3231 SysFreeString(encoding);
3232 IHTMLFormElement_Release(form);
3235 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
3236 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
3238 IHTMLFormElement *form = _get_form_iface(line, unk);
3239 BSTR tmp = a2bstr(encoding);
3242 hres = IHTMLFormElement_put_encoding(form, tmp);
3243 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
3245 IHTMLFormElement_Release(form);
3247 if(exp_hres == S_OK)
3248 _test_form_encoding(line, unk, encoding);
3251 #define test_form_elements(a) _test_form_elements(__LINE__,a)
3252 static void _test_form_elements(unsigned line, IUnknown *unk)
3254 IHTMLFormElement *form = _get_form_iface(line, unk);
3259 hres = IHTMLFormElement_get_elements(form, &disp);
3260 ok_(__FILE__,line)(hres == S_OK, "get_elements failed: %08x\n", hres);
3261 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
3262 ok_(__FILE__,line)(iface_cmp((IUnknown*)form, (IUnknown*)disp), "disp != form\n");
3264 IDispatch_Release(disp);
3265 IHTMLFormElement_Release(form);
3268 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
3269 static void _test_meta_name(unsigned line, IUnknown *unk, const char *exname)
3271 IHTMLMetaElement *meta;
3276 meta = _get_metaelem_iface(line, unk);
3277 hres = IHTMLMetaElement_get_name(meta, &name);
3278 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
3279 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s, expected %s\n", wine_dbgstr_w(name), exname);
3280 SysFreeString(name);
3281 IHTMLMetaElement_Release(meta);
3284 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
3285 static void _test_meta_content(unsigned line, IUnknown *unk, const char *excontent)
3287 IHTMLMetaElement *meta;
3288 BSTR content = NULL;
3292 meta = _get_metaelem_iface(line, unk);
3293 hres = IHTMLMetaElement_get_content(meta, &content);
3294 ok_(__FILE__,line)(hres == S_OK, "get_content failed: %08x\n", hres);
3295 ok_(__FILE__,line)(!strcmp_wa(content, excontent), "content = %s, expected %s\n", wine_dbgstr_w(content), excontent);
3296 SysFreeString(content);
3297 IHTMLMetaElement_Release(meta);
3300 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
3301 static void _test_meta_httpequiv(unsigned line, IUnknown *unk, const char *exval)
3303 IHTMLMetaElement *meta;
3308 meta = _get_metaelem_iface(line, unk);
3309 hres = IHTMLMetaElement_get_httpEquiv(meta, &val);
3310 ok_(__FILE__,line)(hres == S_OK, "get_httpEquiv failed: %08x\n", hres);
3311 ok_(__FILE__,line)(!strcmp_wa(val, exval), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val), exval);
3313 IHTMLMetaElement_Release(meta);
3316 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
3317 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
3319 IHTMLElement *elem = _get_elem_iface(line, unk);
3320 IHTMLDocument2 *doc;
3325 hres = IHTMLElement_get_document(elem, &disp);
3326 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3327 ok(disp != NULL, "disp == NULL\n");
3329 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
3330 IDispatch_Release(disp);
3331 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
3336 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
3337 static IHTMLDOMAttribute *_get_elem_attr_node(unsigned line, IUnknown *unk, const char *attr_name, BOOL expect_success)
3339 IHTMLElement4 *elem = _get_elem4_iface(line, unk);
3340 BSTR str = a2bstr(attr_name);
3341 IHTMLDOMAttribute *attr;
3344 attr = (void*)0xdeadbeef;
3345 hres = IHTMLElement4_getAttributeNode(elem, str, &attr);
3346 ok_(__FILE__,line)(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
3348 ok_(__FILE__,line)(attr != NULL, "attr = NULL\n");
3350 ok_(__FILE__,line)(!attr, "attr = %p\n", attr);
3352 IHTMLElement4_Release(elem);
3357 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
3358 static void _get_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT *v, VARTYPE vt)
3362 hres = IHTMLDOMAttribute_get_nodeValue(attr, v);
3363 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
3364 ok_(__FILE__,line) (V_VT(v) == vt, "vt=%d, expected %d\n", V_VT(v), vt);
3367 #define get_window_doc(e) _get_window_doc(__LINE__,e)
3368 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
3370 IHTMLDocument2 *doc;
3374 hres = IHTMLWindow2_get_document(window, &doc);
3375 ok(hres == S_OK, "get_document failed: %08x\n", hres);
3376 ok(doc != NULL, "disp == NULL\n");
3381 #define doc_get_body(d) _doc_get_body(__LINE__,d)
3382 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
3387 hres = IHTMLDocument2_get_body(doc, &elem);
3388 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
3389 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
3394 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
3395 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
3397 IHTMLElement *elem = NULL;
3402 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
3403 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3404 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
3410 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
3411 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
3413 IHTMLDocument3 *doc3;
3414 IHTMLDOMNode *node = NULL;
3418 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3419 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
3422 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
3423 IHTMLDocument3_Release(doc3);
3425 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3426 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
3431 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
3432 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
3434 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3435 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
3436 IHTMLDOMNode *new_child = NULL;
3439 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
3440 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
3441 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3442 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3444 IHTMLDOMNode_Release(node);
3445 IHTMLDOMNode_Release(child);
3450 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
3451 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
3453 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3454 IHTMLDOMNode *new_child = NULL;
3457 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
3458 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
3459 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3460 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3462 IHTMLDOMNode_Release(node);
3467 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
3468 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
3470 IHTMLDOMNode *node = _get_node_iface(line, unk);
3471 IHTMLDOMNode *new_node = NULL;
3474 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
3475 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
3476 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
3477 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
3479 IHTMLDOMNode_Release(node);
3480 IHTMLDOMNode_Release(new_node);
3483 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
3484 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
3489 hres = IHTMLDocument2_get_title(doc, &title);
3490 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3491 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
3492 SysFreeString(title);
3495 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3496 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3501 tmp = a2bstr(title);
3502 hres = IHTMLDocument2_put_title(doc, tmp);
3503 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3507 static void test_elem_bounding_client_rect(IUnknown *unk)
3509 IHTMLRect *rect, *rect2;
3510 IHTMLElement2 *elem2;
3514 elem2 = get_elem2_iface(unk);
3515 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3516 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3517 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3518 IHTMLElement2_Release(elem2);
3519 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3520 ok(rect != NULL, "rect == NULL\n");
3521 ok(rect != rect2, "rect == rect2\n");
3522 IHTMLRect_Release(rect2);
3524 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3527 hres = IHTMLRect_get_top(rect, &l);
3528 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3529 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3532 hres = IHTMLRect_get_left(rect, &l);
3533 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3534 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3537 hres = IHTMLRect_get_bottom(rect, &l);
3538 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3539 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3542 hres = IHTMLRect_get_right(rect, &l);
3543 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3544 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3546 IHTMLRect_Release(rect);
3549 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3550 const elem_type_t *elem_types, LONG len)
3553 VARIANT name, index;
3557 V_VT(&index) = VT_EMPTY;
3558 V_VT(&name) = VT_BSTR;
3559 V_BSTR(&name) = a2bstr(n);
3561 hres = IHTMLElementCollection_item(col, name, index, &disp);
3562 ok(hres == S_OK, "item failed: %08x\n", hres);
3564 test_elem_collection((IUnknown*)disp, elem_types, len);
3565 IDispatch_Release(disp);
3567 V_VT(&index) = VT_I4;
3569 for(i=0; i<len; i++) {
3571 disp = (void*)0xdeadbeef;
3572 hres = IHTMLElementCollection_item(col, name, index, &disp);
3573 ok(hres == S_OK, "item failed: %08x\n", hres);
3574 ok(disp != NULL, "disp == NULL\n");
3575 if(FAILED(hres) || !disp)
3578 test_elem_type((IUnknown*)disp, elem_types[i]);
3580 IDispatch_Release(disp);
3584 disp = (void*)0xdeadbeef;
3585 hres = IHTMLElementCollection_item(col, name, index, &disp);
3586 ok(hres == S_OK, "item failed: %08x\n", hres);
3587 ok(disp == NULL, "disp != NULL\n");
3590 disp = (void*)0xdeadbeef;
3591 hres = IHTMLElementCollection_item(col, name, index, &disp);
3592 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3593 ok(disp == NULL, "disp != NULL\n");
3595 SysFreeString(V_BSTR(&name));
3598 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3600 IHTMLElementCollection *col;
3602 IDispatch *disp = (void*)0xdeadbeef;
3603 VARIANT name, index;
3606 hres = IHTMLDocument2_get_all(doc, &col);
3607 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3608 ok(col != NULL, "col == NULL\n");
3609 if(FAILED(hres) || !col)
3612 V_VT(&index) = VT_EMPTY;
3613 V_VT(&name) = VT_BSTR;
3614 V_BSTR(&name) = a2bstr(id);
3616 hres = IHTMLElementCollection_item(col, name, index, &disp);
3617 IHTMLElementCollection_Release(col);
3618 SysFreeString(V_BSTR(&name));
3619 ok(hres == S_OK, "item failed: %08x\n", hres);
3620 if(!expect_success) {
3621 ok(disp == NULL, "disp != NULL\n");
3625 ok(disp != NULL, "disp == NULL\n");
3629 elem = get_elem_iface((IUnknown*)disp);
3630 IDispatch_Release(disp);
3635 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3637 IHTMLDocument3 *doc3;
3642 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3643 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3646 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3648 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3650 IHTMLDocument3_Release(doc3);
3655 static void test_select_elem(IHTMLSelectElement *select)
3657 IDispatch *disp, *disp2;
3658 VARIANT name, index;
3661 test_select_type(select, "select-one");
3662 test_select_length(select, 2);
3663 test_select_selidx(select, 0);
3664 test_select_put_selidx(select, 1);
3666 test_select_set_value(select, "val1");
3667 test_select_value(select, "val1");
3669 test_select_get_disabled(select, VARIANT_FALSE);
3670 test_select_set_disabled(select, VARIANT_TRUE);
3671 test_select_set_disabled(select, VARIANT_FALSE);
3674 hres = IHTMLSelectElement_get_options(select, &disp);
3675 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3676 ok(disp != NULL, "options == NULL\n");
3677 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3678 IDispatch_Release(disp);
3680 V_VT(&index) = VT_EMPTY;
3681 V_VT(&name) = VT_I4;
3683 disp = (void*)0xdeadbeef;
3684 hres = IHTMLSelectElement_item(select, name, index, &disp);
3685 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3686 ok(!disp, "disp = %p\n", disp);
3689 disp = (void*)0xdeadbeef;
3690 hres = IHTMLSelectElement_item(select, name, index, &disp);
3691 ok(hres == S_OK, "item failed: %08x\n", hres);
3692 ok(!disp, "disp = %p\n", disp);
3695 hres = IHTMLSelectElement_item(select, name, index, NULL);
3696 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3699 hres = IHTMLSelectElement_item(select, name, index, &disp);
3700 ok(hres == S_OK, "item failed: %08x\n", hres);
3701 ok(disp != NULL, "disp = NULL\n");
3702 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3704 V_VT(&index) = VT_I4;
3707 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3708 ok(hres == S_OK, "item failed: %08x\n", hres);
3709 ok(disp2 != NULL, "disp = NULL\n");
3710 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3711 IDispatch_Release(disp2);
3712 IDispatch_Release(disp);
3715 static void test_form_item(IHTMLElement *elem)
3717 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3718 IDispatch *disp, *disp2;
3719 VARIANT name, index;
3722 V_VT(&index) = VT_EMPTY;
3723 V_VT(&name) = VT_I4;
3725 disp = (void*)0xdeadbeef;
3726 hres = IHTMLFormElement_item(form, name, index, &disp);
3727 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3728 ok(!disp, "disp = %p\n", disp);
3731 disp = (void*)0xdeadbeef;
3732 hres = IHTMLFormElement_item(form, name, index, &disp);
3733 ok(hres == S_OK, "item failed: %08x\n", hres);
3734 ok(!disp, "disp = %p\n", disp);
3737 hres = IHTMLFormElement_item(form, name, index, NULL);
3738 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3741 hres = IHTMLFormElement_item(form, name, index, &disp);
3742 ok(hres == S_OK, "item failed: %08x\n", hres);
3743 ok(disp != NULL, "disp = NULL\n");
3744 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3746 V_VT(&index) = VT_I4;
3749 hres = IHTMLFormElement_item(form, name, index, &disp2);
3750 ok(hres == S_OK, "item failed: %08x\n", hres);
3751 ok(disp2 != NULL, "disp = NULL\n");
3752 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3753 IDispatch_Release(disp2);
3754 IDispatch_Release(disp);
3757 static void test_create_option_elem(IHTMLDocument2 *doc)
3759 IHTMLOptionElement *option;
3761 option = create_option_elem(doc, "test text", "test value");
3763 test_option_put_text(option, "new text");
3764 test_option_put_value(option, "new value");
3765 test_option_put_selected(option, VARIANT_TRUE);
3766 test_option_put_selected(option, VARIANT_FALSE);
3768 IHTMLOptionElement_Release(option);
3771 static void test_create_img_elem(IHTMLDocument2 *doc)
3773 IHTMLImgElement *img;
3775 img = create_img_elem(doc, 10, 15);
3778 test_img_put_width(img, 5);
3779 test_img_put_height(img, 20);
3781 IHTMLImgElement_Release(img);
3785 img = create_img_elem(doc, -1, -1);
3788 test_img_put_width(img, 5);
3789 test_img_put_height(img, 20);
3791 IHTMLImgElement_Release(img);
3795 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3797 IHTMLBodyElement *body;
3798 IHTMLTxtRange *range;
3802 elem = doc_get_body(doc);
3803 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3804 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3805 IHTMLElement_Release(elem);
3807 hres = IHTMLBodyElement_createTextRange(body, &range);
3808 IHTMLBodyElement_Release(body);
3809 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3814 static void test_txtrange(IHTMLDocument2 *doc)
3816 IHTMLTxtRange *body_range, *range, *range2;
3817 IHTMLSelectionObject *selection;
3818 IDispatch *disp_range;
3821 body_range = test_create_body_range(doc);
3823 test_range_text(body_range, "test abc 123\r\nit's text");
3825 hres = IHTMLTxtRange_duplicate(body_range, &range);
3826 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3828 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3829 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3830 test_range_isequal(range, range2, VARIANT_TRUE);
3832 test_range_text(range, "test abc 123\r\nit's text");
3833 test_range_text(body_range, "test abc 123\r\nit's text");
3835 test_range_collapse(range, TRUE);
3836 test_range_isequal(range, range2, VARIANT_FALSE);
3837 test_range_inrange(range, range2, VARIANT_FALSE);
3838 test_range_inrange(range2, range, VARIANT_TRUE);
3839 IHTMLTxtRange_Release(range2);
3841 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3842 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3843 test_range_move(range, characterW, 2, 2);
3844 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3846 test_range_collapse(range, FALSE);
3847 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3849 test_range_collapse(range, FALSE);
3850 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3851 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3852 test_range_move(range, characterW, 2, 2);
3853 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3854 test_range_moveend(range, characterW, -5, -5);
3855 test_range_text(range, NULL);
3856 test_range_moveend(range, characterW, 3, 3);
3857 test_range_text(range, "c 1");
3858 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3859 test_range_collapse(range, TRUE);
3860 test_range_move(range, characterW, 4, 4);
3861 test_range_moveend(range, characterW, 1, 1);
3862 test_range_text(range, " ");
3863 test_range_move(range, wordW, 1, 1);
3864 test_range_moveend(range, characterW, 2, 2);
3865 test_range_text(range, "ab");
3867 IHTMLTxtRange_Release(range);
3869 hres = IHTMLTxtRange_duplicate(body_range, &range);
3870 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3872 test_range_text(range, "test abc 123\r\nit's text");
3873 test_range_move(range, characterW, 3, 3);
3874 test_range_moveend(range, characterW, 1, 1);
3875 test_range_text(range, "t");
3876 test_range_moveend(range, characterW, 3, 3);
3877 test_range_text(range, "t ab");
3878 test_range_moveend(range, characterW, -2, -2);
3879 test_range_text(range, "t ");
3880 test_range_move(range, characterW, 6, 6);
3881 test_range_moveend(range, characterW, 3, 3);
3882 test_range_text(range, "123");
3883 test_range_moveend(range, characterW, 2, 2);
3884 test_range_text(range, "123\r\ni");
3886 IHTMLTxtRange_Release(range);
3888 hres = IHTMLTxtRange_duplicate(body_range, &range);
3889 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3891 test_range_move(range, wordW, 1, 1);
3892 test_range_moveend(range, characterW, 2, 2);
3893 test_range_text(range, "ab");
3895 test_range_move(range, characterW, -2, -2);
3896 test_range_moveend(range, characterW, 2, 2);
3897 test_range_text(range, "t ");
3899 test_range_move(range, wordW, 3, 3);
3900 test_range_move(range, wordW, -2, -2);
3901 test_range_moveend(range, characterW, 2, 2);
3902 test_range_text(range, "ab");
3904 test_range_move(range, characterW, -6, -5);
3905 test_range_moveend(range, characterW, -1, 0);
3906 test_range_moveend(range, characterW, -6, 0);
3907 test_range_move(range, characterW, 2, 2);
3908 test_range_moveend(range, characterW, 2, 2);
3909 test_range_text(range, "st");
3910 test_range_moveend(range, characterW, -6, -4);
3911 test_range_moveend(range, characterW, 2, 2);
3913 IHTMLTxtRange_Release(range);
3915 hres = IHTMLTxtRange_duplicate(body_range, &range);
3916 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3918 test_range_move(range, wordW, 2, 2);
3919 test_range_moveend(range, characterW, 2, 2);
3920 test_range_text(range, "12");
3922 test_range_move(range, characterW, 15, 14);
3923 test_range_move(range, characterW, -2, -2);
3924 test_range_moveend(range, characterW, 3, 2);
3925 test_range_text(range, "t");
3926 test_range_moveend(range, characterW, -1, -1);
3927 test_range_text(range, "t");
3928 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3929 test_range_move(range, characterW, -2, -2);
3930 test_range_moveend(range, characterW, 2, 2);
3931 test_range_text(range, "s ");
3932 test_range_move(range, characterW, 100, 7);
3933 test_range_move(range, wordW, 1, 0);
3934 test_range_move(range, characterW, -2, -2);
3935 test_range_moveend(range, characterW, 3, 2);
3936 test_range_text(range, "t");
3938 IHTMLTxtRange_Release(range);
3940 hres = IHTMLTxtRange_duplicate(body_range, &range);
3941 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3943 test_range_collapse(range, TRUE);
3944 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3945 test_range_put_text(range, "word");
3946 test_range_text(body_range, "wordabc 123\r\nit's text");
3947 test_range_text(range, NULL);
3948 test_range_moveend(range, characterW, 3, 3);
3949 test_range_text(range, "abc");
3950 test_range_movestart(range, characterW, -2, -2);
3951 test_range_text(range, "rdabc");
3952 test_range_movestart(range, characterW, 3, 3);
3953 test_range_text(range, "bc");
3954 test_range_movestart(range, characterW, 4, 4);
3955 test_range_text(range, NULL);
3956 test_range_movestart(range, characterW, -3, -3);
3957 test_range_text(range, "c 1");
3958 test_range_movestart(range, characterW, -7, -6);
3959 test_range_text(range, "wordabc 1");
3960 test_range_movestart(range, characterW, 100, 22);
3961 test_range_text(range, NULL);
3963 IHTMLTxtRange_Release(range);
3964 IHTMLTxtRange_Release(body_range);
3966 hres = IHTMLDocument2_get_selection(doc, &selection);
3967 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3969 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3970 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3971 IHTMLSelectionObject_Release(selection);
3973 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3974 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3975 IDispatch_Release(disp_range);
3977 test_range_text(range, NULL);
3978 test_range_moveend(range, characterW, 3, 3);
3979 test_range_text(range, "wor");
3980 test_range_parent(range, ET_BODY);
3981 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3982 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3983 test_range_move(range, characterW, 3, 3);
3984 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3985 test_range_moveend(range, characterW, -4, -4);
3986 test_range_put_text(range, "abc def ");
3987 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3988 test_range_move(range, wordW, 1, 1);
3989 test_range_movestart(range, characterW, -1, -1);
3990 test_range_text(range, " ");
3991 test_range_move(range, wordW, 1, 1);
3992 test_range_moveend(range, characterW, 3, 3);
3993 test_range_text(range, "def");
3994 test_range_put_text(range, "xyz");
3995 test_range_moveend(range, characterW, 1, 1);
3996 test_range_move(range, wordW, 1, 1);
3997 test_range_moveend(range, characterW, 2, 2);
3998 test_range_text(range, "ab");
4000 IHTMLTxtRange_Release(range);
4003 static void test_txtrange2(IHTMLDocument2 *doc)
4005 IHTMLTxtRange *range;
4007 range = test_create_body_range(doc);
4009 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
4010 test_range_move(range, characterW, 5, 5);
4011 test_range_moveend(range, characterW, 1, 1);
4012 test_range_text(range, "2");
4013 test_range_move(range, characterW, -3, -3);
4014 test_range_moveend(range, characterW, 3, 3);
4015 test_range_text(range, "c\r\n\r\n1");
4016 test_range_collapse(range, VARIANT_FALSE);
4017 test_range_moveend(range, characterW, 4, 4);
4018 test_range_text(range, "23");
4019 test_range_moveend(range, characterW, 1, 1);
4020 test_range_text(range, "23\r\n\r\n\r\nd");
4021 test_range_moveend(range, characterW, -1, -1);
4022 test_range_text(range, "23");
4023 test_range_moveend(range, characterW, -1, -1);
4024 test_range_text(range, "23");
4025 test_range_moveend(range, characterW, -2, -2);
4026 test_range_text(range, "2");
4028 IHTMLTxtRange_Release(range);
4031 static void test_compatmode(IHTMLDocument2 *doc)
4033 IHTMLDocument5 *doc5;
4037 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
4038 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
4042 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
4043 IHTMLDocument5_Release(doc5);
4044 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
4045 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
4046 SysFreeString(mode);
4049 static void test_location(IHTMLDocument2 *doc)
4051 IHTMLLocation *location, *location2;
4052 IHTMLWindow2 *window;
4057 hres = IHTMLDocument2_get_location(doc, &location);
4058 ok(hres == S_OK, "get_location failed: %08x\n", hres);
4060 hres = IHTMLDocument2_get_location(doc, &location2);
4061 ok(hres == S_OK, "get_location failed: %08x\n", hres);
4063 ok(location == location2, "location != location2\n");
4064 IHTMLLocation_Release(location2);
4066 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4067 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4069 hres = IHTMLWindow2_get_location(window, &location2);
4070 ok(hres == S_OK, "get_location failed: %08x\n", hres);
4071 ok(location == location2, "location != location2\n");
4072 IHTMLLocation_Release(location2);
4074 test_ifaces((IUnknown*)location, location_iids);
4075 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
4077 hres = IHTMLLocation_get_pathname(location, &str);
4078 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
4079 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
4082 hres = IHTMLLocation_get_href(location, NULL);
4083 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
4085 hres = IHTMLLocation_get_href(location, &str);
4086 ok(hres == S_OK, "get_href failed: %08x\n", hres);
4087 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
4090 ref = IHTMLLocation_Release(location);
4091 ok(!ref, "location chould be destroyed here\n");
4094 static void test_plugins_col(IHTMLDocument2 *doc)
4096 IHTMLPluginsCollection *col, *col2;
4097 IHTMLWindow2 *window;
4103 window = get_doc_window(doc);
4104 hres = IHTMLWindow2_get_navigator(window, &nav);
4105 IHTMLWindow2_Release(window);
4107 hres = IOmNavigator_get_plugins(nav, &col);
4108 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
4110 hres = IOmNavigator_get_plugins(nav, &col2);
4111 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
4112 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
4113 IHTMLPluginsCollection_Release(col2);
4115 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
4118 hres = IHTMLPluginsCollection_get_length(col, &len);
4119 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4120 ok(!len, "length = %d\n", len);
4122 ref = IHTMLPluginsCollection_Release(col);
4123 ok(!ref, "ref=%d\n", ref);
4125 IOmNavigator_Release(nav);
4128 static void test_mime_types_col(IOmNavigator *nav)
4130 IHTMLMimeTypesCollection *col, *col2;
4135 hres = IOmNavigator_get_mimeTypes(nav, &col);
4136 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
4138 hres = IOmNavigator_get_mimeTypes(nav, &col2);
4139 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
4140 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
4141 IHTMLMimeTypesCollection_Release(col2);
4143 test_disp((IUnknown*)col, &IID_IHTMLMimeTypesCollection, "[object]");
4145 length = 0xdeadbeef;
4146 hres = IHTMLMimeTypesCollection_get_length(col, &length);
4147 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4148 ok(!length, "length = %d\n", length);
4150 ref = IHTMLMimeTypesCollection_Release(col);
4151 ok(!ref, "ref=%d\n", ref);
4154 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
4155 static void _test_language_string(unsigned line, const WCHAR *lang, LCID lcid)
4160 if(pLCIDToLocaleName) {
4161 res = pLCIDToLocaleName(lcid, buf, sizeof(buf)/sizeof(WCHAR), 0);
4162 ok_(__FILE__,line)(res, "LCIDToLocaleName failed: %u\n", GetLastError());
4163 ok_(__FILE__,line)(!lstrcmpW(lang, buf), "lang = %s, expected %s\n", wine_dbgstr_w(lang), wine_dbgstr_w(buf));
4165 win_skip("LCIDToLocaleName not available, unable to test language string\n");
4166 ok_(__FILE__,line)(lang != NULL, "lang == NULL\n");
4170 static void test_navigator(IHTMLDocument2 *doc)
4172 IHTMLWindow2 *window;
4173 IOmNavigator *navigator, *navigator2;
4180 static const WCHAR v40[] = {'4','.','0'};
4182 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4183 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
4185 hres = IHTMLWindow2_get_navigator(window, &navigator);
4186 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
4187 ok(navigator != NULL, "navigator == NULL\n");
4188 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
4190 hres = IHTMLWindow2_get_navigator(window, &navigator2);
4191 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
4192 ok(navigator != navigator2, "navigator2 != navihgator\n");
4194 IHTMLWindow2_Release(window);
4195 IOmNavigator_Release(navigator2);
4197 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
4198 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
4199 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
4200 SysFreeString(bstr);
4203 hres = IOmNavigator_get_appName(navigator, &bstr);
4204 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
4205 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
4206 SysFreeString(bstr);
4209 hres = IOmNavigator_get_platform(navigator, &bstr);
4210 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
4211 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "Win64" : "Win32")
4212 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr));
4213 SysFreeString(bstr);
4216 hres = IOmNavigator_get_cpuClass(navigator, &bstr);
4217 ok(hres == S_OK, "get_cpuClass failed: %08x\n", hres);
4218 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr));
4219 SysFreeString(bstr);
4222 hres = IOmNavigator_get_appVersion(navigator, &bstr);
4223 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
4224 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
4225 SysFreeString(bstr);
4228 hres = IOmNavigator_get_systemLanguage(navigator, &bstr);
4229 ok(hres == S_OK, "get_systemLanguage failed: %08x\n", hres);
4230 test_language_string(bstr, LOCALE_SYSTEM_DEFAULT);
4231 SysFreeString(bstr);
4233 if (pGetUserDefaultUILanguage)
4236 hres = IOmNavigator_get_browserLanguage(navigator, &bstr);
4237 ok(hres == S_OK, "get_browserLanguage failed: %08x\n", hres);
4238 test_language_string(bstr, pGetUserDefaultUILanguage());
4239 SysFreeString(bstr);
4242 win_skip("GetUserDefaultUILanguage not available\n");
4245 hres = IOmNavigator_get_userLanguage(navigator, &bstr);
4246 ok(hres == S_OK, "get_userLanguage failed: %08x\n", hres);
4247 test_language_string(bstr, LOCALE_USER_DEFAULT);
4248 SysFreeString(bstr);
4250 hres = IOmNavigator_toString(navigator, NULL);
4251 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4254 hres = IOmNavigator_toString(navigator, &bstr);
4255 ok(hres == S_OK, "toString failed: %08x\n", hres);
4256 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
4257 SysFreeString(bstr);
4260 hres = ObtainUserAgentString(0, buf, &size);
4261 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
4264 hres = IOmNavigator_get_userAgent(navigator, &bstr);
4265 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
4266 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
4267 SysFreeString(bstr);
4269 if(!strncmp(buf, "Mozilla/", 8)) {
4271 hres = IOmNavigator_get_appVersion(navigator, &bstr);
4272 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
4273 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
4274 SysFreeString(bstr);
4276 skip("nonstandard user agent\n");
4280 hres = IOmNavigator_get_appMinorVersion(navigator, &bstr);
4281 ok(hres == S_OK, "get_appMonorVersion failed: %08x\n", hres);
4282 ok(bstr != NULL, "appMinorVersion returned NULL\n");
4283 SysFreeString(bstr);
4285 test_mime_types_col(navigator);
4287 ref = IOmNavigator_Release(navigator);
4288 ok(!ref, "navigator should be destroyed here\n");
4291 static void test_screen(IHTMLWindow2 *window)
4293 IHTMLScreen *screen, *screen2;
4294 IDispatchEx *dispex;
4301 hres = IHTMLWindow2_get_screen(window, &screen);
4302 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
4303 ok(screen != NULL, "screen == NULL\n");
4306 hres = IHTMLWindow2_get_screen(window, &screen2);
4307 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
4308 ok(screen2 != NULL, "screen == NULL\n");
4309 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
4310 IHTMLScreen_Release(screen2);
4312 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
4313 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
4314 if(SUCCEEDED(hres)) {
4315 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
4316 IDispatchEx_Release(dispex);
4319 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
4321 exl = GetDeviceCaps(hdc, HORZRES);
4323 hres = IHTMLScreen_get_width(screen, &l);
4324 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4325 ok(l == exl, "width = %d, expected %d\n", l, exl);
4327 exl = GetDeviceCaps(hdc, VERTRES);
4329 hres = IHTMLScreen_get_height(screen, &l);
4330 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4331 ok(l == exl, "height = %d, expected %d\n", l, exl);
4333 exl = GetDeviceCaps(hdc, BITSPIXEL);
4335 hres = IHTMLScreen_get_colorDepth(screen, &l);
4336 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4337 ok(l == exl, "height = %d, expected %d\n", l, exl);
4341 SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0);
4344 hres = IHTMLScreen_get_availHeight(screen, &l);
4345 ok(hres == S_OK, "get_availHeight failed: %08x\n", hres);
4346 ok(l == work_area.bottom-work_area.top, "availHeight = %d, expected %d\n", l, work_area.bottom-work_area.top);
4349 hres = IHTMLScreen_get_availWidth(screen, &l);
4350 ok(hres == S_OK, "get_availWidth failed: %08x\n", hres);
4351 ok(l == work_area.right-work_area.left, "availWidth = %d, expected %d\n", l, work_area.right-work_area.left);
4353 IHTMLScreen_Release(screen);
4356 static void test_default_selection(IHTMLDocument2 *doc)
4358 IHTMLSelectionObject *selection;
4359 IHTMLTxtRange *range;
4364 hres = IHTMLDocument2_get_selection(doc, &selection);
4365 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4367 hres = IHTMLSelectionObject_get_type(selection, &str);
4368 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4369 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4372 hres = IHTMLSelectionObject_createRange(selection, &disp);
4373 IHTMLSelectionObject_Release(selection);
4374 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4376 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4377 IDispatch_Release(disp);
4378 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4380 test_range_text(range, NULL);
4381 IHTMLTxtRange_Release(range);
4384 static void test_doc_elem(IHTMLDocument2 *doc)
4386 IHTMLDocument2 *doc_node, *owner_doc;
4388 IHTMLDocument3 *doc3;
4391 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4392 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4394 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4395 IHTMLDocument3_Release(doc3);
4396 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4398 test_node_name((IUnknown*)elem, "HTML");
4399 test_elem_tag((IUnknown*)elem, "HTML");
4401 doc_node = get_doc_node(doc);
4402 owner_doc = get_owner_doc((IUnknown*)elem);
4403 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4404 IHTMLDocument2_Release(owner_doc);
4406 owner_doc = get_owner_doc((IUnknown*)doc_node);
4407 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4408 IHTMLDocument2_Release(doc_node);
4410 test_elem_client_rect((IUnknown*)elem);
4412 IHTMLElement_Release(elem);
4415 static void test_default_body(IHTMLBodyElement *body)
4422 bstr = (void*)0xdeadbeef;
4423 hres = IHTMLBodyElement_get_background(body, &bstr);
4424 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4425 ok(bstr == NULL, "bstr != NULL\n");
4427 l = elem_get_scroll_height((IUnknown*)body);
4428 ok(l != -1, "scrollHeight == -1\n");
4429 l = elem_get_scroll_width((IUnknown*)body);
4430 ok(l != -1, "scrollWidth == -1\n");
4431 l = elem_get_scroll_top((IUnknown*)body);
4432 ok(!l, "scrollTop = %d\n", l);
4433 elem_get_scroll_left((IUnknown*)body);
4435 /* get_text tests */
4436 hres = IHTMLBodyElement_get_text(body, &v);
4437 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4438 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4439 ok(V_BSTR(&v) == NULL, "bstr != NULL\n");
4441 /* get_text - Invalid Text */
4443 V_BSTR(&v) = a2bstr("Invalid");
4444 hres = IHTMLBodyElement_put_text(body, v);
4445 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4449 hres = IHTMLBodyElement_get_text(body, &v);
4450 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4451 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4452 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
4455 /* get_text - Valid Text */
4457 V_BSTR(&v) = a2bstr("#FF0000");
4458 hres = IHTMLBodyElement_put_text(body, v);
4459 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4463 hres = IHTMLBodyElement_get_text(body, &v);
4464 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4465 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4466 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
4470 static void test_body_funs(IHTMLBodyElement *body)
4472 VARIANT vbg, vDefaultbg;
4475 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4476 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4477 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4478 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
4480 V_VT(&vbg) = VT_BSTR;
4481 V_BSTR(&vbg) = a2bstr("red");
4482 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4483 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4486 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4487 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4488 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4489 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4492 /* Restore Originial */
4493 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4494 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4495 VariantClear(&vDefaultbg);
4498 static void test_history(IHTMLWindow2 *window)
4500 IOmHistory *history, *history2;
4504 hres = IHTMLWindow2_get_history(window, &history);
4505 ok(hres == S_OK, "get_history failed: %08x\n", hres);
4506 ok(history != NULL, "history = NULL\n");
4508 test_disp2((IUnknown*)history, &DIID_DispHTMLHistory, &IID_IOmHistory, "[object]");
4511 hres = IHTMLWindow2_get_history(window, &history2);
4512 ok(hres == S_OK, "get_history failed: %08x\n", hres);
4513 ok(history2 != NULL, "history2 = NULL\n");
4514 ok(iface_cmp((IUnknown*)history, (IUnknown*)history2), "history != history2\n");
4516 IOmHistory_Release(history2);
4517 IOmHistory_Release(history);
4520 static void test_window(IHTMLDocument2 *doc)
4522 IHTMLWindow2 *window, *window2, *self, *parent;
4523 IHTMLDocument2 *doc2 = NULL;
4530 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4531 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4532 test_ifaces((IUnknown*)window, window_iids);
4533 hres = IDispatch_QueryInterface(window, &IID_ITravelLogClient, (void**)&unk);
4535 IUnknown_Release(unk);
4537 win_skip("IID_ITravelLogClient not supported\n");
4539 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4541 hres = IHTMLWindow2_get_document(window, &doc2);
4542 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4543 ok(doc2 != NULL, "doc2 == NULL\n");
4545 test_ifaces((IUnknown*)doc2, doc_node_iids);
4546 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4547 test_class_info((IUnknown*)doc2);
4549 test_ifaces((IUnknown*)doc, doc_obj_iids);
4550 test_disp((IUnknown*)doc, &DIID_DispHTMLDocument, "[object]");
4551 test_class_info((IUnknown*)doc);
4553 unk = (void*)0xdeadbeef;
4554 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4555 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4556 ok(!unk, "unk = %p\n", unk);
4558 IHTMLDocument_Release(doc2);
4560 hres = IHTMLWindow2_get_window(window, &window2);
4561 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4562 ok(window2 != NULL, "window2 == NULL\n");
4564 hres = IHTMLWindow2_get_self(window, &self);
4565 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4566 ok(window2 != NULL, "self == NULL\n");
4568 ok(self == window2, "self != window2\n");
4570 IHTMLWindow2_Release(window2);
4573 hres = IHTMLDocument2_get_Script(doc, &disp);
4574 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4575 ok(disp == (void*)window, "disp != window\n");
4576 IDispatch_Release(disp);
4578 hres = IHTMLWindow2_toString(window, NULL);
4579 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4582 hres = IHTMLWindow2_toString(window, &str);
4583 ok(hres == S_OK, "toString failed: %08x\n", hres);
4584 ok(!strcmp_wa(str, "[object]") ||
4585 !strcmp_wa(str, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str));
4588 V_VT(&v) = VT_ERROR;
4589 hres = IHTMLWindow2_get_opener(window, &v);
4590 ok(hres == S_OK, "get_opener failed: %08x\n", hres);
4591 ok(V_VT(&v) == VT_EMPTY, "V_VT(opener) = %d\n", V_VT(&v));
4594 hres = IHTMLWindow2_get_parent(window, &parent);
4595 ok(hres == S_OK, "get_parent failed: %08x\n", hres);
4596 ok(parent != NULL, "parent == NULL\n");
4597 ok(parent == self, "parent != window\n");
4598 IHTMLWindow2_Release(parent);
4599 IHTMLWindow2_Release(self);
4601 test_window_name(window, NULL);
4602 set_window_name(window, "test");
4603 test_window_length(window, 0);
4604 test_screen(window);
4605 test_window_status(window);
4606 set_window_status(window, "Test!");
4607 test_history(window);
4609 IHTMLWindow2_Release(window);
4612 static void test_defaults(IHTMLDocument2 *doc)
4614 IHTMLStyleSheetsCollection *stylesheetcol;
4615 IHTMLCurrentStyle *cstyle;
4616 IHTMLBodyElement *body;
4617 IHTMLElement2 *elem2;
4622 IHTMLElementCollection *collection;
4624 elem = doc_get_body(doc);
4626 hres = IHTMLDocument2_get_images(doc, NULL);
4627 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4629 hres = IHTMLDocument2_get_images(doc, &collection);
4630 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4633 test_elem_collection((IUnknown*)collection, NULL, 0);
4634 IHTMLElementCollection_Release(collection);
4637 hres = IHTMLDocument2_get_applets(doc, NULL);
4638 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4640 hres = IHTMLDocument2_get_applets(doc, &collection);
4641 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4644 test_elem_collection((IUnknown*)collection, NULL, 0);
4645 IHTMLElementCollection_Release(collection);
4648 hres = IHTMLDocument2_get_links(doc, NULL);
4649 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4651 hres = IHTMLDocument2_get_links(doc, &collection);
4652 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4655 test_elem_collection((IUnknown*)collection, NULL, 0);
4656 IHTMLElementCollection_Release(collection);
4659 hres = IHTMLDocument2_get_forms(doc, NULL);
4660 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4662 hres = IHTMLDocument2_get_forms(doc, &collection);
4663 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4666 test_elem_collection((IUnknown*)collection, NULL, 0);
4667 IHTMLElementCollection_Release(collection);
4670 hres = IHTMLDocument2_get_anchors(doc, NULL);
4671 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4673 hres = IHTMLDocument2_get_anchors(doc, &collection);
4674 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4677 test_elem_collection((IUnknown*)collection, NULL, 0);
4678 IHTMLElementCollection_Release(collection);
4681 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4682 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4683 test_default_body(body);
4684 test_body_funs(body);
4685 IHTMLBodyElement_Release(body);
4687 hres = IHTMLElement_get_style(elem, &style);
4688 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4690 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4691 test_ifaces((IUnknown*)style, style_iids);
4692 IHTMLStyle_Release(style);
4695 test_compatmode(doc);
4697 test_navigator(doc);
4698 test_plugins_col(doc);
4700 elem2 = get_elem2_iface((IUnknown*)elem);
4701 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4702 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4703 if(SUCCEEDED(hres)) {
4706 test_disp((IUnknown*)cstyle, &DIID_DispHTMLCurrentStyle, "[object]");
4707 test_ifaces((IUnknown*)cstyle, cstyle_iids);
4709 hres = IHTMLCurrentStyle_QueryInterface(cstyle, &IID_IHTMLCurrentStyle4, (void**)&unk);
4711 IUnknown_Release(unk);
4714 /*IE6 doesn't have interface */
4715 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
4718 IHTMLCurrentStyle_Release(cstyle);
4720 IHTMLElement2_Release(elem2);
4722 IHTMLElement_Release(elem);
4724 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4725 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4728 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4729 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4730 ok(l == 0, "length = %d\n", l);
4732 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4734 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
4735 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
4737 test_default_selection(doc);
4738 test_doc_title(doc, "");
4741 static void test_tr_elem(IHTMLElement *elem)
4743 IHTMLElementCollection *col;
4747 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4749 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4750 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4755 hres = IHTMLTableRow_get_cells(row, &col);
4756 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4757 ok(col != NULL, "get_cells returned NULL\n");
4759 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4760 IHTMLElementCollection_Release(col);
4762 IHTMLTable_Release(row);
4765 static void test_table_elem(IHTMLElement *elem)
4767 IHTMLElementCollection *col;
4772 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4773 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4775 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4776 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4781 hres = IHTMLTable_get_rows(table, &col);
4782 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4783 ok(col != NULL, "get_ros returned NULL\n");
4785 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4786 IHTMLElementCollection_Release(col);
4788 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4790 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4791 test_elem_tag((IUnknown*)node, "TABLE");
4792 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4793 IHTMLDOMNode_Release(node);
4795 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4796 test_elem_tag((IUnknown*)node, "TABLE");
4797 test_elem_all((IUnknown*)node, NULL, 0);
4798 IHTMLDOMNode_Release(node);
4800 IHTMLTable_Release(table);
4803 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4812 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4813 SafeArrayAccessData(sa, (void**)&var);
4814 V_VT(var) = VT_BSTR;
4815 V_BSTR(var) = a2bstr(text);
4816 SafeArrayUnaccessData(sa);
4819 hres = IHTMLDocument2_writeln(doc, sa);
4821 hres = IHTMLDocument2_write(doc, sa);
4822 ok(hres == S_OK, "write failed: %08x\n", hres);
4824 SafeArrayDestroy(sa);
4827 static void doc_complex_write(IHTMLDocument2 *doc)
4829 SAFEARRAYBOUND dim = {5, 0};
4834 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4835 SafeArrayAccessData(sa, (void**)&args);
4837 V_VT(args) = VT_BSTR;
4838 V_BSTR(args) = a2bstr("<body i4val=\"");
4839 V_VT(args+1) = VT_I4;
4841 V_VT(args+2) = VT_BSTR;
4842 V_BSTR(args+2) = a2bstr("\" r8val=\"");
4843 V_VT(args+3) = VT_R8;
4844 V_R8(args+3) = 3.14;
4845 V_VT(args+4) = VT_BSTR;
4846 V_BSTR(args+4) = a2bstr("\">");
4847 SafeArrayUnaccessData(sa);
4849 hres = IHTMLDocument2_write(doc, sa);
4850 ok(hres == S_OK, "write failed: %08x\n", hres);
4852 SafeArrayDestroy(sa);
4855 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
4857 IHTMLDocument2 *window_doc, *elem_doc;
4858 IHTMLFrameElement3 *frame_elem3;
4859 IHTMLWindow2 *content_window;
4862 content_window = get_frame_content_window(frame_elem);
4863 window_doc = get_window_doc(content_window);
4864 IHTMLWindow2_Release(content_window);
4866 elem_doc = get_elem_doc(frame_elem);
4867 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
4870 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
4871 if(SUCCEEDED(hres)) {
4872 IDispatch *disp = NULL;
4874 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
4875 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
4876 ok(disp != NULL, "contentDocument == NULL\n");
4877 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
4879 IDispatch_Release(disp);
4880 IHTMLFrameElement3_Release(frame_elem3);
4882 win_skip("IHTMLFrameElement3 not supported\n");
4886 IHTMLDocument2_Release(elem_doc);
4887 IHTMLDocument2_Release(window_doc);
4890 static void test_iframe_elem(IHTMLElement *elem)
4892 IHTMLDocument2 *content_doc, *owner_doc;
4893 IHTMLElementCollection *col;
4894 IHTMLWindow2 *content_window;
4901 static const elem_type_t all_types[] = {
4909 test_frame_doc((IUnknown*)elem, TRUE);
4911 content_window = get_frame_content_window((IUnknown*)elem);
4912 test_window_length(content_window, 0);
4914 content_doc = get_window_doc(content_window);
4915 IHTMLWindow2_Release(content_window);
4917 str = a2bstr("text/html");
4918 V_VT(&errv) = VT_ERROR;
4920 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4922 ok(hres == S_OK, "open failed: %08x\n", hres);
4923 ok(disp != NULL, "disp == NULL\n");
4924 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4925 IDispatch_Release(disp);
4927 doc_write(content_doc, FALSE, "<html><head><title>test</title></head>");
4928 doc_complex_write(content_doc);
4929 doc_write(content_doc, TRUE, "<br />");
4930 doc_write(content_doc, TRUE, "</html>");
4932 hres = IHTMLDocument2_get_all(content_doc, &col);
4933 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4934 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4935 IHTMLElementCollection_Release(col);
4937 body = doc_get_body(content_doc);
4938 test_elem_attr(body, "i4val", "4");
4939 test_elem_attr(body, "r8val", "3.14");
4940 IHTMLElement_Release(body);
4942 hres = IHTMLDocument2_close(content_doc);
4943 ok(hres == S_OK, "close failed: %08x\n", hres);
4945 owner_doc = get_owner_doc((IUnknown*)content_doc);
4946 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4948 IHTMLDocument2_Release(content_doc);
4951 static void test_stylesheet(IDispatch *disp)
4953 IHTMLStyleSheetRulesCollection *col = NULL;
4954 IHTMLStyleSheet *stylesheet;
4957 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4958 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4960 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4961 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4962 ok(col != NULL, "col == NULL\n");
4964 IHTMLStyleSheetRulesCollection_Release(col);
4965 IHTMLStyleSheet_Release(stylesheet);
4968 static void test_stylesheets(IHTMLDocument2 *doc)
4970 IHTMLStyleSheetsCollection *col = NULL;
4975 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4976 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4977 ok(col != NULL, "col == NULL\n");
4979 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
4981 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4982 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4983 ok(len == 1, "len=%d\n", len);
4989 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4990 ok(hres == S_OK, "item failed: %08x\n", hres);
4991 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4992 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4993 test_stylesheet(V_DISPATCH(&res));
5000 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5001 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5002 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5003 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5006 IHTMLStyleSheetsCollection_Release(col);
5009 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5011 IDispatchEx *dispex;
5013 DISPPARAMS dp = {NULL, NULL, 0, 0};
5021 static const WCHAR w0[] = {'0',0};
5022 static const WCHAR w100[] = {'1','0','0',0};
5024 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5025 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5027 bstr = SysAllocString(w0);
5028 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5029 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5030 SysFreeString(bstr);
5033 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5034 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5035 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5036 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5037 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5038 type = get_node_type((IUnknown*)node);
5039 ok(type == 3, "type=%d\n", type);
5040 IHTMLDOMNode_Release(node);
5043 bstr = SysAllocString(w100);
5044 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5045 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5046 SysFreeString(bstr);
5048 IDispatchEx_Release(dispex);
5053 static void test_elems(IHTMLDocument2 *doc)
5055 IHTMLElementCollection *col;
5056 IHTMLDOMChildrenCollection *child_col;
5057 IHTMLElement *elem, *elem2, *elem3;
5058 IHTMLDOMNode *node, *node2;
5059 IHTMLWindow2 *window;
5063 IHTMLElementCollection *collection;
5064 IHTMLDocument3 *doc3;
5067 static const elem_type_t all_types[] = {
5097 static const elem_type_t item_types[] = {
5103 hres = IHTMLDocument2_get_all(doc, &col);
5104 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5105 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5106 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5107 IHTMLElementCollection_Release(col);
5109 hres = IHTMLDocument2_get_images(doc, &collection);
5110 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5113 static const elem_type_t images_types[] = {ET_IMG};
5114 test_elem_collection((IUnknown*)collection, images_types, 1);
5116 IHTMLElementCollection_Release(collection);
5119 hres = IHTMLDocument2_get_links(doc, &collection);
5120 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5123 static const elem_type_t images_types[] = {ET_A};
5124 test_elem_collection((IUnknown*)collection, images_types, 1);
5126 IHTMLElementCollection_Release(collection);
5129 hres = IHTMLDocument2_get_anchors(doc, &collection);
5130 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5133 static const elem_type_t anchor_types[] = {ET_A};
5134 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5136 IHTMLElementCollection_Release(collection);
5139 test_plugins_col(doc);
5141 elem = get_doc_elem(doc);
5142 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5143 IHTMLElement_Release(elem);
5145 get_elem_by_id(doc, "xxx", FALSE);
5146 elem = get_doc_elem_by_id(doc, "xxx");
5147 ok(!elem, "elem != NULL\n");
5149 elem = get_doc_elem_by_id(doc, "s");
5150 ok(elem != NULL, "elem == NULL\n");
5152 test_elem_type((IUnknown*)elem, ET_SELECT);
5153 test_elem_attr(elem, "xxx", NULL);
5154 test_elem_attr(elem, "id", "s");
5155 test_elem_class((IUnknown*)elem, NULL);
5156 test_elem_set_class((IUnknown*)elem, "cl");
5157 test_elem_set_class((IUnknown*)elem, NULL);
5158 test_elem_tabindex((IUnknown*)elem, 0);
5159 test_elem_set_tabindex((IUnknown*)elem, 1);
5160 test_elem_filters((IUnknown*)elem);
5162 node = test_node_get_parent((IUnknown*)elem);
5163 ok(node != NULL, "node == NULL\n");
5164 test_node_name((IUnknown*)node, "BODY");
5165 node2 = test_node_get_parent((IUnknown*)node);
5166 IHTMLDOMNode_Release(node);
5167 ok(node2 != NULL, "node == NULL\n");
5168 test_node_name((IUnknown*)node2, "HTML");
5169 node = test_node_get_parent((IUnknown*)node2);
5170 IHTMLDOMNode_Release(node2);
5171 ok(node != NULL, "node == NULL\n");
5174 test_node_name((IUnknown*)node, "#document");
5175 type = get_node_type((IUnknown*)node);
5176 ok(type == 9, "type=%d, expected 9\n", type);
5177 node2 = test_node_get_parent((IUnknown*)node);
5178 IHTMLDOMNode_Release(node);
5179 ok(node2 == NULL, "node != NULL\n");
5182 elem2 = test_elem_get_parent((IUnknown*)elem);
5183 ok(elem2 != NULL, "elem2 == NULL\n");
5184 test_node_name((IUnknown*)elem2, "BODY");
5185 elem3 = test_elem_get_parent((IUnknown*)elem2);
5186 IHTMLElement_Release(elem2);
5187 ok(elem3 != NULL, "elem3 == NULL\n");
5188 test_node_name((IUnknown*)elem3, "HTML");
5189 elem2 = test_elem_get_parent((IUnknown*)elem3);
5190 IHTMLElement_Release(elem3);
5191 ok(elem2 == NULL, "elem2 != NULL\n");
5193 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5194 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5195 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5197 test_elem_innertext(elem, "opt1opt2");
5199 IHTMLElement_Release(elem);
5202 elem = get_elem_by_id(doc, "s", TRUE);
5204 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
5205 IHTMLDocument2 *doc_node, *elem_doc;
5207 test_select_elem(select);
5209 test_elem_title((IUnknown*)select, NULL);
5210 test_elem_set_title((IUnknown*)select, "Title");
5211 test_elem_title((IUnknown*)select, "Title");
5212 test_elem_offset((IUnknown*)select, "BODY");
5213 test_elem_bounding_client_rect((IUnknown*)select);
5215 node = get_first_child((IUnknown*)select);
5216 ok(node != NULL, "node == NULL\n");
5218 test_elem_type((IUnknown*)node, ET_OPTION);
5219 IHTMLDOMNode_Release(node);
5222 type = get_node_type((IUnknown*)select);
5223 ok(type == 1, "type=%d\n", type);
5225 IHTMLSelectElement_Release(select);
5227 elem_doc = get_elem_doc((IUnknown*)elem);
5229 doc_node = get_doc_node(doc);
5230 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5231 IHTMLDocument2_Release(doc_node);
5232 IHTMLDocument2_Release(elem_doc);
5234 IHTMLElement_Release(elem);
5237 elem = get_elem_by_id(doc, "sc", TRUE);
5239 IHTMLScriptElement *script;
5242 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5243 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5249 hres = IHTMLScriptElement_put_type (script, NULL);
5250 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5251 hres = IHTMLScriptElement_get_type(script, &type);
5252 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5253 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
5255 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
5256 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5257 hres = IHTMLScriptElement_get_type(script, &type);
5258 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5259 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5261 SysFreeString(type);
5264 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5265 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5267 hres = IHTMLScriptElement_get_defer(script, &vb);
5268 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5269 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5271 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5272 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5274 str = (BSTR)0xdeadbeef;
5275 hres = IHTMLScriptElement_get_src(script, &str);
5276 ok(hres == S_OK, "get_src failed: %08x\n", hres);
5277 ok(!str, "src = %s\n", wine_dbgstr_w(str));
5280 IHTMLScriptElement_Release(script);
5283 elem = get_elem_by_id(doc, "in", TRUE);
5285 IHTMLInputElement *input;
5287 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5288 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5290 test_elem_id((IUnknown*)elem, "in");
5291 test_elem_put_id((IUnknown*)elem, "newin");
5292 test_input_get_disabled(input, VARIANT_FALSE);
5293 test_input_set_disabled(input, VARIANT_TRUE);
5294 test_input_set_disabled(input, VARIANT_FALSE);
5295 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5296 test_input_get_disabled(input, VARIANT_TRUE);
5297 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5298 test_input_get_disabled(input, VARIANT_FALSE);
5299 test_elem_client_size((IUnknown*)elem);
5300 test_input_type(input, "text");
5302 test_node_get_value_str((IUnknown*)elem, NULL);
5303 test_node_put_value_str((IUnknown*)elem, "test");
5304 test_node_get_value_str((IUnknown*)elem, NULL);
5305 test_input_value((IUnknown*)elem, NULL);
5306 test_input_put_value((IUnknown*)elem, "test");
5307 test_elem_class((IUnknown*)elem, "testclass");
5308 test_elem_tabindex((IUnknown*)elem, 2);
5309 test_elem_set_tabindex((IUnknown*)elem, 3);
5310 test_elem_title((IUnknown*)elem, "test title");
5312 test_input_get_defaultchecked(input, VARIANT_FALSE);
5313 test_input_set_defaultchecked(input, VARIANT_TRUE);
5314 test_input_set_defaultchecked(input, VARIANT_FALSE);
5316 test_input_get_checked(input, VARIANT_FALSE);
5317 test_input_set_checked(input, VARIANT_TRUE);
5318 test_input_set_checked(input, VARIANT_FALSE);
5320 test_input_maxlength(input, 0x7fffffff);
5321 test_input_set_maxlength(input, 30);
5323 test_input_name(input, NULL);
5324 test_input_set_name(input, "test");
5326 test_input_src(input, NULL);
5327 test_input_set_src(input, "about:blank");
5329 IHTMLInputElement_Release(input);
5330 IHTMLElement_Release(elem);
5333 elem = get_elem_by_id(doc, "imgid", TRUE);
5335 test_img_src((IUnknown*)elem, "", NULL);
5336 test_img_set_src((IUnknown*)elem, "about:blank");
5337 test_img_src((IUnknown*)elem, "about:blank", NULL);
5338 test_img_alt((IUnknown*)elem, NULL);
5339 test_img_set_alt((IUnknown*)elem, "alt test");
5340 test_img_name((IUnknown*)elem, "WineImg");
5341 IHTMLElement_Release(elem);
5344 elem = get_elem_by_id(doc, "attr", TRUE);
5346 test_dynamic_properties(elem);
5347 test_attr_collection(elem);
5348 IHTMLElement_Release(elem);
5351 elem = get_elem_by_id(doc, "styleid", TRUE);
5353 test_style_media((IUnknown*)elem, NULL);
5354 test_style_put_media((IUnknown*)elem, "screen");
5355 test_style_type((IUnknown*)elem, NULL);
5356 test_style_put_type((IUnknown*)elem, "text/css");
5357 IHTMLElement_Release(elem);
5360 elem = get_doc_elem_by_id(doc, "tbl");
5361 ok(elem != NULL, "elem == NULL\n");
5363 test_table_elem(elem);
5364 IHTMLElement_Release(elem);
5367 elem = get_doc_elem_by_id(doc, "row2");
5368 ok(elem != NULL, "elem == NULL\n");
5371 IHTMLElement_Release(elem);
5374 elem = get_doc_elem_by_id(doc, "ifr");
5375 ok(elem != NULL, "elem == NULL\n");
5377 test_iframe_elem(elem);
5378 IHTMLElement_Release(elem);
5381 elem = get_doc_elem_by_id(doc, "objid");
5382 ok(elem != NULL, "elem == NULL\n");
5384 test_object_vspace((IUnknown*)elem, 100);
5385 IHTMLElement_Release(elem);
5388 elem = get_elem_by_id(doc, "a", TRUE);
5390 test_anchor_href((IUnknown*)elem, "http://test/");
5392 /* Change the href */
5393 test_anchor_put_href((IUnknown*)elem, "http://test1/");
5394 test_anchor_href((IUnknown*)elem, "http://test1/");
5396 /* Restore the href */
5397 test_anchor_put_href((IUnknown*)elem, "http://test/");
5398 test_anchor_href((IUnknown*)elem, "http://test/");
5401 test_anchor_get_target((IUnknown*)elem, NULL);
5403 /* Change the target */
5404 test_anchor_put_target((IUnknown*)elem, "wine");
5405 test_anchor_get_target((IUnknown*)elem, "wine");
5407 /* Restore the target */
5408 test_anchor_put_target((IUnknown*)elem, NULL);
5409 test_anchor_get_target((IUnknown*)elem, NULL);
5411 IHTMLElement_Release(elem);
5414 elem = get_doc_elem_by_id(doc, "metaid");
5416 test_meta_name((IUnknown*)elem, "meta name");
5417 test_meta_content((IUnknown*)elem, "text/html; charset=utf-8");
5418 test_meta_httpequiv((IUnknown*)elem, "Content-Type");
5419 IHTMLElement_Release(elem);
5422 elem = doc_get_body(doc);
5424 node = get_first_child((IUnknown*)elem);
5425 ok(node != NULL, "node == NULL\n");
5427 test_ifaces((IUnknown*)node, text_iids);
5428 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5430 node2 = get_first_child((IUnknown*)node);
5431 ok(!node2, "node2 != NULL\n");
5433 type = get_node_type((IUnknown*)node);
5434 ok(type == 3, "type=%d\n", type);
5436 test_node_get_value_str((IUnknown*)node, "text test");
5437 test_node_put_value_str((IUnknown*)elem, "test text");
5438 test_node_get_value_str((IUnknown*)node, "text test");
5440 hres = IHTMLDOMNode_get_attributes(node, &disp);
5441 ok(hres == S_OK, "get_attributes failed: %08x\n", hres);
5442 ok(!disp, "disp != NULL\n");
5444 IHTMLDOMNode_Release(node);
5447 child_col = get_child_nodes((IUnknown*)elem);
5448 ok(child_col != NULL, "child_coll == NULL\n");
5452 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5454 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5455 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5456 ok(length, "length=0\n");
5459 node = get_child_item(child_col, 0);
5460 ok(node != NULL, "node == NULL\n");
5464 type = get_node_type((IUnknown*)node);
5465 ok(type == 3, "type=%d\n", type);
5466 node2 = node_get_next((IUnknown*)node);
5468 prev = node_get_prev((IUnknown*)node2);
5469 ok(iface_cmp((IUnknown*)node, (IUnknown*)prev), "node != prev\n");
5470 IHTMLDOMNode_Release(prev);
5472 IHTMLDOMNode_Release(node);
5475 node = get_child_item(child_col, 1);
5476 ok(node != NULL, "node == NULL\n");
5478 type = get_node_type((IUnknown*)node);
5479 ok(type == 8, "type=%d\n", type);
5481 test_elem_id((IUnknown*)node, NULL);
5482 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5483 IHTMLDOMNode_Release(node2);
5484 IHTMLDOMNode_Release(node);
5487 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5488 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5490 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5491 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5493 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5494 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5496 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5497 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5499 test_child_col_disp(child_col);
5501 IHTMLDOMChildrenCollection_Release(child_col);
5504 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5505 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5506 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5508 IHTMLElement_Release(elem);
5510 elem = get_doc_elem_by_id(doc, "frm");
5511 ok(elem != NULL, "elem == NULL\n");
5513 test_form_length((IUnknown*)elem, 0);
5514 test_form_elements((IUnknown*)elem);
5515 IHTMLElement_Release(elem);
5518 test_stylesheets(doc);
5519 test_create_option_elem(doc);
5520 test_create_img_elem(doc);
5522 elem = get_doc_elem_by_id(doc, "tbl");
5523 ok(elem != NULL, "elem = NULL\n");
5524 test_elem_set_innertext(elem, "inner text");
5525 IHTMLElement_Release(elem);
5527 test_doc_title(doc, "test");
5528 test_doc_set_title(doc, "test title");
5529 test_doc_title(doc, "test title");
5532 hres = IHTMLDocument2_get_Script(doc, &disp);
5533 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5536 IDispatchEx *dispex;
5537 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5538 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5542 BSTR str = a2bstr("Testing");
5543 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5544 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5545 ok(pid != -1, "pid == -1\n");
5547 IDispatchEx_Release(dispex);
5550 IDispatch_Release(disp);
5552 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5553 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5555 str = a2bstr("img");
5556 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5557 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5561 static const elem_type_t img_types[] = { ET_IMG };
5563 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5564 IHTMLElementCollection_Release(col);
5567 elem = get_doc_elem_by_id(doc, "y");
5568 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5569 test_elem_innerhtml((IUnknown*)elem, "inner html");
5570 test_elem_set_innerhtml((IUnknown*)elem, "");
5571 test_elem_innerhtml((IUnknown*)elem, NULL);
5572 node = node_get_next((IUnknown*)elem);
5573 ok(!node, "node = %p\n", node);
5575 elem2 = get_doc_elem_by_id(doc, "x");
5576 test_elem_tag((IUnknown*)elem2, "A");
5577 node = node_get_next((IUnknown*)elem2);
5578 IHTMLDOMNode_Release(node);
5579 IHTMLElement_Release(elem2);
5580 IHTMLElement_Release(elem);
5582 IHTMLDocument3_Release(doc3);
5584 elem = get_elem_by_id(doc, "s", TRUE);
5586 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
5588 test_select_put_length((IUnknown*)elem, 3);
5589 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
5590 test_select_put_length((IUnknown*)elem, 1);
5591 test_elem_all((IUnknown*)elem, select_types, 1);
5592 IHTMLElement_Release(elem);
5595 window = get_doc_window(doc);
5596 test_window_name(window, NULL);
5597 set_window_name(window, "test name");
5598 test_window_length(window, 1);
5599 IHTMLWindow2_Release(window);
5602 static void test_attr(IHTMLElement *elem)
5604 IHTMLDOMAttribute *attr, *attr2;
5607 get_elem_attr_node((IUnknown*)elem, "noattr", FALSE);
5609 attr = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
5611 test_disp((IUnknown*)attr, &DIID_DispHTMLDOMAttribute, "[object]");
5612 test_ifaces((IUnknown*)attr, attr_iids);
5613 test_no_iface((IUnknown*)attr, &IID_IHTMLDOMNode);
5615 attr2 = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
5616 ok(iface_cmp((IUnknown*)attr, (IUnknown*)attr2), "attr != attr2\n");
5617 IHTMLDOMAttribute_Release(attr2);
5619 get_attr_node_value(attr, &v, VT_BSTR);
5620 ok(!strcmp_wa(V_BSTR(&v), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5623 IHTMLDOMAttribute_Release(attr);
5625 attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
5626 get_attr_node_value(attr, &v, VT_BSTR);
5627 ok(!V_BSTR(&v), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5629 IHTMLDOMAttribute_Release(attr);
5633 set_dispex_value((IUnknown*)elem, "dispprop", &v);
5634 attr = get_elem_attr_node((IUnknown*)elem, "dispprop", TRUE);
5635 get_attr_node_value(attr, &v, VT_I4);
5636 ok(V_I4(&v) == 100, "V_I4(v) = %d\n", V_I4(&v));
5637 IHTMLDOMAttribute_Release(attr);
5640 static void test_blocked(IHTMLDocument2 *doc, IHTMLElement *outer_elem)
5644 test_elem_set_innerhtml((IUnknown*)outer_elem,
5645 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
5646 elem = get_elem_by_id(doc, "imgid", TRUE);
5648 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5649 IHTMLElement_Release(elem);
5652 test_elem_set_innerhtml((IUnknown*)outer_elem,
5653 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
5654 elem = get_elem_by_id(doc, "imgid", TRUE);
5656 test_img_src((IUnknown*)elem, "blocke::http://www.winehq.org/img.png", NULL);
5657 test_img_set_src((IUnknown*)elem, "BLOCKED:http://www.winehq.org/img.png");
5658 test_img_src((IUnknown*)elem, "blocked:http://www.winehq.org/img.png", NULL);
5659 test_img_set_src((IUnknown*)elem, "blocked::http://www.winehq.org/img.png");
5660 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
5661 IHTMLElement_Release(elem);
5665 static void test_elems2(IHTMLDocument2 *doc)
5667 IHTMLElement *elem, *elem2, *div;
5669 static const elem_type_t outer_types[] = {
5674 div = get_doc_elem_by_id(doc, "divid");
5676 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
5677 elem2 = get_doc_elem_by_id(doc, "innerid");
5678 ok(elem2 != NULL, "elem2 == NULL\n");
5679 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5680 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5681 IHTMLElement_Release(elem2);
5683 elem2 = get_doc_elem_by_id(doc, "aid");
5684 ok(elem2 != NULL, "elem2 == NULL\n");
5685 test_elem_set_outerhtml((IUnknown*)elem2, "");
5686 test_elem_all((IUnknown*)div, outer_types, 1);
5687 IHTMLElement_Release(elem2);
5689 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
5690 elem = get_elem_by_id(doc, "ta", TRUE);
5692 test_textarea_value((IUnknown*)elem, NULL);
5693 test_textarea_put_value((IUnknown*)elem, "test");
5694 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
5695 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
5696 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
5697 test_textarea_type((IUnknown*)elem);
5698 IHTMLElement_Release(elem);
5701 test_elem_set_innerhtml((IUnknown*)div,
5702 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" /></div></textarea>");
5703 elem = get_elem_by_id(doc, "form", TRUE);
5705 test_form_length((IUnknown*)elem, 2);
5706 test_form_item(elem);
5707 test_form_action((IUnknown*)elem, NULL);
5708 test_form_put_action((IUnknown*)elem, "about:blank");
5709 test_form_method((IUnknown*)elem, "get");
5710 test_form_put_method((IUnknown*)elem, S_OK, "post");
5711 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
5712 test_form_method((IUnknown*)elem, "post");
5713 test_form_name((IUnknown*)elem, NULL);
5714 test_form_put_name((IUnknown*)elem, "Name");
5715 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
5716 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
5717 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
5718 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
5719 test_form_encoding((IUnknown*)elem, "multipart/form-data");
5720 test_form_elements((IUnknown*)elem);
5721 IHTMLElement_Release(elem);
5725 test_blocked(doc, div);
5727 IHTMLElement_Release(div);
5730 static void test_create_elems(IHTMLDocument2 *doc)
5732 IHTMLElement *elem, *body, *elem2;
5733 IHTMLDOMNode *node, *node2, *node3, *comment;
5734 IHTMLDocument5 *doc5;
5741 static const elem_type_t types1[] = { ET_TESTG };
5743 elem = test_create_elem(doc, "TEST");
5744 test_elem_tag((IUnknown*)elem, "TEST");
5745 type = get_node_type((IUnknown*)elem);
5746 ok(type == 1, "type=%d\n", type);
5747 test_ifaces((IUnknown*)elem, elem_iids);
5748 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5750 body = doc_get_body(doc);
5751 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5753 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5754 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5755 elem2 = get_elem_iface((IUnknown*)node);
5756 IHTMLElement_Release(elem2);
5758 hres = IHTMLElement_get_all(body, &disp);
5759 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5760 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5761 IDispatch_Release(disp);
5763 test_node_remove_child((IUnknown*)body, node);
5765 hres = IHTMLElement_get_all(body, &disp);
5766 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5767 test_elem_collection((IUnknown*)disp, NULL, 0);
5768 IDispatch_Release(disp);
5769 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5771 IHTMLElement_Release(elem);
5772 IHTMLDOMNode_Release(node);
5774 node = test_create_text(doc, "test");
5775 test_ifaces((IUnknown*)node, text_iids);
5776 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5777 test_text_length((IUnknown*)node, 4);
5779 V_VT(&var) = VT_NULL;
5780 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5781 IHTMLDOMNode_Release(node);
5783 node = test_create_text(doc, "insert ");
5785 V_VT(&var) = VT_DISPATCH;
5786 V_DISPATCH(&var) = (IDispatch*)node2;
5787 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5788 IHTMLDOMNode_Release(node);
5789 IHTMLDOMNode_Release(node2);
5790 IHTMLDOMNode_Release(node3);
5792 test_elem_innertext(body, "insert test");
5793 test_elem_innerhtml((IUnknown*)body, "insert test");
5795 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5798 str = a2bstr("testing");
5799 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5801 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5804 type = get_node_type((IUnknown*)comment);
5805 ok(type == 8, "type=%d, expected 8\n", type);
5807 test_node_get_value_str((IUnknown*)comment, "testing");
5808 test_elem_title((IUnknown*)comment, NULL);
5809 test_elem_set_title((IUnknown*)comment, "comment title");
5810 test_elem_title((IUnknown*)comment, "comment title");
5811 test_comment_text((IUnknown*)comment, "<!--testing-->");
5812 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
5813 test_comment_attrs((IUnknown*)comment);
5815 IHTMLDOMNode_Release(comment);
5818 IHTMLDocument5_Release(doc5);
5821 IHTMLElement_Release(body);
5824 static void test_replacechild_elems(IHTMLDocument2 *doc)
5827 IHTMLDOMNode *node, *node2, *node3;
5828 IHTMLDOMNode *nodeBody, *nodeNew;
5832 body = doc_get_body(doc);
5834 node = test_create_text(doc, "insert");
5836 V_VT(&var) = VT_NULL;
5837 V_DISPATCH(&var) = NULL;
5838 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5839 IHTMLDOMNode_Release(node);
5841 test_elem_innertext(body, "insert");
5843 node3 = test_create_text(doc, "replaced");
5845 nodeBody = _get_node_iface(__LINE__, (IUnknown *)body);
5847 hres = IHTMLDOMNode_replaceChild(nodeBody, node3, node2, &nodeNew);
5848 ok(hres == S_OK, "Expected S_OK, got 0x%08x\n", hres);
5850 test_elem_innertext(body, "replaced");
5852 IHTMLDOMNode_Release(node2);
5853 IHTMLDOMNode_Release(node3);
5854 IHTMLDOMNode_Release(nodeBody);
5856 IHTMLElement_Release(body);
5859 static void test_null_write(IHTMLDocument2 *doc)
5863 doc_write(doc, FALSE, NULL);
5864 doc_write(doc, TRUE, NULL);
5866 hres = IHTMLDocument2_write(doc, NULL);
5868 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
5870 hres = IHTMLDocument2_writeln(doc, NULL);
5872 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
5875 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5877 IOleCommandTarget *cmdtrg;
5880 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5881 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5883 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5884 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5886 IOleCommandTarget_Release(cmdtrg);
5889 static void test_indent(IHTMLDocument2 *doc)
5891 IHTMLElementCollection *col;
5892 IHTMLTxtRange *range;
5895 static const elem_type_t all_types[] = {
5904 static const elem_type_t indent_types[] = {
5915 hres = IHTMLDocument2_get_all(doc, &col);
5916 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5917 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5918 IHTMLElementCollection_Release(col);
5920 range = test_create_body_range(doc);
5921 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5922 IHTMLTxtRange_Release(range);
5924 hres = IHTMLDocument2_get_all(doc, &col);
5925 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5926 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5927 IHTMLElementCollection_Release(col);
5930 static void test_cond_comment(IHTMLDocument2 *doc)
5932 IHTMLElementCollection *col;
5935 static const elem_type_t all_types[] = {
5943 hres = IHTMLDocument2_get_all(doc, &col);
5944 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5945 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5946 IHTMLElementCollection_Release(col);
5949 static void test_frame(IDispatch *disp, const char *exp_id)
5951 IHTMLWindow2 *frame2, *parent, *top;
5952 IHTMLDocument2 *parent_doc, *top_doc;
5953 IHTMLWindow4 *frame;
5954 IHTMLFrameBase *frame_elem;
5957 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5958 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5962 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5963 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5964 IHTMLWindow4_Release(frame);
5968 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
5969 test_frame_doc((IUnknown*)frame_elem, FALSE);
5970 test_elem_id((IUnknown*)frame_elem, exp_id);
5971 IHTMLElement_Release(frame_elem);
5973 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5974 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5978 hres = IHTMLWindow2_get_parent(frame2, &parent);
5979 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5981 IHTMLWindow2_Release(frame2);
5985 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5986 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5987 IHTMLWindow2_Release(parent);
5989 IHTMLWindow2_Release(frame2);
5993 test_doc_title(parent_doc, "frameset test");
5994 IHTMLDocument2_Release(parent_doc);
5997 hres = IHTMLWindow2_get_top(frame2, &top);
5998 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5999 IHTMLWindow2_Release(frame2);
6003 hres = IHTMLWindow2_get_document(top, &top_doc);
6004 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6005 IHTMLWindow2_Release(top);
6009 test_doc_title(top_doc, "frameset test");
6010 IHTMLDocument2_Release(top_doc);
6013 static void test_frames_collection(IHTMLFramesCollection2 *frames, const char *frid)
6015 VARIANT index_var, result_var;
6019 /* test result length */
6020 hres = IHTMLFramesCollection2_get_length(frames, &length);
6021 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6022 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6024 /* test first frame */
6025 V_VT(&index_var) = VT_I4;
6026 V_I4(&index_var) = 0;
6027 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6028 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6029 if(SUCCEEDED(hres)) {
6030 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6031 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6033 VariantClear(&result_var);
6035 /* test second frame */
6036 V_I4(&index_var) = 1;
6037 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6038 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6039 if(SUCCEEDED(hres)) {
6040 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6041 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6043 VariantClear(&result_var);
6045 /* fail on next frame */
6046 V_I4(&index_var) = 3;
6047 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6048 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6049 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6050 VariantClear(&result_var);
6052 /* string argument (element id lookup) */
6053 V_VT(&index_var) = VT_BSTR;
6054 V_BSTR(&index_var) = a2bstr(frid);
6055 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6056 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6057 if(SUCCEEDED(hres)) {
6058 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6059 test_frame(V_DISPATCH(&result_var), frid);
6061 VariantClear(&result_var);
6062 VariantClear(&index_var);
6064 /* invalid argument */
6065 V_VT(&index_var) = VT_BOOL;
6066 V_BOOL(&index_var) = VARIANT_TRUE;
6067 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6068 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6069 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6070 VariantClear(&result_var);
6073 static void test_frameset(IHTMLDocument2 *doc)
6075 IHTMLWindow2 *window;
6076 IHTMLFramesCollection2 *frames;
6078 IHTMLFrameBase *fbase;
6082 window = get_doc_window(doc);
6084 /* test using IHTMLFramesCollection object */
6086 hres = IHTMLWindow2_get_frames(window, &frames);
6087 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6091 test_frames_collection(frames, "fr1");
6092 IHTMLFramesCollection2_Release(frames);
6094 hres = IHTMLDocument2_get_frames(doc, &frames);
6095 ok(hres == S_OK, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres);
6099 test_frames_collection(frames, "fr1");
6100 IHTMLFramesCollection2_Release(frames);
6102 /* test using IHTMLWindow2 inheritance */
6103 test_frames_collection((IHTMLFramesCollection2*)window, "fr2");
6105 /* getElementById with node name attributes */
6106 elem = get_doc_elem_by_id(doc, "nm1");
6107 test_elem_id((IUnknown*)elem, "fr1");
6109 /* get/put scrolling */
6110 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6111 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6113 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6114 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6115 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6119 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6120 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6123 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6124 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6125 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6128 str = a2bstr("junk");
6129 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6130 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6131 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6134 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6135 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6136 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6140 hres = IHTMLFrameBase_get_name(fbase, &str);
6141 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6142 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6145 IHTMLFrameBase_Release(fbase);
6146 IHTMLElement_Release(elem);
6148 /* get_name with no name attr */
6149 elem = get_doc_elem_by_id(doc, "fr3");
6150 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6151 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6153 hres = IHTMLFrameBase_get_name(fbase, &str);
6154 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6155 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6158 IHTMLFrameBase_Release(fbase);
6159 IHTMLElement_Release(elem);
6160 IHTMLWindow2_Release(window);
6163 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
6165 IHTMLDocument2 *frag;
6166 IHTMLDocument3 *doc3;
6169 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6170 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6172 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
6173 IHTMLDocument3_Release(doc3);
6174 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
6175 ok(frag != NULL, "frag == NULL\n");
6180 static void test_docfrag(IHTMLDocument2 *doc)
6182 IHTMLElement *div, *body, *br;
6183 IHTMLElementCollection *col;
6184 IHTMLLocation *location;
6185 IHTMLDocument2 *frag;
6188 static const elem_type_t all_types[] = {
6197 frag = create_docfrag(doc);
6199 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
6201 body = (void*)0xdeadbeef;
6202 hres = IHTMLDocument2_get_body(frag, &body);
6203 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6204 ok(!body, "body != NULL\n");
6206 location = (void*)0xdeadbeef;
6207 hres = IHTMLDocument2_get_location(frag, &location);
6208 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
6209 ok(location == (void*)0xdeadbeef, "location changed\n");
6211 br = test_create_elem(doc, "BR");
6212 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
6213 IHTMLElement_Release(br);
6215 div = get_elem_by_id(doc, "divid", TRUE);
6216 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
6217 IHTMLElement_Release(div);
6219 hres = IHTMLDocument2_get_all(doc, &col);
6220 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6221 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6222 IHTMLElementCollection_Release(col);
6224 IHTMLDocument2_Release(frag);
6227 static IHTMLDocument2 *notif_doc;
6228 static BOOL doc_complete;
6230 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6231 REFIID riid, void**ppv)
6233 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6238 ok(0, "unexpected call\n");
6239 return E_NOINTERFACE;
6242 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6247 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6252 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6254 if(dispID == DISPID_READYSTATE){
6258 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6259 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6261 if(!strcmp_wa(state, "complete"))
6262 doc_complete = TRUE;
6264 SysFreeString(state);
6270 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6272 ok(0, "unexpected call\n");
6276 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6277 PropertyNotifySink_QueryInterface,
6278 PropertyNotifySink_AddRef,
6279 PropertyNotifySink_Release,
6280 PropertyNotifySink_OnChanged,
6281 PropertyNotifySink_OnRequestEdit
6284 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6286 static IHTMLDocument2 *create_doc_with_string(const char *str)
6288 IPersistStreamInit *init;
6290 IHTMLDocument2 *doc;
6294 notif_doc = doc = create_document();
6298 doc_complete = FALSE;
6300 mem = GlobalAlloc(0, len);
6301 memcpy(mem, str, len);
6302 CreateStreamOnHGlobal(mem, TRUE, &stream);
6304 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6306 IPersistStreamInit_Load(init, stream);
6307 IPersistStreamInit_Release(init);
6308 IStream_Release(stream);
6313 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6315 IConnectionPointContainer *container;
6316 IConnectionPoint *cp;
6320 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6321 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6323 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6324 IConnectionPointContainer_Release(container);
6325 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6327 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6328 IConnectionPoint_Release(cp);
6329 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6332 typedef void (*domtest_t)(IHTMLDocument2*);
6334 static void run_domtest(const char *str, domtest_t test)
6336 IHTMLDocument2 *doc;
6340 doc = create_doc_with_string(str);
6344 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6346 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6347 TranslateMessage(&msg);
6348 DispatchMessage(&msg);
6353 ref = IHTMLDocument2_Release(doc);
6354 ok(!ref || broken(ref == 1), /* Vista */
6360 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
6361 pLCIDToLocaleName = (void*)GetProcAddress(hkernel32, "LCIDToLocaleName");
6362 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
6366 run_domtest(doc_str1, test_doc_elem);
6367 run_domtest(doc_str1, test_get_set_attr);
6368 run_domtest(range_test_str, test_txtrange);
6369 run_domtest(range_test2_str, test_txtrange2);
6370 if (winetest_interactive || ! is_ie_hardened()) {
6371 run_domtest(elem_test_str, test_elems);
6372 run_domtest(elem_test2_str, test_elems2);
6374 skip("IE running in Enhanced Security Configuration\n");
6376 run_domtest(doc_blank, test_create_elems);
6377 run_domtest(doc_blank, test_defaults);
6378 run_domtest(doc_blank, test_null_write);
6379 run_domtest(indent_test_str, test_indent);
6380 run_domtest(cond_comment_str, test_cond_comment);
6381 run_domtest(frameset_str, test_frameset);
6382 run_domtest(emptydiv_str, test_docfrag);
6383 run_domtest(doc_blank, test_replacechild_elems);