2 * Copyright 2007-2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
34 #include "mshtml_test.h"
37 static const char doc_blank[] = "<html></html>";
38 static const char doc_str1[] = "<html><body>test</body></html>";
39 static const char range_test_str[] =
40 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
41 static const char range_test2_str[] =
42 "<html><body>abc<hr />123<br /><hr />def</body></html>";
43 static const char elem_test_str[] =
44 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
45 "<body onload=\"Testing()\">text test<!-- a comment -->"
46 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
47 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
48 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
49 "<textarea id=\"X\">text text</textarea>"
50 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
51 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
52 "<test /><object id=\"objid\" vspace=100></object><embed />"
53 "<img id=\"imgid\" name=\"WineImg\"/>"
54 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 "<form id=\"frm\"></form>"
57 static const char elem_test2_str[] =
58 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
59 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
62 static const char indent_test_str[] =
63 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
64 static const char cond_comment_str[] =
65 "<html><head><title>test</title></head><body>"
66 "<!--[if gte IE 4]> <br> <![endif]-->"
68 static const char frameset_str[] =
69 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
70 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
71 "<frame src=\"about:blank\" id=\"fr3\">"
73 static const char emptydiv_str[] =
74 "<html><head><title>emptydiv test</title></head>"
75 "<body><div id=\"divid\"></div></body></html>";
77 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
78 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
79 static WCHAR wordW[] = {'w','o','r','d',0};
113 static const IID * const none_iids[] = {
118 static const IID * const doc_node_iids[] = {
127 &IID_IConnectionPointContainer,
128 &IID_IInternetHostSecurityManager,
134 static const IID * const doc_obj_iids[] = {
141 &IID_IConnectionPointContainer,
148 #define ELEM_IFACES \
150 &IID_IHTMLDOMNode2, \
152 &IID_IHTMLElement2, \
153 &IID_IHTMLElement3, \
154 &IID_IHTMLElement4, \
157 static const IID * const elem_iids[] = {
159 &IID_IConnectionPointContainer,
163 static const IID * const body_iids[] = {
165 &IID_IHTMLTextContainer,
166 &IID_IHTMLBodyElement,
167 &IID_IConnectionPointContainer,
171 static const IID * const anchor_iids[] = {
173 &IID_IHTMLAnchorElement,
174 &IID_IConnectionPointContainer,
178 static const IID * const input_iids[] = {
180 &IID_IHTMLInputElement,
181 &IID_IHTMLInputTextElement,
182 &IID_IConnectionPointContainer,
186 static const IID * const select_iids[] = {
188 &IID_IHTMLSelectElement,
189 &IID_IConnectionPointContainer,
193 static const IID * const textarea_iids[] = {
195 &IID_IHTMLTextAreaElement,
196 &IID_IConnectionPointContainer,
200 static const IID * const option_iids[] = {
202 &IID_IHTMLOptionElement,
203 &IID_IConnectionPointContainer,
207 static const IID * const table_iids[] = {
210 &IID_IConnectionPointContainer,
214 static const IID * const script_iids[] = {
216 &IID_IHTMLScriptElement,
217 &IID_IConnectionPointContainer,
221 static const IID * const text_iids[] = {
224 &IID_IHTMLDOMTextNode,
228 static const IID * const attr_iids[] = {
229 &IID_IHTMLDOMAttribute,
234 static const IID * const location_iids[] = {
240 static const IID * const window_iids[] = {
245 &IID_IServiceProvider,
249 static const IID * const comment_iids[] = {
251 &IID_IHTMLCommentElement,
252 &IID_IConnectionPointContainer,
256 static const IID * const img_iids[] = {
258 &IID_IHTMLImgElement,
259 &IID_IConnectionPointContainer,
263 static const IID * const tr_iids[] = {
266 &IID_IConnectionPointContainer,
270 static const IID * const td_iids[] = {
272 &IID_IConnectionPointContainer,
276 static const IID * const frame_iids[] = {
279 &IID_IHTMLFrameBase2,
280 &IID_IConnectionPointContainer,
284 static const IID * const head_iids[] = {
286 &IID_IHTMLHeadElement,
287 &IID_IConnectionPointContainer,
291 static const IID * const title_iids[] = {
293 &IID_IHTMLTitleElement,
294 &IID_IConnectionPointContainer,
298 static const IID * const object_iids[] = {
300 &IID_IHTMLObjectElement,
301 /* FIXME: No IConnectionPointContainer */
305 static const IID * const embed_iids[] = {
307 &IID_IHTMLEmbedElement,
308 /* FIXME: No IConnectionPointContainer */
312 static const IID * const iframe_iids[] = {
315 &IID_IHTMLFrameBase2,
316 &IID_IHTMLIFrameElement,
317 &IID_IConnectionPointContainer,
321 static const IID * const form_iids[] = {
323 &IID_IHTMLFormElement,
324 &IID_IConnectionPointContainer,
328 static const IID * const styleelem_iids[] = {
330 &IID_IHTMLStyleElement,
331 &IID_IConnectionPointContainer,
335 static const IID * const generic_iids[] = {
337 &IID_IHTMLGenericElement,
338 &IID_IConnectionPointContainer,
342 static const IID * const style_iids[] = {
353 static const IID * const cstyle_iids[] = {
357 &IID_IHTMLCurrentStyle,
361 static const IID * const img_factory_iids[] = {
365 &IID_IHTMLImageElementFactory,
375 static const elem_type_info_t elem_type_infos[] = {
376 {"", none_iids, NULL},
377 {"HTML", elem_iids, NULL},
378 {"HEAD", head_iids, &DIID_DispHTMLHeadElement},
379 {"TITLE", title_iids, &DIID_DispHTMLTitleElement},
380 {"BODY", body_iids, &DIID_DispHTMLBody},
381 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
382 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
383 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
384 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
385 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
386 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
387 {"BLOCKQUOTE",elem_iids, NULL},
388 {"P", elem_iids, NULL},
389 {"BR", elem_iids, NULL},
390 {"TABLE", table_iids, &DIID_DispHTMLTable},
391 {"TBODY", elem_iids, NULL},
392 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
393 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
394 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
395 {"!", comment_iids, &DIID_DispHTMLCommentElement},
396 {"IMG", img_iids, &DIID_DispHTMLImg},
397 {"TR", tr_iids, &DIID_DispHTMLTableRow},
398 {"TD", td_iids, NULL},
399 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
400 {"FORM", form_iids, &DIID_DispHTMLFormElement},
401 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
402 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
403 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
404 {"DIV", elem_iids, NULL}
407 static const char *dbgstr_guid(REFIID riid)
411 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
412 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
413 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
414 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
419 static int strcmp_wa(LPCWSTR strw, const char *stra)
422 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
423 return lstrcmpA(stra, buf);
426 static BSTR a2bstr(const char *str)
434 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
435 ret = SysAllocStringLen(NULL, len);
436 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
441 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
443 IUnknown *unk1, *unk2;
448 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
449 IUnknown_Release(unk1);
450 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
451 IUnknown_Release(unk2);
456 static IHTMLDocument2 *create_document(void)
459 IHTMLDocument5 *doc5;
462 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
463 &IID_IHTMLDocument2, (void**)&doc);
464 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
468 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
470 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
471 IHTMLDocument2_Release(doc);
475 IHTMLDocument5_Release(doc5);
479 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
480 static IDispatchEx *_get_dispex_iface(unsigned line, IUnknown *unk)
485 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
486 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
490 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
491 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
493 const IID * const *piid;
497 for(piid = iids; *piid; piid++) {
498 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
499 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
501 IUnknown_Release(unk);
505 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
506 static void _test_no_iface(unsigned line, IUnknown *iface, REFIID iid)
511 unk = (void*)0xdeadbeef;
512 hres = IUnknown_QueryInterface(iface, iid, (void**)&unk);
513 ok_(__FILE__,line)(hres == E_NOINTERFACE, "hres = %08x, expected E_NOINTERFACE\n", hres);
514 ok_(__FILE__,line)(!unk, "unk = %p\n", unk);
517 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
518 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
520 IDispatchEx *dispex = _get_dispex_iface(line, unk);
527 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
528 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
529 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
531 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
532 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
534 if(SUCCEEDED(hres)) {
537 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
538 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
540 *iid = type_attr->guid;
544 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
545 ITypeInfo_Release(typeinfo);
548 IDispatchEx_Release(dispex);
552 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
553 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
555 IDispatchEx *dispex = _get_dispex_iface(line, unk);
556 DISPPARAMS dp = {NULL,NULL,0,0};
561 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
562 IDispatchEx_Release(dispex);
563 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
565 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
566 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
570 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
571 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
575 if(_test_get_dispid(line, unk, &iid))
576 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
579 _test_disp_value(line, unk, val);
582 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
583 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
587 if(_test_get_dispid(line, unk, &iid))
588 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
589 "unexpected guid %s\n", dbgstr_guid(&iid));
592 _test_disp_value(line, unk, val);
595 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
596 static void _set_dispex_value(unsigned line, IUnknown *unk, const char *name, VARIANT *val)
598 IDispatchEx *dispex = _get_dispex_iface(line, unk);
599 DISPPARAMS dp = {val, NULL, 1, 0};
606 hres = IDispatchEx_GetDispID(dispex, str, fdexNameEnsure|fdexNameCaseInsensitive, &id);
608 ok_(__FILE__,line)(hres == S_OK, "GetDispID failed: %08x\n", hres);
610 memset(&ei, 0, sizeof(ei));
611 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYPUT, &dp, NULL, &ei, NULL);
612 ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres);
616 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
617 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
622 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
623 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
627 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
628 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
633 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
634 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
638 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
639 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
644 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
645 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
649 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
650 static IHTMLElement4 *_get_elem4_iface(unsigned line, IUnknown *unk)
655 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement4, (void**)&elem);
656 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement4: %08x\n", hres);
660 #define get_node_iface(u) _get_node_iface(__LINE__,u)
661 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
666 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
667 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
671 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
672 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
677 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
678 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
682 #define get_img_iface(u) _get_img_iface(__LINE__,u)
683 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
685 IHTMLImgElement *img;
688 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
689 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
693 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
694 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
696 IHTMLAnchorElement *anchor;
699 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
700 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
704 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
705 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
707 IHTMLTextAreaElement *textarea;
710 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
711 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
715 #define get_select_iface(u) _get_select_iface(__LINE__,u)
716 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
718 IHTMLSelectElement *select;
721 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
722 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
726 #define get_form_iface(u) _get_form_iface(__LINE__,u)
727 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
729 IHTMLFormElement *form;
732 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
733 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
737 #define get_text_iface(u) _get_text_iface(__LINE__,u)
738 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
740 IHTMLDOMTextNode *text;
743 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
744 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
748 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
749 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
751 IHTMLCommentElement *comment;
754 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
755 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
759 #define get_object_iface(u) _get_object_iface(__LINE__,u)
760 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
762 IHTMLObjectElement *obj;
765 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
766 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
770 #define get_style_iface(u) _get_style_iface(__LINE__,u)
771 static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
773 IHTMLStyleElement *obj;
776 hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
777 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
781 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
782 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
784 IHTMLDOMNode *node = _get_node_iface(line, unk);
788 hres = IHTMLDOMNode_get_nodeName(node, &name);
789 IHTMLDOMNode_Release(node);
790 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
791 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
796 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
797 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
799 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
800 IDispatch *disp = (void*)0xdeadbeef;
801 IHTMLDocument2 *doc = NULL;
804 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
805 IHTMLDOMNode2_Release(node);
806 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
809 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
810 IDispatch_Release(disp);
811 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
817 #define get_doc_window(d) _get_doc_window(__LINE__,d)
818 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
820 IHTMLWindow2 *window;
824 hres = IHTMLDocument2_get_parentWindow(doc, &window);
825 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
826 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
831 #define clone_node(n,d) _clone_node(__LINE__,n,d)
832 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
834 IHTMLDOMNode *node = _get_node_iface(line, unk);
835 IHTMLDOMNode *ret = NULL;
838 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
839 IHTMLDOMNode_Release(node);
840 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
841 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
847 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
848 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
850 IHTMLElement *elem = _get_elem_iface(line, unk);
854 hres = IHTMLElement_get_tagName(elem, &tag);
855 IHTMLElement_Release(elem);
856 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
857 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
862 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
863 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
865 _test_elem_tag(line, unk, elem_type_infos[type].tag);
866 _test_ifaces(line, unk, elem_type_infos[type].iids);
868 if(elem_type_infos[type].dispiid && type != ET_A)
869 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
872 #define get_node_type(n) _get_node_type(__LINE__,n)
873 static LONG _get_node_type(unsigned line, IUnknown *unk)
875 IHTMLDOMNode *node = _get_node_iface(line, unk);
879 hres = IHTMLDOMNode_get_nodeType(node, &type);
880 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
882 IHTMLDOMNode_Release(node);
887 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
888 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
890 IHTMLDOMNode *node = _get_node_iface(line, unk);
891 IHTMLDOMChildrenCollection *col = NULL;
895 hres = IHTMLDOMNode_get_childNodes(node, &disp);
896 IHTMLDOMNode_Release(node);
897 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
901 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
902 IDispatch_Release(disp);
903 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
908 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
909 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
911 IHTMLDOMNode *node = NULL;
915 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
916 ok(hres == S_OK, "item failed: %08x\n", hres);
918 node = _get_node_iface(line, (IUnknown*)disp);
919 IDispatch_Release(disp);
924 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
925 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
934 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
936 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
939 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
940 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
942 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
945 VariantClear(&value);
948 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
949 static void _test_elem_offset(unsigned line, IUnknown *unk, const char *parent_tag)
951 IHTMLElement *elem = _get_elem_iface(line, unk);
952 IHTMLElement *off_parent;
956 hres = IHTMLElement_get_offsetTop(elem, &l);
957 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
959 hres = IHTMLElement_get_offsetHeight(elem, &l);
960 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
962 hres = IHTMLElement_get_offsetWidth(elem, &l);
963 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
965 hres = IHTMLElement_get_offsetLeft(elem, &l);
966 ok_(__FILE__,line) (hres == S_OK, "get_offsetLeft failed: %08x\n", hres);
968 hres = IHTMLElement_get_offsetParent(elem, &off_parent);
969 ok_(__FILE__,line) (hres == S_OK, "get_offsetParent failed: %08x\n", hres);
971 _test_elem_tag(line, (IUnknown*)off_parent, parent_tag);
972 IHTMLElement_Release(off_parent);
974 IHTMLElement_Release(elem);
977 #define get_doc_node(d) _get_doc_node(__LINE__,d)
978 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
980 IHTMLWindow2 *window;
984 hres = IHTMLDocument2_get_parentWindow(doc, &window);
985 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
987 hres = IHTMLWindow2_get_document(window, &ret);
988 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
989 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
994 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
995 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
1000 hres = IHTMLWindow2_get_name(window, &name);
1001 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
1003 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
1005 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
1006 SysFreeString(name);
1009 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1010 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
1016 hres = IHTMLWindow2_put_name(window, str);
1018 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
1020 _test_window_name(line, window, name);
1023 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1024 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
1029 hres = IHTMLWindow2_get_length(window, &length);
1030 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1031 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1034 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1035 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1037 IHTMLFrameBase2 *base2;
1038 IHTMLWindow2 *window;
1041 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1042 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1045 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1046 IHTMLFrameBase2_Release(base2);
1047 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1048 ok(window != NULL, "contentWindow = NULL\n");
1053 static void test_get_set_attr(IHTMLDocument2 *doc)
1056 IHTMLDocument3 *doc3;
1061 /* grab an element to test with */
1062 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1063 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1065 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1066 IHTMLDocument3_Release(doc3);
1067 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1069 /* get a non-present attribute */
1070 bstr = a2bstr("notAnAttribute");
1071 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1072 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1073 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1075 SysFreeString(bstr);
1077 /* get a present attribute */
1078 bstr = a2bstr("scrollHeight");
1079 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1080 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1081 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1083 SysFreeString(bstr);
1085 /* create a new BSTR attribute */
1086 bstr = a2bstr("newAttribute");
1088 V_VT(&val) = VT_BSTR;
1089 V_BSTR(&val) = a2bstr("the value");
1090 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1091 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1094 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1095 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1096 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1097 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)));
1100 /* overwrite the attribute with a BOOL */
1101 V_VT(&val) = VT_BOOL;
1102 V_BOOL(&val) = VARIANT_TRUE;
1103 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1104 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1107 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1108 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1109 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1110 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1113 SysFreeString(bstr);
1115 /* case-insensitive */
1116 bstr = a2bstr("newattribute");
1117 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1118 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1119 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1120 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1122 SysFreeString(bstr);
1124 IHTMLElement_Release(elem);
1127 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1128 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1131 IHTMLDocument3 *doc3;
1134 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1135 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1136 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1137 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1138 IHTMLDocument3_Release(doc3);
1143 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1144 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1146 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1150 hres = IHTMLAnchorElement_get_href(anchor, &str);
1151 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1152 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1155 _test_disp_value(line, unk, exhref);
1158 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1159 static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhref)
1161 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1165 str = a2bstr(exhref);
1166 hres = IHTMLAnchorElement_put_href(anchor, str);
1167 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1170 _test_disp_value(line, unk, exhref);
1173 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1174 static void _test_anchor_get_target(unsigned line, IUnknown *unk, const char *target)
1176 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1180 hres = IHTMLAnchorElement_get_target(anchor, &str);
1181 ok_(__FILE__,line)(hres == S_OK, "get_target failed: %08x\n", hres);
1183 ok_(__FILE__,line)(!strcmp_wa(str, target), "target = %s, expected %s\n", wine_dbgstr_w(str), target);
1185 ok_(__FILE__,line)(str == NULL, "target = %s, expected NULL\n", wine_dbgstr_w(str));
1189 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1190 static void _test_anchor_put_target(unsigned line, IUnknown *unk, const char *target)
1192 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1196 str = target ? a2bstr(target) : NULL;
1197 hres = IHTMLAnchorElement_put_target(anchor, str);
1198 ok_(__FILE__,line)(hres == S_OK, "put_target failed: %08x\n", hres);
1203 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1204 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1209 hres = IHTMLOptionElement_get_text(option, &bstr);
1210 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1211 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1212 SysFreeString(bstr);
1215 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1216 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1221 bstr = a2bstr(text);
1222 hres = IHTMLOptionElement_put_text(option, bstr);
1223 SysFreeString(bstr);
1224 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1226 _test_option_text(line, option, text);
1229 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1230 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1235 hres = IHTMLOptionElement_get_value(option, &bstr);
1236 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1237 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1238 SysFreeString(bstr);
1241 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1242 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1247 bstr = a2bstr(value);
1248 hres = IHTMLOptionElement_put_value(option, bstr);
1249 SysFreeString(bstr);
1250 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1252 _test_option_value(line, option, value);
1255 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1256 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1258 VARIANT_BOOL b = 0x100;
1261 hres = IHTMLOptionElement_get_selected(option, &b);
1262 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1263 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1266 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1267 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1271 hres = IHTMLOptionElement_put_selected(option, b);
1272 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1273 _test_option_selected(line, option, b);
1276 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1277 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1279 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1280 BSTR value = (void*)0xdeadbeef;
1283 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1284 IHTMLTextAreaElement_Release(textarea);
1285 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1287 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1289 ok_(__FILE__,line)(!value, "value = %p\n", value);
1290 SysFreeString(value);
1293 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1294 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1296 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1297 BSTR tmp = a2bstr(value);
1300 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1301 IHTMLTextAreaElement_Release(textarea);
1302 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1305 _test_textarea_value(line, unk, value);
1308 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1309 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1311 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1312 VARIANT_BOOL b = 0x100;
1315 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1316 IHTMLTextAreaElement_Release(textarea);
1317 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1318 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1321 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1322 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1324 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1327 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1328 IHTMLTextAreaElement_Release(textarea);
1329 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1331 _test_textarea_readonly(line, unk, b);
1334 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1335 static void _test_textarea_type(unsigned line, IUnknown *unk)
1337 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1338 BSTR type = (void*)0xdeadbeef;
1341 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1342 IHTMLTextAreaElement_Release(textarea);
1343 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1344 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1345 SysFreeString(type);
1348 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1349 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1351 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1355 text = a2bstr(extext);
1356 hres = IHTMLCommentElement_get_text(comment, &text);
1357 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1358 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1360 IHTMLCommentElement_Release(comment);
1361 SysFreeString(text);
1364 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1365 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1367 IHTMLObjectElement *object = _get_object_iface(line, unk);
1372 hres = IHTMLObjectElement_get_vspace(object, &l);
1373 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1374 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1375 IHTMLObjectElement_Release(object);
1378 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1379 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1380 const char *txt, const char *val)
1382 IHTMLOptionElementFactory *factory;
1383 IHTMLOptionElement *option;
1384 IHTMLWindow2 *window;
1385 VARIANT text, value, empty;
1388 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1389 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1391 hres = IHTMLWindow2_get_Option(window, &factory);
1392 IHTMLWindow2_Release(window);
1393 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1395 V_VT(&text) = VT_BSTR;
1396 V_BSTR(&text) = a2bstr(txt);
1397 V_VT(&value) = VT_BSTR;
1398 V_BSTR(&value) = a2bstr(val);
1399 V_VT(&empty) = VT_EMPTY;
1401 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1402 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1404 IHTMLOptionElementFactory_Release(factory);
1405 VariantClear(&text);
1406 VariantClear(&value);
1408 _test_option_text(line, option, txt);
1409 _test_option_value(line, option, val);
1410 _test_option_selected(line, option, VARIANT_FALSE);
1415 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1416 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1421 hres = IHTMLImgElement_get_width(img, &found);
1422 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1423 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1426 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1427 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1431 hres = IHTMLImgElement_put_width(img, width);
1432 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1434 _test_img_width(line, img, width);
1437 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1438 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1443 hres = IHTMLImgElement_get_height(img, &found);
1444 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1445 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1448 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1449 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1453 hres = IHTMLImgElement_put_height(img, height);
1454 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1456 _test_img_height(line, img, height);
1459 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1460 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1461 LONG wdth, LONG hght)
1463 IHTMLImageElementFactory *factory;
1464 IHTMLImgElement *img;
1465 IHTMLWindow2 *window;
1466 VARIANT width, height;
1470 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1471 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1473 hres = IHTMLWindow2_get_Image(window, &factory);
1474 IHTMLWindow2_Release(window);
1475 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1477 test_ifaces((IUnknown*)factory, img_factory_iids);
1478 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1481 snprintf(buf, 16, "%d", wdth);
1482 V_VT(&width) = VT_BSTR;
1483 V_BSTR(&width) = a2bstr(buf);
1485 V_VT(&width) = VT_EMPTY;
1490 snprintf(buf, 16, "%d", hght);
1491 V_VT(&height) = VT_BSTR;
1492 V_BSTR(&height) = a2bstr(buf);
1494 V_VT(&height) = VT_EMPTY;
1498 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1499 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1501 IHTMLImageElementFactory_Release(factory);
1502 VariantClear(&width);
1503 VariantClear(&height);
1505 if(SUCCEEDED(hres)) {
1506 _test_img_width(line, img, wdth);
1507 _test_img_height(line, img, hght);
1514 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1515 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1517 LONG len = 0xdeadbeef;
1520 hres = IHTMLSelectElement_get_length(select, &len);
1521 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1522 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1525 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1526 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1528 IHTMLSelectElement *select = _get_select_iface(line, unk);
1531 hres = IHTMLSelectElement_put_length(select, length);
1532 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1533 _test_select_length(line, select, length);
1534 IHTMLSelectElement_Release(select);
1537 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1538 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1540 LONG idx = 0xdeadbeef;
1543 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1544 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1545 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1548 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1549 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1553 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1554 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1555 _test_select_selidx(line, select, index);
1558 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1559 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1564 hres = IHTMLSelectElement_get_value(select, &val);
1565 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1567 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1569 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1573 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1574 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1580 hres = IHTMLSelectElement_put_value(select, bstr);
1581 SysFreeString(bstr);
1582 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1585 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1586 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1591 hres = IHTMLSelectElement_get_type(select, &type);
1592 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1593 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1594 SysFreeString(type);
1597 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1598 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1603 hres = IHTMLTxtRange_get_text(range, &text);
1604 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1607 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1608 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1610 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1613 SysFreeString(text);
1617 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1618 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1622 hres = IHTMLTxtRange_collapse(range, b);
1623 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1624 _test_range_text(line, range, NULL);
1627 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1628 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1629 VARIANT_BOOL exb, const char *extext)
1631 VARIANT_BOOL b = 0xe0e0;
1634 hres = IHTMLTxtRange_expand(range, unit, &b);
1635 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1636 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1637 _test_range_text(line, range, extext);
1640 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1641 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1643 LONG c = 0xdeadbeef;
1646 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1647 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1648 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1649 _test_range_text(line, range, NULL);
1652 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1653 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1654 LPWSTR unit, LONG cnt, LONG excnt)
1656 LONG c = 0xdeadbeef;
1659 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1660 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1661 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1664 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1665 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1667 LONG c = 0xdeadbeef;
1670 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1671 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1672 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1675 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1676 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1679 BSTR bstr = a2bstr(text);
1681 hres = IHTMLTxtRange_put_text(range, bstr);
1682 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1683 SysFreeString(bstr);
1684 _test_range_text(line, range, NULL);
1687 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1688 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1694 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1695 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1696 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1699 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1700 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1706 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1707 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1708 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1711 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1712 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1713 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1716 test_range_inrange(range1, range2, VARIANT_TRUE);
1717 test_range_inrange(range2, range1, VARIANT_TRUE);
1721 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1722 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1727 hres = IHTMLTxtRange_parentElement(range, &elem);
1728 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1730 _test_elem_type(line, (IUnknown*)elem, type);
1732 IHTMLElement_Release(elem);
1735 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1736 static void _test_elem_collection(unsigned line, IUnknown *unk,
1737 const elem_type_t *elem_types, LONG exlen)
1739 IHTMLElementCollection *col;
1742 VARIANT name, index;
1743 IDispatch *disp, *disp2;
1746 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1747 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1749 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1751 hres = IHTMLElementCollection_get_length(col, &len);
1752 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1753 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1758 V_VT(&index) = VT_EMPTY;
1760 for(i=0; i<len; i++) {
1761 V_VT(&name) = VT_I4;
1763 disp = (void*)0xdeadbeef;
1764 hres = IHTMLElementCollection_item(col, name, index, &disp);
1765 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1766 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1767 if(FAILED(hres) || !disp)
1770 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1773 V_VT(&name) = VT_UINT;
1775 disp2 = (void*)0xdeadbeef;
1776 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1777 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1778 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1780 IDispatch_Release(disp2);
1783 IDispatch_Release(disp);
1786 V_VT(&name) = VT_I4;
1788 disp = (void*)0xdeadbeef;
1789 hres = IHTMLElementCollection_item(col, name, index, &disp);
1790 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1791 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1793 V_VT(&name) = VT_I4;
1795 disp = (void*)0xdeadbeef;
1796 hres = IHTMLElementCollection_item(col, name, index, &disp);
1797 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1798 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1800 IHTMLElementCollection_Release(col);
1803 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1804 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1806 IHTMLElement *elem = _get_elem_iface(line, unk);
1810 hres = IHTMLElement_get_all(elem, &disp);
1811 IHTMLElement_Release(elem);
1812 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1814 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1815 IDispatch_Release(disp);
1818 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1819 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1821 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1822 IHTMLElementCollection *col = NULL;
1823 elem_type_t *types = NULL;
1828 tmp = a2bstr(elem_type_infos[type].tag);
1829 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1831 IHTMLElement2_Release(elem);
1832 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1833 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1836 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1837 for(i=0; i<exlen; i++)
1841 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1843 HeapFree(GetProcessHeap(), 0, types);
1846 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1847 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1852 hres = IHTMLElement_get_innerText(elem, &text);
1853 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1854 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1855 wine_dbgstr_w(text), extext);
1856 SysFreeString(text);
1859 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1860 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1862 IHTMLDOMChildrenCollection *col;
1867 hres = IHTMLElement_put_innerText(elem, str);
1868 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1871 _test_elem_innertext(line, elem, text);
1874 col = _get_child_nodes(line, (IUnknown*)elem);
1875 ok(col != NULL, "col == NULL\n");
1877 LONG length = 0, type;
1880 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1881 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1882 ok(length == 1, "length = %d\n", length);
1884 node = _get_child_item(line, col, 0);
1885 ok(node != NULL, "node == NULL\n");
1887 type = _get_node_type(line, (IUnknown*)node);
1888 ok(type == 3, "type=%d\n", type);
1889 IHTMLDOMNode_Release(node);
1892 IHTMLDOMChildrenCollection_Release(col);
1897 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1898 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1900 IHTMLElement *elem = _get_elem_iface(line, unk);
1904 hres = IHTMLElement_get_innerHTML(elem, &html);
1905 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1907 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1909 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1911 IHTMLElement_Release(elem);
1912 SysFreeString(html);
1915 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1916 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1918 IHTMLElement *elem = _get_elem_iface(line, unk);
1922 html = a2bstr(inner_html);
1923 hres = IHTMLElement_put_innerHTML(elem, html);
1924 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1926 IHTMLElement_Release(elem);
1927 SysFreeString(html);
1930 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1931 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1933 IHTMLElement *elem = _get_elem_iface(line, unk);
1937 html = a2bstr(outer_html);
1938 hres = IHTMLElement_put_outerHTML(elem, html);
1939 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1941 IHTMLElement_Release(elem);
1942 SysFreeString(html);
1945 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1946 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1948 IHTMLElement *elem = _get_elem_iface(line, unk);
1952 hres = IHTMLElement_get_outerHTML(elem, &html);
1953 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1954 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1956 IHTMLElement_Release(elem);
1957 SysFreeString(html);
1960 #define get_first_child(n) _get_first_child(__LINE__,n)
1961 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1963 IHTMLDOMNode *node = _get_node_iface(line, unk);
1964 IHTMLDOMNode *child = NULL;
1967 hres = IHTMLDOMNode_get_firstChild(node, &child);
1968 IHTMLDOMNode_Release(node);
1969 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1974 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1975 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1977 IHTMLDOMNode *node = _get_node_iface(line, unk);
1978 VARIANT_BOOL b = 0xdead;
1981 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1982 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1983 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1985 IHTMLDOMNode_Release(node);
1988 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1989 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1991 IHTMLDOMNode *node = _get_node_iface(line, unk);
1992 IHTMLDOMNode *parent;
1995 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1996 IHTMLDOMNode_Release(node);
1997 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
2002 #define node_get_next(u) _node_get_next(__LINE__,u)
2003 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
2005 IHTMLDOMNode *node = _get_node_iface(line, unk);
2009 hres = IHTMLDOMNode_get_nextSibling(node, &next);
2010 IHTMLDOMNode_Release(node);
2011 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
2016 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2017 static IHTMLDOMNode *_node_get_prev(unsigned line, IUnknown *unk)
2019 IHTMLDOMNode *node = _get_node_iface(line, unk);
2023 hres = IHTMLDOMNode_get_previousSibling(node, &prev);
2024 IHTMLDOMNode_Release(node);
2025 ok_(__FILE__,line) (hres == S_OK, "get_previousSibling failed: %08x\n", hres);
2030 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2031 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
2033 IHTMLElement *elem = _get_elem_iface(line, unk);
2034 IHTMLElement *parent;
2037 hres = IHTMLElement_get_parentElement(elem, &parent);
2038 IHTMLElement_Release(elem);
2039 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
2044 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2045 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2047 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2048 VARIANT_BOOL disabled = 100;
2052 hres = IHTMLElement3_get_disabled(elem3, &disabled);
2053 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2054 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2055 IHTMLElement3_Release(elem3);
2058 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2059 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
2061 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2065 hres = IHTMLElement3_put_disabled(elem3, b);
2066 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2068 IHTMLElement3_Release(elem3);
2069 _test_elem3_get_disabled(line, unk, b);
2072 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2073 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2075 VARIANT_BOOL disabled = 100;
2078 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2079 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2080 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2082 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2085 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2086 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2088 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2092 hres = IHTMLDOMTextNode_get_length(text, &length);
2093 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2094 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2095 IHTMLDOMTextNode_Release(text);
2098 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2099 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2103 hres = IHTMLSelectElement_put_disabled(select, b);
2104 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2106 _test_select_get_disabled(line, select, b);
2109 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2110 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2112 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2113 IHTMLTextContainer *txtcont;
2114 LONG l = -1, l2 = -1;
2117 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2118 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2119 IHTMLElement2_Release(elem);
2121 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2122 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2124 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2125 IHTMLTextContainer_Release(txtcont);
2126 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2127 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2132 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2133 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2135 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2136 IHTMLTextContainer *txtcont;
2137 LONG l = -1, l2 = -1;
2140 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2141 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2142 IHTMLElement2_Release(elem);
2144 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2145 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2147 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2148 IHTMLTextContainer_Release(txtcont);
2149 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2150 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2155 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2156 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2158 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2159 IHTMLTextContainer *txtcont;
2160 LONG l = -1, l2 = -1;
2163 hres = IHTMLElement2_get_scrollTop(elem, &l);
2164 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2165 IHTMLElement2_Release(elem);
2167 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2168 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2170 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2171 IHTMLTextContainer_Release(txtcont);
2172 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2173 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2178 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2179 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2181 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2182 IHTMLTextContainer *txtcont;
2183 LONG l = -1, l2 = -1;
2186 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2187 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2189 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2190 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2191 IHTMLElement2_Release(elem);
2193 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2194 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2196 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2197 IHTMLTextContainer_Release(txtcont);
2198 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2199 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2202 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2203 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc, const char *broken_src)
2205 IHTMLImgElement *img = _get_img_iface(line, unk);
2209 hres = IHTMLImgElement_get_src(img, &src);
2210 IHTMLImgElement_Release(img);
2211 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2212 ok_(__FILE__,line) (!strcmp_wa(src, exsrc) || (broken_src && broken(!strcmp_wa(src, broken_src))),
2213 "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2217 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2218 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2220 IHTMLImgElement *img = _get_img_iface(line, unk);
2225 hres = IHTMLImgElement_put_src(img, tmp);
2226 IHTMLImgElement_Release(img);
2228 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2231 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2232 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2234 IHTMLImgElement *img = _get_img_iface(line, unk);
2238 hres = IHTMLImgElement_get_alt(img, &alt);
2239 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2241 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2243 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2247 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2248 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2250 IHTMLImgElement *img = _get_img_iface(line, unk);
2255 hres = IHTMLImgElement_put_alt(img, tmp);
2256 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2259 _test_img_alt(line, unk, alt);
2262 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2263 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2265 IHTMLImgElement *img = _get_img_iface(line, unk);
2269 hres = IHTMLImgElement_get_name(img, &sName);
2270 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2271 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2272 IHTMLImgElement_Release(img);
2273 SysFreeString(sName);
2276 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2277 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2282 hres = IHTMLInputElement_get_type(input, &type);
2283 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2284 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2285 SysFreeString(type);
2288 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2289 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2291 BSTR name = (BSTR)0xdeadbeef;
2294 hres = IHTMLInputElement_get_name(input, &name);
2295 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2297 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2299 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2300 SysFreeString(name);
2303 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2304 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2306 BSTR tmp = a2bstr(name);
2309 hres = IHTMLInputElement_put_name(input, tmp);
2310 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2313 _test_input_name(line, input, name);
2316 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2317 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2319 VARIANT_BOOL disabled = 100;
2322 hres = IHTMLInputElement_get_disabled(input, &disabled);
2323 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2324 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2326 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2329 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2330 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2334 hres = IHTMLInputElement_put_disabled(input, b);
2335 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2337 _test_input_get_disabled(line, input, b);
2340 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2341 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2343 VARIANT_BOOL checked = 100;
2346 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2347 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2348 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2351 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2352 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2356 hres = IHTMLInputElement_put_defaultChecked(input, b);
2357 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2359 _test_input_get_defaultchecked(line, input, b);
2362 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2363 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2365 VARIANT_BOOL checked = 100;
2368 hres = IHTMLInputElement_get_checked(input, &checked);
2369 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2370 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2373 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2374 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2378 hres = IHTMLInputElement_put_checked(input, b);
2379 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2381 _test_input_get_checked(line, input, b);
2384 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2385 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2387 IHTMLInputElement *input;
2391 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2392 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2396 hres = IHTMLInputElement_get_value(input, &bstr);
2397 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2399 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2401 ok_(__FILE__,line) (!bstr, "exval != NULL\n");
2402 SysFreeString(bstr);
2403 IHTMLInputElement_Release(input);
2406 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2407 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2409 IHTMLInputElement *input;
2413 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2414 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2419 hres = IHTMLInputElement_put_value(input, bstr);
2420 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2421 SysFreeString(bstr);
2422 IHTMLInputElement_Release(input);
2424 _test_input_value(line, unk, val);
2427 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2428 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2433 hres = IHTMLInputElement_get_src(input, &src);
2434 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2436 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2438 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2442 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2443 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2449 hres = IHTMLInputElement_put_src(input, tmp);
2451 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2453 _test_input_src(line, input, src);
2456 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2457 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2459 IHTMLElement *elem = _get_elem_iface(line, unk);
2460 BSTR class = (void*)0xdeadbeef;
2463 hres = IHTMLElement_get_className(elem, &class);
2464 IHTMLElement_Release(elem);
2465 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2467 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2469 ok_(__FILE__,line) (!class, "class != NULL\n");
2470 SysFreeString(class);
2473 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2474 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2476 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2480 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2481 IHTMLElement2_Release(elem2);
2482 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2483 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2486 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2487 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2489 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2492 hres = IHTMLElement2_put_tabIndex(elem2, index);
2493 IHTMLElement2_Release(elem2);
2494 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2496 _test_elem_tabindex(line, unk, index);
2499 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2500 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2502 IHTMLStyleElement *style = _get_style_iface(line, unk);
2506 hres = IHTMLStyleElement_get_media(style, &media);
2507 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2509 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2511 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2513 IHTMLStyleElement_Release(style);
2514 SysFreeString(media);
2517 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2518 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2520 IHTMLStyleElement *style = _get_style_iface(line, unk);
2524 str = a2bstr(media);
2525 hres = IHTMLStyleElement_put_media(style, str);
2526 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2527 IHTMLStyleElement_Release(style);
2530 _test_style_media(line, unk, media);
2533 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2534 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2536 IHTMLStyleElement *style = _get_style_iface(line, unk);
2540 hres = IHTMLStyleElement_get_type(style, &type);
2541 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2543 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2545 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2547 IHTMLStyleElement_Release(style);
2548 SysFreeString(type);
2551 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2552 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2554 IHTMLStyleElement *style = _get_style_iface(line, unk);
2559 hres = IHTMLStyleElement_put_type(style, str);
2560 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2561 IHTMLStyleElement_Release(style);
2564 _test_style_type(line, unk, type);
2567 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2568 static void _test_elem_filters(unsigned line, IUnknown *unk)
2570 IHTMLElement *elem = _get_elem_iface(line, unk);
2572 IHTMLFiltersCollection *filters;
2574 hres = IHTMLElement_get_filters(elem, &filters);
2575 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2576 "get_filters failed: %08x\n", hres);
2580 IDispatchEx *dispex;
2582 hres = IHTMLFiltersCollection_get_length(filters, &len);
2583 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2584 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2586 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2587 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2588 "Could not get IDispatchEx interface: %08x\n", hres);
2589 if(SUCCEEDED(hres)) {
2590 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2591 IDispatchEx_Release(dispex);
2594 IHTMLFiltersCollection_Release(filters);
2597 IHTMLElement_Release(elem);
2600 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2601 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2603 IHTMLElement *elem = _get_elem_iface(line, unk);
2607 tmp = class ? a2bstr(class) : NULL;
2608 hres = IHTMLElement_put_className(elem, tmp);
2609 IHTMLElement_Release(elem);
2610 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2613 _test_elem_class(line, unk, class);
2616 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2617 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2619 IHTMLElement *elem = _get_elem_iface(line, unk);
2620 BSTR id = (void*)0xdeadbeef;
2623 hres = IHTMLElement_get_id(elem, &id);
2624 IHTMLElement_Release(elem);
2625 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2628 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2630 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2635 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2636 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2638 IHTMLElement *elem = _get_elem_iface(line, unk);
2639 BSTR tmp = a2bstr(new_id);
2642 hres = IHTMLElement_put_id(elem, tmp);
2643 IHTMLElement_Release(elem);
2645 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2647 _test_elem_id(line, unk, new_id);
2650 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2651 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2653 IHTMLElement *elem = _get_elem_iface(line, unk);
2657 hres = IHTMLElement_get_title(elem, &title);
2658 IHTMLElement_Release(elem);
2659 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2661 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2663 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2665 SysFreeString(title);
2668 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2669 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2671 IHTMLElement *elem = _get_elem_iface(line, unk);
2675 tmp = a2bstr(title);
2676 hres = IHTMLElement_put_title(elem, tmp);
2677 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2679 IHTMLElement_Release(elem);
2683 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2684 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2686 IHTMLDOMNode *node = _get_node_iface(line, unk);
2690 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2691 IHTMLDOMNode_Release(node);
2692 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2695 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2696 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2698 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2704 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2705 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2707 IHTMLDOMNode *node = _get_node_iface(line, unk);
2711 V_VT(&var) = VT_BSTR;
2712 V_BSTR(&var) = a2bstr(val);
2714 hres = IHTMLDOMNode_put_nodeValue(node, var);
2715 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2716 IHTMLDOMNode_Release(node);
2720 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2721 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2723 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2727 hres = IHTMLElement2_get_clientWidth(elem, &l);
2728 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2729 hres = IHTMLElement2_get_clientHeight(elem, &l);
2730 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2732 IHTMLElement2_Release(elem);
2735 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2736 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2738 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2742 hres = IHTMLElement2_get_clientLeft(elem, &l);
2743 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2744 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2746 hres = IHTMLElement2_get_clientTop(elem, &l);
2747 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2748 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2750 IHTMLElement2_Release(elem);
2753 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2754 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2756 IHTMLFormElement *form = _get_form_iface(line, unk);
2757 LONG len = 0xdeadbeef;
2760 hres = IHTMLFormElement_get_length(form, &len);
2761 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2762 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2764 IHTMLFormElement_Release(form);
2767 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2768 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2770 IHTMLFormElement *form = _get_form_iface(line, unk);
2771 BSTR action = (void*)0xdeadbeef;
2774 hres = IHTMLFormElement_get_action(form, &action);
2775 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2777 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2779 ok_(__FILE__,line)(!action, "action=%p\n", action);
2781 SysFreeString(action);
2782 IHTMLFormElement_Release(form);
2785 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2786 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2788 IHTMLFormElement *form = _get_form_iface(line, unk);
2789 BSTR tmp = a2bstr(action);
2792 hres = IHTMLFormElement_put_action(form, tmp);
2793 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2795 IHTMLFormElement_Release(form);
2797 _test_form_action(line, unk, action);
2800 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2801 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2803 IHTMLFormElement *form = _get_form_iface(line, unk);
2804 BSTR method = (void*)0xdeadbeef;
2807 hres = IHTMLFormElement_get_method(form, &method);
2808 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2810 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2812 ok_(__FILE__,line)(!method, "method=%p\n", method);
2814 SysFreeString(method);
2815 IHTMLFormElement_Release(form);
2818 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2819 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2821 IHTMLFormElement *form = _get_form_iface(line, unk);
2822 BSTR tmp = a2bstr(method);
2825 hres = IHTMLFormElement_put_method(form, tmp);
2826 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2828 IHTMLFormElement_Release(form);
2830 if(exp_hres == S_OK)
2831 _test_form_method(line, unk, method);
2834 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2835 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2837 IHTMLFormElement *form = _get_form_iface(line, unk);
2838 BSTR name = (void*)0xdeadbeef;
2841 hres = IHTMLFormElement_get_name(form, &name);
2842 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2844 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2846 ok_(__FILE__,line)(!name, "name=%p\n", name);
2848 SysFreeString(name);
2849 IHTMLFormElement_Release(form);
2852 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2853 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2855 IHTMLFormElement *form = _get_form_iface(line, unk);
2856 BSTR tmp = a2bstr(name);
2859 hres = IHTMLFormElement_put_name(form, tmp);
2860 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2862 IHTMLFormElement_Release(form);
2864 _test_form_name(line, unk, name);
2867 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2868 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2870 IHTMLFormElement *form = _get_form_iface(line, unk);
2871 BSTR encoding = (void*)0xdeadbeef;
2874 hres = IHTMLFormElement_get_encoding(form, &encoding);
2875 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2877 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2879 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2881 SysFreeString(encoding);
2882 IHTMLFormElement_Release(form);
2885 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2886 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2888 IHTMLFormElement *form = _get_form_iface(line, unk);
2889 BSTR tmp = a2bstr(encoding);
2892 hres = IHTMLFormElement_put_encoding(form, tmp);
2893 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2895 IHTMLFormElement_Release(form);
2897 if(exp_hres == S_OK)
2898 _test_form_encoding(line, unk, encoding);
2901 #define test_form_elements(a) _test_form_elements(__LINE__,a)
2902 static void _test_form_elements(unsigned line, IUnknown *unk)
2904 IHTMLFormElement *form = _get_form_iface(line, unk);
2909 hres = IHTMLFormElement_get_elements(form, &disp);
2910 ok_(__FILE__,line)(hres == S_OK, "get_elements failed: %08x\n", hres);
2911 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
2912 ok_(__FILE__,line)(iface_cmp((IUnknown*)form, (IUnknown*)disp), "disp != form\n");
2914 IDispatch_Release(disp);
2915 IHTMLFormElement_Release(form);
2918 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2919 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2921 IHTMLElement *elem = _get_elem_iface(line, unk);
2922 IHTMLDocument2 *doc;
2927 hres = IHTMLElement_get_document(elem, &disp);
2928 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2929 ok(disp != NULL, "disp == NULL\n");
2931 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2932 IDispatch_Release(disp);
2933 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2938 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
2939 static IHTMLDOMAttribute *_get_elem_attr_node(unsigned line, IUnknown *unk, const char *attr_name, BOOL expect_success)
2941 IHTMLElement4 *elem = _get_elem4_iface(line, unk);
2942 BSTR str = a2bstr(attr_name);
2943 IHTMLDOMAttribute *attr;
2946 attr = (void*)0xdeadbeef;
2947 hres = IHTMLElement4_getAttributeNode(elem, str, &attr);
2948 ok_(__FILE__,line)(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
2950 ok_(__FILE__,line)(attr != NULL, "attr = NULL\n");
2952 ok_(__FILE__,line)(!attr, "attr = %p\n", attr);
2954 IHTMLElement4_Release(elem);
2959 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
2960 static void _get_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT *v, VARTYPE vt)
2964 hres = IHTMLDOMAttribute_get_nodeValue(attr, v);
2965 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2966 ok_(__FILE__,line) (V_VT(v) == vt, "vt=%d, expected %d\n", V_VT(v), vt);
2969 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2970 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2972 IHTMLDocument2 *doc;
2976 hres = IHTMLWindow2_get_document(window, &doc);
2977 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2978 ok(doc != NULL, "disp == NULL\n");
2983 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2984 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
2989 hres = IHTMLDocument2_get_body(doc, &elem);
2990 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2991 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
2996 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2997 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2999 IHTMLElement *elem = NULL;
3004 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
3005 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3006 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
3012 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
3013 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
3015 IHTMLDocument3 *doc3;
3016 IHTMLDOMNode *node = NULL;
3020 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3021 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
3024 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
3025 IHTMLDocument3_Release(doc3);
3027 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
3028 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
3033 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
3034 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
3036 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3037 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
3038 IHTMLDOMNode *new_child = NULL;
3041 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
3042 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
3043 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3044 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3046 IHTMLDOMNode_Release(node);
3047 IHTMLDOMNode_Release(child);
3052 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
3053 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
3055 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3056 IHTMLDOMNode *new_child = NULL;
3059 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
3060 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
3061 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3062 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3064 IHTMLDOMNode_Release(node);
3069 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
3070 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
3072 IHTMLDOMNode *node = _get_node_iface(line, unk);
3073 IHTMLDOMNode *new_node = NULL;
3076 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
3077 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
3078 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
3079 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
3081 IHTMLDOMNode_Release(node);
3082 IHTMLDOMNode_Release(new_node);
3085 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
3086 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
3091 hres = IHTMLDocument2_get_title(doc, &title);
3092 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3093 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
3094 SysFreeString(title);
3097 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3098 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3103 tmp = a2bstr(title);
3104 hres = IHTMLDocument2_put_title(doc, tmp);
3105 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3109 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
3110 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
3115 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
3116 LOCALE_USER_DEFAULT, &dispid);
3117 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
3120 DISPPARAMS params = {NULL,NULL,0,0};
3121 DISPID dispidNamed = DISPID_PROPERTYPUT;
3126 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3127 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
3128 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
3131 params.cNamedArgs = 1;
3132 params.rgdispidNamedArgs = &dispidNamed;
3133 V_VT(&arg) = VT_BSTR;
3134 V_BSTR(&arg) = a2bstr("none");
3135 params.rgvarg = &arg;
3136 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3137 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3138 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
3141 V_VT(&arg) = VT_BSTR;
3142 V_BSTR(&arg) = a2bstr("dotted");
3143 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3144 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3145 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
3148 V_VT(&arg) = VT_BSTR;
3149 V_BSTR(&arg) = a2bstr("dashed");
3150 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3151 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3152 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
3155 V_VT(&arg) = VT_BSTR;
3156 V_BSTR(&arg) = a2bstr("solid");
3157 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3158 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3159 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
3162 V_VT(&arg) = VT_BSTR;
3163 V_BSTR(&arg) = a2bstr("double");
3164 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3165 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3166 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
3169 V_VT(&arg) = VT_BSTR;
3170 V_BSTR(&arg) = a2bstr("groove");
3171 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3172 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3173 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
3176 V_VT(&arg) = VT_BSTR;
3177 V_BSTR(&arg) = a2bstr("ridge");
3178 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3179 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3180 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
3183 V_VT(&arg) = VT_BSTR;
3184 V_BSTR(&arg) = a2bstr("inset");
3185 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3186 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3187 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
3190 V_VT(&arg) = VT_BSTR;
3191 V_BSTR(&arg) = a2bstr("outset");
3192 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3193 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3194 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
3197 V_VT(&arg) = VT_BSTR;
3198 V_BSTR(&arg) = a2bstr("invalid");
3199 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3200 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3201 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
3204 params.rgvarg = &vDefault;
3205 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3206 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3207 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
3208 VariantClear(&vDefault);
3212 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3213 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
3215 BSTR text = (void*)0xdeadbeef;
3218 hres = IHTMLStyle_get_cssText(style, &text);
3219 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
3221 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
3223 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
3225 SysFreeString(text);
3228 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3229 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
3235 hres = IHTMLStyle_put_cssText(style, tmp);
3236 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3240 static void test_elem_bounding_client_rect(IUnknown *unk)
3242 IHTMLRect *rect, *rect2;
3243 IHTMLElement2 *elem2;
3247 elem2 = get_elem2_iface(unk);
3248 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3249 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3250 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3251 IHTMLElement2_Release(elem2);
3252 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3253 ok(rect != NULL, "rect == NULL\n");
3254 ok(rect != rect2, "rect == rect2\n");
3255 IHTMLRect_Release(rect2);
3257 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3260 hres = IHTMLRect_get_top(rect, &l);
3261 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3262 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3265 hres = IHTMLRect_get_left(rect, &l);
3266 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3267 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3270 hres = IHTMLRect_get_bottom(rect, &l);
3271 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3272 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3275 hres = IHTMLRect_get_right(rect, &l);
3276 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3277 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3279 IHTMLRect_Release(rect);
3282 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3283 const elem_type_t *elem_types, LONG len)
3286 VARIANT name, index;
3290 V_VT(&index) = VT_EMPTY;
3291 V_VT(&name) = VT_BSTR;
3292 V_BSTR(&name) = a2bstr(n);
3294 hres = IHTMLElementCollection_item(col, name, index, &disp);
3295 ok(hres == S_OK, "item failed: %08x\n", hres);
3297 test_elem_collection((IUnknown*)disp, elem_types, len);
3298 IDispatch_Release(disp);
3299 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3303 V_VT(&index) = VT_I4;
3305 for(i=0; i<len; i++) {
3307 disp = (void*)0xdeadbeef;
3308 hres = IHTMLElementCollection_item(col, name, index, &disp);
3309 ok(hres == S_OK, "item failed: %08x\n", hres);
3310 ok(disp != NULL, "disp == NULL\n");
3311 if(FAILED(hres) || !disp)
3314 test_elem_type((IUnknown*)disp, elem_types[i]);
3316 IDispatch_Release(disp);
3320 disp = (void*)0xdeadbeef;
3321 hres = IHTMLElementCollection_item(col, name, index, &disp);
3322 ok(hres == S_OK, "item failed: %08x\n", hres);
3323 ok(disp == NULL, "disp != NULL\n");
3326 disp = (void*)0xdeadbeef;
3327 hres = IHTMLElementCollection_item(col, name, index, &disp);
3328 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3329 ok(disp == NULL, "disp != NULL\n");
3332 SysFreeString(V_BSTR(&name));
3335 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3337 IHTMLElementCollection *col;
3339 IDispatch *disp = (void*)0xdeadbeef;
3340 VARIANT name, index;
3343 hres = IHTMLDocument2_get_all(doc, &col);
3344 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3345 ok(col != NULL, "col == NULL\n");
3346 if(FAILED(hres) || !col)
3349 V_VT(&index) = VT_EMPTY;
3350 V_VT(&name) = VT_BSTR;
3351 V_BSTR(&name) = a2bstr(id);
3353 hres = IHTMLElementCollection_item(col, name, index, &disp);
3354 IHTMLElementCollection_Release(col);
3355 SysFreeString(V_BSTR(&name));
3356 ok(hres == S_OK, "item failed: %08x\n", hres);
3357 if(!expect_success) {
3358 ok(disp == NULL, "disp != NULL\n");
3362 ok(disp != NULL, "disp == NULL\n");
3366 elem = get_elem_iface((IUnknown*)disp);
3367 IDispatch_Release(disp);
3372 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3374 IHTMLDocument3 *doc3;
3379 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3380 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3383 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3385 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3387 IHTMLDocument3_Release(doc3);
3392 static void test_select_elem(IHTMLSelectElement *select)
3394 IDispatch *disp, *disp2;
3395 VARIANT name, index;
3398 test_select_type(select, "select-one");
3399 test_select_length(select, 2);
3400 test_select_selidx(select, 0);
3401 test_select_put_selidx(select, 1);
3403 test_select_set_value(select, "val1");
3404 test_select_value(select, "val1");
3406 test_select_get_disabled(select, VARIANT_FALSE);
3407 test_select_set_disabled(select, VARIANT_TRUE);
3408 test_select_set_disabled(select, VARIANT_FALSE);
3411 hres = IHTMLSelectElement_get_options(select, &disp);
3412 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3413 ok(disp != NULL, "options == NULL\n");
3414 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3415 IDispatch_Release(disp);
3417 V_VT(&index) = VT_EMPTY;
3418 V_VT(&name) = VT_I4;
3420 disp = (void*)0xdeadbeef;
3421 hres = IHTMLSelectElement_item(select, name, index, &disp);
3422 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3423 ok(!disp, "disp = %p\n", disp);
3426 disp = (void*)0xdeadbeef;
3427 hres = IHTMLSelectElement_item(select, name, index, &disp);
3428 ok(hres == S_OK, "item failed: %08x\n", hres);
3429 ok(!disp, "disp = %p\n", disp);
3432 hres = IHTMLSelectElement_item(select, name, index, NULL);
3433 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3436 hres = IHTMLSelectElement_item(select, name, index, &disp);
3437 ok(hres == S_OK, "item failed: %08x\n", hres);
3438 ok(disp != NULL, "disp = NULL\n");
3439 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3441 V_VT(&index) = VT_I4;
3444 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3445 ok(hres == S_OK, "item failed: %08x\n", hres);
3446 ok(disp2 != NULL, "disp = NULL\n");
3447 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3448 IDispatch_Release(disp2);
3449 IDispatch_Release(disp);
3452 static void test_form_item(IHTMLElement *elem)
3454 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3455 IDispatch *disp, *disp2;
3456 VARIANT name, index;
3459 V_VT(&index) = VT_EMPTY;
3460 V_VT(&name) = VT_I4;
3462 disp = (void*)0xdeadbeef;
3463 hres = IHTMLFormElement_item(form, name, index, &disp);
3464 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3465 ok(!disp, "disp = %p\n", disp);
3468 disp = (void*)0xdeadbeef;
3469 hres = IHTMLFormElement_item(form, name, index, &disp);
3470 ok(hres == S_OK, "item failed: %08x\n", hres);
3471 ok(!disp, "disp = %p\n", disp);
3474 hres = IHTMLFormElement_item(form, name, index, NULL);
3475 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3478 hres = IHTMLFormElement_item(form, name, index, &disp);
3479 ok(hres == S_OK, "item failed: %08x\n", hres);
3480 ok(disp != NULL, "disp = NULL\n");
3481 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3483 V_VT(&index) = VT_I4;
3486 hres = IHTMLFormElement_item(form, name, index, &disp2);
3487 ok(hres == S_OK, "item failed: %08x\n", hres);
3488 ok(disp2 != NULL, "disp = NULL\n");
3489 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3490 IDispatch_Release(disp2);
3491 IDispatch_Release(disp);
3494 static void test_create_option_elem(IHTMLDocument2 *doc)
3496 IHTMLOptionElement *option;
3498 option = create_option_elem(doc, "test text", "test value");
3500 test_option_put_text(option, "new text");
3501 test_option_put_value(option, "new value");
3502 test_option_put_selected(option, VARIANT_TRUE);
3503 test_option_put_selected(option, VARIANT_FALSE);
3505 IHTMLOptionElement_Release(option);
3508 static void test_create_img_elem(IHTMLDocument2 *doc)
3510 IHTMLImgElement *img;
3512 img = create_img_elem(doc, 10, 15);
3515 test_img_put_width(img, 5);
3516 test_img_put_height(img, 20);
3518 IHTMLImgElement_Release(img);
3522 img = create_img_elem(doc, -1, -1);
3525 test_img_put_width(img, 5);
3526 test_img_put_height(img, 20);
3528 IHTMLImgElement_Release(img);
3532 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3534 IHTMLBodyElement *body;
3535 IHTMLTxtRange *range;
3539 elem = doc_get_body(doc);
3540 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3541 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3542 IHTMLElement_Release(elem);
3544 hres = IHTMLBodyElement_createTextRange(body, &range);
3545 IHTMLBodyElement_Release(body);
3546 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3551 static void test_txtrange(IHTMLDocument2 *doc)
3553 IHTMLTxtRange *body_range, *range, *range2;
3554 IHTMLSelectionObject *selection;
3555 IDispatch *disp_range;
3558 body_range = test_create_body_range(doc);
3560 test_range_text(body_range, "test abc 123\r\nit's text");
3562 hres = IHTMLTxtRange_duplicate(body_range, &range);
3563 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3565 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3566 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3567 test_range_isequal(range, range2, VARIANT_TRUE);
3569 test_range_text(range, "test abc 123\r\nit's text");
3570 test_range_text(body_range, "test abc 123\r\nit's text");
3572 test_range_collapse(range, TRUE);
3573 test_range_isequal(range, range2, VARIANT_FALSE);
3574 test_range_inrange(range, range2, VARIANT_FALSE);
3575 test_range_inrange(range2, range, VARIANT_TRUE);
3576 IHTMLTxtRange_Release(range2);
3578 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3579 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3580 test_range_move(range, characterW, 2, 2);
3581 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3583 test_range_collapse(range, FALSE);
3584 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3586 test_range_collapse(range, FALSE);
3587 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3588 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3589 test_range_move(range, characterW, 2, 2);
3590 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3591 test_range_moveend(range, characterW, -5, -5);
3592 test_range_text(range, NULL);
3593 test_range_moveend(range, characterW, 3, 3);
3594 test_range_text(range, "c 1");
3595 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3596 test_range_collapse(range, TRUE);
3597 test_range_move(range, characterW, 4, 4);
3598 test_range_moveend(range, characterW, 1, 1);
3599 test_range_text(range, " ");
3600 test_range_move(range, wordW, 1, 1);
3601 test_range_moveend(range, characterW, 2, 2);
3602 test_range_text(range, "ab");
3604 IHTMLTxtRange_Release(range);
3606 hres = IHTMLTxtRange_duplicate(body_range, &range);
3607 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3609 test_range_text(range, "test abc 123\r\nit's text");
3610 test_range_move(range, characterW, 3, 3);
3611 test_range_moveend(range, characterW, 1, 1);
3612 test_range_text(range, "t");
3613 test_range_moveend(range, characterW, 3, 3);
3614 test_range_text(range, "t ab");
3615 test_range_moveend(range, characterW, -2, -2);
3616 test_range_text(range, "t ");
3617 test_range_move(range, characterW, 6, 6);
3618 test_range_moveend(range, characterW, 3, 3);
3619 test_range_text(range, "123");
3620 test_range_moveend(range, characterW, 2, 2);
3621 test_range_text(range, "123\r\ni");
3623 IHTMLTxtRange_Release(range);
3625 hres = IHTMLTxtRange_duplicate(body_range, &range);
3626 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3628 test_range_move(range, wordW, 1, 1);
3629 test_range_moveend(range, characterW, 2, 2);
3630 test_range_text(range, "ab");
3632 test_range_move(range, characterW, -2, -2);
3633 test_range_moveend(range, characterW, 2, 2);
3634 test_range_text(range, "t ");
3636 test_range_move(range, wordW, 3, 3);
3637 test_range_move(range, wordW, -2, -2);
3638 test_range_moveend(range, characterW, 2, 2);
3639 test_range_text(range, "ab");
3641 test_range_move(range, characterW, -6, -5);
3642 test_range_moveend(range, characterW, -1, 0);
3643 test_range_moveend(range, characterW, -6, 0);
3644 test_range_move(range, characterW, 2, 2);
3645 test_range_moveend(range, characterW, 2, 2);
3646 test_range_text(range, "st");
3647 test_range_moveend(range, characterW, -6, -4);
3648 test_range_moveend(range, characterW, 2, 2);
3650 IHTMLTxtRange_Release(range);
3652 hres = IHTMLTxtRange_duplicate(body_range, &range);
3653 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3655 test_range_move(range, wordW, 2, 2);
3656 test_range_moveend(range, characterW, 2, 2);
3657 test_range_text(range, "12");
3659 test_range_move(range, characterW, 15, 14);
3660 test_range_move(range, characterW, -2, -2);
3661 test_range_moveend(range, characterW, 3, 2);
3662 test_range_text(range, "t");
3663 test_range_moveend(range, characterW, -1, -1);
3664 test_range_text(range, "t");
3665 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3666 test_range_move(range, characterW, -2, -2);
3667 test_range_moveend(range, characterW, 2, 2);
3668 test_range_text(range, "s ");
3669 test_range_move(range, characterW, 100, 7);
3670 test_range_move(range, wordW, 1, 0);
3671 test_range_move(range, characterW, -2, -2);
3672 test_range_moveend(range, characterW, 3, 2);
3673 test_range_text(range, "t");
3675 IHTMLTxtRange_Release(range);
3677 hres = IHTMLTxtRange_duplicate(body_range, &range);
3678 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3680 test_range_collapse(range, TRUE);
3681 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3682 test_range_put_text(range, "word");
3683 test_range_text(body_range, "wordabc 123\r\nit's text");
3684 test_range_text(range, NULL);
3685 test_range_moveend(range, characterW, 3, 3);
3686 test_range_text(range, "abc");
3687 test_range_movestart(range, characterW, -2, -2);
3688 test_range_text(range, "rdabc");
3689 test_range_movestart(range, characterW, 3, 3);
3690 test_range_text(range, "bc");
3691 test_range_movestart(range, characterW, 4, 4);
3692 test_range_text(range, NULL);
3693 test_range_movestart(range, characterW, -3, -3);
3694 test_range_text(range, "c 1");
3695 test_range_movestart(range, characterW, -7, -6);
3696 test_range_text(range, "wordabc 1");
3697 test_range_movestart(range, characterW, 100, 22);
3698 test_range_text(range, NULL);
3700 IHTMLTxtRange_Release(range);
3701 IHTMLTxtRange_Release(body_range);
3703 hres = IHTMLDocument2_get_selection(doc, &selection);
3704 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3706 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3707 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3708 IHTMLSelectionObject_Release(selection);
3710 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3711 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3712 IDispatch_Release(disp_range);
3714 test_range_text(range, NULL);
3715 test_range_moveend(range, characterW, 3, 3);
3716 test_range_text(range, "wor");
3717 test_range_parent(range, ET_BODY);
3718 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3719 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3720 test_range_move(range, characterW, 3, 3);
3721 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3722 test_range_moveend(range, characterW, -4, -4);
3723 test_range_put_text(range, "abc def ");
3724 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3725 test_range_move(range, wordW, 1, 1);
3726 test_range_movestart(range, characterW, -1, -1);
3727 test_range_text(range, " ");
3728 test_range_move(range, wordW, 1, 1);
3729 test_range_moveend(range, characterW, 3, 3);
3730 test_range_text(range, "def");
3731 test_range_put_text(range, "xyz");
3732 test_range_moveend(range, characterW, 1, 1);
3733 test_range_move(range, wordW, 1, 1);
3734 test_range_moveend(range, characterW, 2, 2);
3735 test_range_text(range, "ab");
3737 IHTMLTxtRange_Release(range);
3740 static void test_txtrange2(IHTMLDocument2 *doc)
3742 IHTMLTxtRange *range;
3744 range = test_create_body_range(doc);
3746 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3747 test_range_move(range, characterW, 5, 5);
3748 test_range_moveend(range, characterW, 1, 1);
3749 test_range_text(range, "2");
3750 test_range_move(range, characterW, -3, -3);
3751 test_range_moveend(range, characterW, 3, 3);
3752 test_range_text(range, "c\r\n\r\n1");
3753 test_range_collapse(range, VARIANT_FALSE);
3754 test_range_moveend(range, characterW, 4, 4);
3755 test_range_text(range, "23");
3756 test_range_moveend(range, characterW, 1, 1);
3757 test_range_text(range, "23\r\n\r\n\r\nd");
3758 test_range_moveend(range, characterW, -1, -1);
3759 test_range_text(range, "23");
3760 test_range_moveend(range, characterW, -1, -1);
3761 test_range_text(range, "23");
3762 test_range_moveend(range, characterW, -2, -2);
3763 test_range_text(range, "2");
3765 IHTMLTxtRange_Release(range);
3768 static void test_compatmode(IHTMLDocument2 *doc)
3770 IHTMLDocument5 *doc5;
3774 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3775 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3779 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3780 IHTMLDocument5_Release(doc5);
3781 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3782 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3783 SysFreeString(mode);
3786 static void test_location(IHTMLDocument2 *doc)
3788 IHTMLLocation *location, *location2;
3789 IHTMLWindow2 *window;
3794 hres = IHTMLDocument2_get_location(doc, &location);
3795 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3797 hres = IHTMLDocument2_get_location(doc, &location2);
3798 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3800 ok(location == location2, "location != location2\n");
3801 IHTMLLocation_Release(location2);
3803 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3804 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3806 hres = IHTMLWindow2_get_location(window, &location2);
3807 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3808 ok(location == location2, "location != location2\n");
3809 IHTMLLocation_Release(location2);
3811 test_ifaces((IUnknown*)location, location_iids);
3812 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3814 hres = IHTMLLocation_get_pathname(location, &str);
3815 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3816 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3819 hres = IHTMLLocation_get_href(location, NULL);
3820 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3822 hres = IHTMLLocation_get_href(location, &str);
3823 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3824 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3827 ref = IHTMLLocation_Release(location);
3828 ok(!ref, "location chould be destroyed here\n");
3831 static void test_plugins_col(IOmNavigator *nav)
3833 IHTMLPluginsCollection *col, *col2;
3837 hres = IOmNavigator_get_plugins(nav, &col);
3838 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3840 hres = IOmNavigator_get_plugins(nav, &col2);
3841 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3842 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3843 IHTMLPluginsCollection_Release(col2);
3845 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3847 ref = IHTMLPluginsCollection_Release(col);
3848 ok(!ref, "ref=%d\n", ref);
3851 static void test_mime_types_col(IOmNavigator *nav)
3853 IHTMLMimeTypesCollection *col, *col2;
3858 hres = IOmNavigator_get_mimeTypes(nav, &col);
3859 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
3861 hres = IOmNavigator_get_mimeTypes(nav, &col2);
3862 ok(hres == S_OK, "get_mimeTypes failed: %08x\n", hres);
3863 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3864 IHTMLMimeTypesCollection_Release(col2);
3866 test_disp((IUnknown*)col, &IID_IHTMLMimeTypesCollection, "[object]");
3868 length = 0xdeadbeef;
3869 hres = IHTMLMimeTypesCollection_get_length(col, &length);
3870 ok(hres == S_OK, "get_length failed: %08x\n", hres);
3871 ok(!length, "length = %d\n", length);
3873 ref = IHTMLMimeTypesCollection_Release(col);
3874 ok(!ref, "ref=%d\n", ref);
3877 static void test_navigator(IHTMLDocument2 *doc)
3879 IHTMLWindow2 *window;
3880 IOmNavigator *navigator, *navigator2;
3887 static const WCHAR v40[] = {'4','.','0'};
3889 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3890 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3892 hres = IHTMLWindow2_get_navigator(window, &navigator);
3893 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3894 ok(navigator != NULL, "navigator == NULL\n");
3895 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3897 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3898 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3899 ok(navigator != navigator2, "navigator2 != navihgator\n");
3901 IHTMLWindow2_Release(window);
3902 IOmNavigator_Release(navigator2);
3904 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3905 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3906 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3907 SysFreeString(bstr);
3910 hres = IOmNavigator_get_appName(navigator, &bstr);
3911 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3912 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3913 SysFreeString(bstr);
3916 hres = IOmNavigator_get_platform(navigator, &bstr);
3917 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3918 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "Win64" : "Win32")
3919 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3920 SysFreeString(bstr);
3923 hres = IOmNavigator_get_cpuClass(navigator, &bstr);
3924 ok(hres == S_OK, "get_cpuClass failed: %08x\n", hres);
3925 ok(!strcmp_wa(bstr, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr));
3926 SysFreeString(bstr);
3929 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3930 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3931 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3932 SysFreeString(bstr);
3934 hres = IOmNavigator_toString(navigator, NULL);
3935 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3938 hres = IOmNavigator_toString(navigator, &bstr);
3939 ok(hres == S_OK, "toString failed: %08x\n", hres);
3940 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3941 SysFreeString(bstr);
3944 hres = ObtainUserAgentString(0, buf, &size);
3945 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3948 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3949 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3950 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3951 SysFreeString(bstr);
3953 if(!strncmp(buf, "Mozilla/", 8)) {
3955 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3956 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3957 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3958 SysFreeString(bstr);
3960 skip("nonstandard user agent\n");
3963 test_plugins_col(navigator);
3964 test_mime_types_col(navigator);
3966 ref = IOmNavigator_Release(navigator);
3967 ok(!ref, "navigator should be destroyed here\n");
3970 static void test_screen(IHTMLWindow2 *window)
3972 IHTMLScreen *screen, *screen2;
3973 IDispatchEx *dispex;
3980 hres = IHTMLWindow2_get_screen(window, &screen);
3981 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3982 ok(screen != NULL, "screen == NULL\n");
3985 hres = IHTMLWindow2_get_screen(window, &screen2);
3986 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3987 ok(screen2 != NULL, "screen == NULL\n");
3988 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3989 IHTMLScreen_Release(screen2);
3991 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3992 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3993 if(SUCCEEDED(hres)) {
3994 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3995 IDispatchEx_Release(dispex);
3998 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
4000 exl = GetDeviceCaps(hdc, HORZRES);
4002 hres = IHTMLScreen_get_width(screen, &l);
4003 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4004 ok(l == exl, "width = %d, expected %d\n", l, exl);
4006 exl = GetDeviceCaps(hdc, VERTRES);
4008 hres = IHTMLScreen_get_height(screen, &l);
4009 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4010 ok(l == exl, "height = %d, expected %d\n", l, exl);
4012 exl = GetDeviceCaps(hdc, BITSPIXEL);
4014 hres = IHTMLScreen_get_colorDepth(screen, &l);
4015 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4016 ok(l == exl, "height = %d, expected %d\n", l, exl);
4020 SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0);
4023 hres = IHTMLScreen_get_availHeight(screen, &l);
4024 ok(hres == S_OK, "get_availHeight failed: %08x\n", hres);
4025 ok(l == work_area.bottom-work_area.top, "availHeight = %d, expected %d\n", l, work_area.bottom-work_area.top);
4028 hres = IHTMLScreen_get_availWidth(screen, &l);
4029 ok(hres == S_OK, "get_availWidth failed: %08x\n", hres);
4030 ok(l == work_area.right-work_area.left, "availWidth = %d, expected %d\n", l, work_area.right-work_area.left);
4032 IHTMLScreen_Release(screen);
4035 static void test_current_style(IHTMLCurrentStyle *current_style)
4041 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
4042 test_ifaces((IUnknown*)current_style, cstyle_iids);
4044 hres = IHTMLCurrentStyle_get_display(current_style, &str);
4045 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4046 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
4049 hres = IHTMLCurrentStyle_get_position(current_style, &str);
4050 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4051 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4054 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
4055 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4058 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
4059 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4060 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
4063 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
4064 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
4065 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
4068 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
4069 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4070 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
4073 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
4074 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
4075 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
4078 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
4079 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
4080 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
4083 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
4084 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
4085 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
4088 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
4089 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4090 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
4093 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
4094 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4095 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
4098 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
4099 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4100 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
4103 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
4104 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4105 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4108 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
4109 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4110 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
4113 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
4114 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4117 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
4118 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4121 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
4122 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4125 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
4126 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4129 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
4130 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
4133 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
4134 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4137 hres = IHTMLCurrentStyle_get_padding(current_style, &str);
4138 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
4141 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
4142 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4143 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4144 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
4147 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
4148 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4149 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4152 hres = IHTMLCurrentStyle_get_left(current_style, &v);
4153 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4154 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4157 hres = IHTMLCurrentStyle_get_top(current_style, &v);
4158 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4159 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4162 hres = IHTMLCurrentStyle_get_width(current_style, &v);
4163 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4164 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4167 hres = IHTMLCurrentStyle_get_height(current_style, &v);
4168 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4169 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4172 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
4173 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
4174 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4177 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
4178 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4179 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4180 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
4183 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
4184 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4185 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4186 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
4189 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
4190 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4191 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4194 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
4195 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4196 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4199 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
4200 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4201 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4205 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
4206 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4207 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4210 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
4211 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4212 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4215 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
4216 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4217 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4220 hres = IHTMLCurrentStyle_get_color(current_style, &v);
4221 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4222 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4225 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
4226 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
4227 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4230 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
4231 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4232 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4235 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
4236 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4237 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4240 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
4241 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4242 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4245 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
4246 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4247 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4250 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
4251 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
4252 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4255 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
4256 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4257 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4260 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
4261 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4262 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4265 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
4266 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
4267 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4270 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
4271 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4272 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4275 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
4276 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
4277 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4280 hres = IHTMLCurrentStyle_get_right(current_style, &v);
4281 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
4282 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4285 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
4286 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
4287 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4290 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
4291 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
4292 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4295 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
4296 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
4297 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4301 static void test_style2(IHTMLStyle2 *style2)
4307 str = (void*)0xdeadbeef;
4308 hres = IHTMLStyle2_get_position(style2, &str);
4309 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4310 ok(!str, "str != NULL\n");
4312 str = a2bstr("absolute");
4313 hres = IHTMLStyle2_put_position(style2, str);
4314 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4318 hres = IHTMLStyle2_get_position(style2, &str);
4319 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4320 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4324 V_VT(&v) = VT_EMPTY;
4325 hres = IHTMLStyle2_get_right(style2, &v);
4326 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4327 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4328 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4332 V_BSTR(&v) = a2bstr("3px");
4333 hres = IHTMLStyle2_put_right(style2, v);
4334 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4337 V_VT(&v) = VT_EMPTY;
4338 hres = IHTMLStyle2_get_right(style2, &v);
4339 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4340 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4341 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4345 static void test_style3(IHTMLStyle3 *style3)
4350 str = (void*)0xdeadbeef;
4351 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4352 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4353 ok(!str, "str != NULL\n");
4355 str = a2bstr("break-word");
4356 hres = IHTMLStyle3_put_wordWrap(style3, str);
4357 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4361 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4362 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4363 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4367 static void test_style4(IHTMLStyle4 *style4)
4373 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4374 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4377 V_BSTR(&v) = a2bstr("10px");
4378 hres = IHTMLStyle4_put_minHeight(style4, v);
4379 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4382 hres = IHTMLStyle4_get_minHeight(style4, &v);
4383 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4384 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4385 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4388 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4389 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4390 VariantClear(&vdefault);
4393 static void test_default_style(IHTMLStyle *style)
4395 IHTMLStyle2 *style2;
4396 IHTMLStyle3 *style3;
4397 IHTMLStyle4 *style4;
4403 BSTR sOverflowDefault;
4407 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4408 test_ifaces((IUnknown*)style, style_iids);
4410 test_style_csstext(style, NULL);
4412 hres = IHTMLStyle_get_position(style, &str);
4413 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4414 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4417 hres = IHTMLStyle_get_marginRight(style, &v);
4418 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4419 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4420 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4423 hres = IHTMLStyle_get_marginLeft(style, &v);
4424 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4425 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4426 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4428 str = (void*)0xdeadbeef;
4429 hres = IHTMLStyle_get_fontFamily(style, &str);
4430 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4431 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4433 str = (void*)0xdeadbeef;
4434 hres = IHTMLStyle_get_fontWeight(style, &str);
4435 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4436 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4438 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4439 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4441 str = a2bstr("test");
4442 hres = IHTMLStyle_put_fontWeight(style, str);
4443 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4446 str = a2bstr("bold");
4447 hres = IHTMLStyle_put_fontWeight(style, str);
4448 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4451 str = a2bstr("bolder");
4452 hres = IHTMLStyle_put_fontWeight(style, str);
4453 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4456 str = a2bstr("lighter");
4457 hres = IHTMLStyle_put_fontWeight(style, str);
4458 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4461 str = a2bstr("100");
4462 hres = IHTMLStyle_put_fontWeight(style, str);
4463 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4466 str = a2bstr("200");
4467 hres = IHTMLStyle_put_fontWeight(style, str);
4468 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4471 str = a2bstr("300");
4472 hres = IHTMLStyle_put_fontWeight(style, str);
4473 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4476 str = a2bstr("400");
4477 hres = IHTMLStyle_put_fontWeight(style, str);
4478 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4481 str = a2bstr("500");
4482 hres = IHTMLStyle_put_fontWeight(style, str);
4483 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4486 str = a2bstr("600");
4487 hres = IHTMLStyle_put_fontWeight(style, str);
4488 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4491 str = a2bstr("700");
4492 hres = IHTMLStyle_put_fontWeight(style, str);
4493 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4496 str = a2bstr("800");
4497 hres = IHTMLStyle_put_fontWeight(style, str);
4498 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4501 str = a2bstr("900");
4502 hres = IHTMLStyle_put_fontWeight(style, str);
4503 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4506 hres = IHTMLStyle_get_fontWeight(style, &str);
4507 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4508 ok(!strcmp_wa(str, "900"), "str != style900\n");
4511 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4512 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4513 SysFreeString(sDefault);
4516 hres = IHTMLStyle_get_fontVariant(style, NULL);
4517 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4519 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4520 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4522 str = a2bstr("test");
4523 hres = IHTMLStyle_put_fontVariant(style, str);
4524 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4527 str = a2bstr("small-caps");
4528 hres = IHTMLStyle_put_fontVariant(style, str);
4529 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4532 str = a2bstr("normal");
4533 hres = IHTMLStyle_put_fontVariant(style, str);
4534 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4537 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4538 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4539 SysFreeString(sDefault);
4541 str = (void*)0xdeadbeef;
4542 hres = IHTMLStyle_get_display(style, &str);
4543 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4544 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4546 str = (void*)0xdeadbeef;
4547 hres = IHTMLStyle_get_visibility(style, &str);
4548 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4549 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4552 hres = IHTMLStyle_get_fontSize(style, &v);
4553 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4554 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4555 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4558 hres = IHTMLStyle_get_color(style, &v);
4559 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4560 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4561 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4564 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4565 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4566 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4568 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4569 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4570 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4572 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4573 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4574 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4576 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4577 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4580 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4581 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4582 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4584 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4585 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4586 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4588 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4589 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4590 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4592 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4593 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4596 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4597 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4598 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4600 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4601 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4602 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4604 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4605 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4606 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4608 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4609 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4612 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4613 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4614 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4616 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4617 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4618 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4620 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4621 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4622 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4624 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4625 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4628 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4629 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4630 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4632 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4633 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4634 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4636 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4637 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4638 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4640 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4641 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4643 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4644 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4646 str = a2bstr("invalid");
4647 hres = IHTMLStyle_put_textDecoration(style, str);
4648 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4651 str = a2bstr("none");
4652 hres = IHTMLStyle_put_textDecoration(style, str);
4653 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4656 str = a2bstr("underline");
4657 hres = IHTMLStyle_put_textDecoration(style, str);
4658 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4661 str = a2bstr("overline");
4662 hres = IHTMLStyle_put_textDecoration(style, str);
4663 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4666 str = a2bstr("line-through");
4667 hres = IHTMLStyle_put_textDecoration(style, str);
4668 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4671 str = a2bstr("blink");
4672 hres = IHTMLStyle_put_textDecoration(style, str);
4673 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4676 hres = IHTMLStyle_get_textDecoration(style, &str);
4677 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4678 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4681 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4682 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4683 SysFreeString(sDefault);
4685 hres = IHTMLStyle_get_posWidth(style, NULL);
4686 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4688 hres = IHTMLStyle_get_posWidth(style, &f);
4689 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4690 ok(f == 0.0f, "f = %f\n", f);
4692 V_VT(&v) = VT_EMPTY;
4693 hres = IHTMLStyle_get_width(style, &v);
4694 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4695 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4696 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4698 hres = IHTMLStyle_put_posWidth(style, 2.2);
4699 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4701 hres = IHTMLStyle_get_posWidth(style, &f);
4702 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4704 f == 2.2f, /* IE8 */
4708 V_BSTR(&v) = a2bstr("auto");
4709 hres = IHTMLStyle_put_width(style, v);
4710 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4713 V_VT(&v) = VT_EMPTY;
4714 hres = IHTMLStyle_get_width(style, &v);
4715 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4716 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4717 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4722 hres = IHTMLStyle_put_width(style, v);
4723 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4725 V_VT(&v) = VT_EMPTY;
4726 hres = IHTMLStyle_get_width(style, &v);
4727 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4728 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4729 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4733 str = (void*)0xdeadbeef;
4734 hres = IHTMLStyle_get_margin(style, &str);
4735 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4736 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4739 hres = IHTMLStyle_put_margin(style, str);
4740 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4743 hres = IHTMLStyle_get_margin(style, &str);
4744 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4745 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4748 hres = IHTMLStyle_put_margin(style, NULL);
4749 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4751 str = (void*)0xdeadbeef;
4752 hres = IHTMLStyle_get_marginTop(style, &v);
4753 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4754 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4755 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4758 V_BSTR(&v) = a2bstr("6px");
4759 hres = IHTMLStyle_put_marginTop(style, v);
4760 SysFreeString(V_BSTR(&v));
4761 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4763 str = (void*)0xdeadbeef;
4764 hres = IHTMLStyle_get_marginTop(style, &v);
4765 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4766 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4767 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4771 hres = IHTMLStyle_get_border(style, &str);
4772 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4773 ok(!str || !*str, "str is not empty\n");
4776 str = a2bstr("1px");
4777 hres = IHTMLStyle_put_border(style, str);
4778 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4781 V_VT(&v) = VT_EMPTY;
4782 hres = IHTMLStyle_get_left(style, &v);
4783 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4784 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4785 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4789 hres = IHTMLStyle_get_posLeft(style, NULL);
4790 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4793 hres = IHTMLStyle_get_posLeft(style, &f);
4794 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4795 ok(f == 0.0, "expected 0.0 got %f\n", f);
4797 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4798 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4800 hres = IHTMLStyle_get_posLeft(style, &f);
4801 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4803 f == 4.9f, /* IE8 */
4804 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4806 /* Ensure left is updated correctly. */
4807 V_VT(&v) = VT_EMPTY;
4808 hres = IHTMLStyle_get_left(style, &v);
4809 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4810 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4811 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4812 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4813 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4818 V_BSTR(&v) = a2bstr("3px");
4819 hres = IHTMLStyle_put_left(style, v);
4820 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4823 hres = IHTMLStyle_get_posLeft(style, &f);
4824 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4825 ok(f == 3.0, "expected 3.0 got %f\n", f);
4827 V_VT(&v) = VT_EMPTY;
4828 hres = IHTMLStyle_get_left(style, &v);
4829 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4830 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4831 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4835 hres = IHTMLStyle_put_left(style, v);
4836 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4838 V_VT(&v) = VT_EMPTY;
4839 hres = IHTMLStyle_get_left(style, &v);
4840 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4841 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4842 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4845 V_VT(&v) = VT_EMPTY;
4846 hres = IHTMLStyle_get_top(style, &v);
4847 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4848 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4849 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4853 hres = IHTMLStyle_get_posTop(style, NULL);
4854 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4857 hres = IHTMLStyle_get_posTop(style, &f);
4858 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4859 ok(f == 0.0, "expected 0.0 got %f\n", f);
4861 hres = IHTMLStyle_put_posTop(style, 4.9f);
4862 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4864 hres = IHTMLStyle_get_posTop(style, &f);
4865 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4867 f == 4.9f, /* IE8 */
4868 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4871 V_BSTR(&v) = a2bstr("3px");
4872 hres = IHTMLStyle_put_top(style, v);
4873 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4876 V_VT(&v) = VT_EMPTY;
4877 hres = IHTMLStyle_get_top(style, &v);
4878 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4879 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4880 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4883 hres = IHTMLStyle_get_posTop(style, &f);
4884 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4885 ok(f == 3.0, "expected 3.0 got %f\n", f);
4888 hres = IHTMLStyle_put_top(style, v);
4889 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4891 V_VT(&v) = VT_EMPTY;
4892 hres = IHTMLStyle_get_top(style, &v);
4893 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4894 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4895 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4898 /* Test posHeight */
4899 hres = IHTMLStyle_get_posHeight(style, NULL);
4900 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4902 V_VT(&v) = VT_EMPTY;
4903 hres = IHTMLStyle_get_height(style, &v);
4904 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4905 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4906 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4910 hres = IHTMLStyle_get_posHeight(style, &f);
4911 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4912 ok(f == 0.0, "expected 0.0 got %f\n", f);
4914 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4915 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4917 hres = IHTMLStyle_get_posHeight(style, &f);
4918 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4920 f == 4.9f, /* IE8 */
4921 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4924 V_BSTR(&v) = a2bstr("64px");
4925 hres = IHTMLStyle_put_height(style, v);
4926 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4929 V_VT(&v) = VT_EMPTY;
4930 hres = IHTMLStyle_get_height(style, &v);
4931 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4932 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4933 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4936 hres = IHTMLStyle_get_posHeight(style, &f);
4937 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4938 ok(f == 64.0, "expected 64.0 got %f\n", f);
4940 str = (void*)0xdeadbeef;
4941 hres = IHTMLStyle_get_cursor(style, &str);
4942 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4943 ok(!str, "get_cursor != NULL\n");
4946 str = a2bstr("default");
4947 hres = IHTMLStyle_put_cursor(style, str);
4948 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4952 hres = IHTMLStyle_get_cursor(style, &str);
4953 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4954 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4957 V_VT(&v) = VT_EMPTY;
4958 hres = IHTMLStyle_get_verticalAlign(style, &v);
4959 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4960 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4961 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4965 V_BSTR(&v) = a2bstr("middle");
4966 hres = IHTMLStyle_put_verticalAlign(style, v);
4967 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4970 V_VT(&v) = VT_EMPTY;
4971 hres = IHTMLStyle_get_verticalAlign(style, &v);
4972 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4973 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4974 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4977 str = (void*)0xdeadbeef;
4978 hres = IHTMLStyle_get_textAlign(style, &str);
4979 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4980 ok(!str, "textAlign != NULL\n");
4982 str = a2bstr("center");
4983 hres = IHTMLStyle_put_textAlign(style, str);
4984 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4988 hres = IHTMLStyle_get_textAlign(style, &str);
4989 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4990 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4993 str = (void*)0xdeadbeef;
4994 hres = IHTMLStyle_get_filter(style, &str);
4995 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4996 ok(!str, "filter != NULL\n");
4998 str = a2bstr("alpha(opacity=100)");
4999 hres = IHTMLStyle_put_filter(style, str);
5000 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
5003 V_VT(&v) = VT_EMPTY;
5004 hres = IHTMLStyle_get_zIndex(style, &v);
5005 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
5006 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
5007 ok(!V_I4(&v), "V_I4(v) != 0\n");
5011 V_BSTR(&v) = a2bstr("1");
5012 hres = IHTMLStyle_put_zIndex(style, v);
5013 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
5016 V_VT(&v) = VT_EMPTY;
5017 hres = IHTMLStyle_get_zIndex(style, &v);
5018 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
5019 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
5020 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
5024 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
5025 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
5027 str = a2bstr("test");
5028 hres = IHTMLStyle_put_fontStyle(style, str);
5029 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
5032 str = a2bstr("italic");
5033 hres = IHTMLStyle_put_fontStyle(style, str);
5034 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
5037 str = a2bstr("oblique");
5038 hres = IHTMLStyle_put_fontStyle(style, str);
5039 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
5042 str = a2bstr("normal");
5043 hres = IHTMLStyle_put_fontStyle(style, str);
5044 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
5047 hres = IHTMLStyle_put_fontStyle(style, sDefault);
5048 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
5049 SysFreeString(sDefault);
5052 hres = IHTMLStyle_get_overflow(style, NULL);
5053 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
5055 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
5056 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
5058 str = a2bstr("test");
5059 hres = IHTMLStyle_put_overflow(style, str);
5060 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
5063 str = a2bstr("visible");
5064 hres = IHTMLStyle_put_overflow(style, str);
5065 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5068 str = a2bstr("scroll");
5069 hres = IHTMLStyle_put_overflow(style, str);
5070 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5073 str = a2bstr("hidden");
5074 hres = IHTMLStyle_put_overflow(style, str);
5075 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5078 str = a2bstr("auto");
5079 hres = IHTMLStyle_put_overflow(style, str);
5080 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5083 hres = IHTMLStyle_get_overflow(style, &str);
5084 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
5085 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
5089 hres = IHTMLStyle_put_overflow(style, str);
5090 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5093 hres = IHTMLStyle_get_overflow(style, &str);
5094 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
5095 ok(!str, "str=%s\n", wine_dbgstr_w(str));
5098 /* restore overflow default */
5099 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
5100 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5101 SysFreeString(sOverflowDefault);
5103 /* Attribute Tests*/
5104 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
5105 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
5107 str = a2bstr("position");
5108 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
5109 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
5111 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
5112 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
5113 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5116 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
5117 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
5120 V_BSTR(&v) = a2bstr("absolute");
5121 hres = IHTMLStyle_setAttribute(style, str, v, 1);
5122 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
5125 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
5126 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
5127 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5128 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5133 hres = IHTMLStyle_setAttribute(style, str, v, 1);
5134 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
5139 str = a2bstr("borderLeftStyle");
5140 test_border_styles(style, str);
5143 str = a2bstr("borderbottomstyle");
5144 test_border_styles(style, str);
5147 str = a2bstr("borderrightstyle");
5148 test_border_styles(style, str);
5151 str = a2bstr("bordertopstyle");
5152 test_border_styles(style, str);
5155 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
5156 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5158 str = a2bstr("none dotted dashed solid");
5159 hres = IHTMLStyle_put_borderStyle(style, str);
5160 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5163 str = a2bstr("none dotted dashed solid");
5164 hres = IHTMLStyle_get_borderStyle(style, &str);
5165 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5166 ok(!strcmp_wa(str, "none dotted dashed solid"),
5167 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
5170 str = a2bstr("double groove ridge inset");
5171 hres = IHTMLStyle_put_borderStyle(style, str);
5172 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5175 str = a2bstr("window-inset outset ridge inset");
5176 hres = IHTMLStyle_put_borderStyle(style, str);
5177 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5180 str = a2bstr("window-inset");
5181 hres = IHTMLStyle_put_borderStyle(style, str);
5182 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5185 str = a2bstr("none none none none none");
5186 hres = IHTMLStyle_put_borderStyle(style, str);
5187 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5190 str = a2bstr("invalid none none none");
5191 hres = IHTMLStyle_put_borderStyle(style, str);
5192 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5195 str = a2bstr("none invalid none none");
5196 hres = IHTMLStyle_put_borderStyle(style, str);
5197 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5200 hres = IHTMLStyle_put_borderStyle(style, sDefault);
5201 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5202 SysFreeString(sDefault);
5204 /* backgoundColor */
5205 hres = IHTMLStyle_get_backgroundColor(style, &v);
5206 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5207 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5208 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5212 hres = IHTMLStyle_get_padding(style, &str);
5213 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5214 ok(!str, "padding = %s\n", wine_dbgstr_w(str));
5218 hres = IHTMLStyle_put_padding(style, str);
5219 ok(hres == S_OK, "put_padding failed: %08x\n", hres);
5222 hres = IHTMLStyle_get_padding(style, &str);
5223 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5224 ok(!strcmp_wa(str, "1px"), "padding = %s\n", wine_dbgstr_w(str));
5228 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
5229 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5232 V_BSTR(&v) = a2bstr("10");
5233 hres = IHTMLStyle_put_paddingLeft(style, v);
5234 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5237 hres = IHTMLStyle_get_paddingLeft(style, &v);
5238 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5239 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5242 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
5243 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5245 /* BackgroundRepeat */
5246 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
5247 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5249 str = a2bstr("invalid");
5250 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5251 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
5254 str = a2bstr("repeat");
5255 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5256 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5259 str = a2bstr("no-repeat");
5260 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5261 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5264 str = a2bstr("repeat-x");
5265 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5266 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5269 str = a2bstr("repeat-y");
5270 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5271 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5274 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
5275 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5276 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
5279 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
5280 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5281 SysFreeString(sDefault);
5284 hres = IHTMLStyle_get_borderColor(style, &sDefault);
5285 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5287 str = a2bstr("red green red blue");
5288 hres = IHTMLStyle_put_borderColor(style, str);
5289 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5292 hres = IHTMLStyle_get_borderColor(style, &str);
5293 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5294 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
5297 hres = IHTMLStyle_put_borderColor(style, sDefault);
5298 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5299 SysFreeString(sDefault);
5302 hres = IHTMLStyle_get_borderRight(style, &sDefault);
5303 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
5305 str = a2bstr("thick dotted red");
5306 hres = IHTMLStyle_put_borderRight(style, str);
5307 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5310 /* IHTMLStyle_get_borderRight appears to have a bug where
5311 it returns the first letter of the color. So we check
5312 each style individually.
5315 hres = IHTMLStyle_get_borderRightColor(style, &v);
5316 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
5317 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5321 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5322 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5323 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5326 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5327 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5328 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5331 hres = IHTMLStyle_put_borderRight(style, sDefault);
5332 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5333 SysFreeString(sDefault);
5336 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5337 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5339 str = a2bstr("thick dotted red");
5340 hres = IHTMLStyle_put_borderTop(style, str);
5341 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5344 /* IHTMLStyle_get_borderTop appears to have a bug where
5345 it returns the first letter of the color. So we check
5346 each style individually.
5349 hres = IHTMLStyle_get_borderTopColor(style, &v);
5350 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5351 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5355 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5356 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5357 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5360 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5361 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5362 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5365 hres = IHTMLStyle_put_borderTop(style, sDefault);
5366 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5367 SysFreeString(sDefault);
5370 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5371 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5373 str = a2bstr("thick dotted red");
5374 hres = IHTMLStyle_put_borderBottom(style, str);
5375 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5378 /* IHTMLStyle_get_borderBottom appears to have a bug where
5379 it returns the first letter of the color. So we check
5380 each style individually.
5383 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5384 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5385 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5389 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5390 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5391 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5394 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5395 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5396 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5399 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5400 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5401 SysFreeString(sDefault);
5404 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5405 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5407 str = a2bstr("thick dotted red");
5408 hres = IHTMLStyle_put_borderLeft(style, str);
5409 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5412 /* IHTMLStyle_get_borderLeft appears to have a bug where
5413 it returns the first letter of the color. So we check
5414 each style individually.
5417 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5418 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5419 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5423 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5424 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5425 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5428 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5429 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5430 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5433 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5434 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5435 SysFreeString(sDefault);
5437 /* backgroundPositionX */
5438 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5439 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5440 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5441 ok(!V_BSTR(&v), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5445 V_BSTR(&v) = a2bstr("10px");
5446 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5447 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5450 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5451 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5452 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5453 ok(!strcmp_wa(V_BSTR(&v), "10px"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5456 /* backgroundPositionY */
5457 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5458 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5459 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5463 V_BSTR(&v) = a2bstr("15px");
5464 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5465 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5468 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5469 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5470 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5471 ok(!strcmp_wa(V_BSTR(&v), "15px"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5474 /* backgroundPosition */
5476 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5477 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5478 ok(!strcmp_wa(str, "10px 15px"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5481 str = a2bstr("center 20%");
5482 hres = IHTMLStyle_put_backgroundPosition(style, str);
5483 ok(hres == S_OK, "put_backgroundPosition failed: %08x\n", hres);
5487 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5488 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5489 ok(!strcmp_wa(str, "center 20%"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5492 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5493 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5494 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5495 ok(!strcmp_wa(V_BSTR(&v), "center"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5498 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5499 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5500 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5501 ok(!strcmp_wa(V_BSTR(&v), "20%"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5504 /* borderTopWidth */
5505 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5506 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5509 V_BSTR(&v) = a2bstr("10px");
5510 hres = IHTMLStyle_put_borderTopWidth(style, v);
5511 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5514 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5515 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5516 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5519 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5520 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5521 VariantClear(&vDefault);
5523 /* borderRightWidth */
5524 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5525 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5528 V_BSTR(&v) = a2bstr("10");
5529 hres = IHTMLStyle_put_borderRightWidth(style, v);
5530 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5533 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5534 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5535 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5538 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5539 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5540 VariantClear(&vDefault);
5542 /* borderBottomWidth */
5543 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5544 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5547 V_BSTR(&v) = a2bstr("10");
5548 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5549 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5552 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5553 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5554 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5557 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5558 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5559 VariantClear(&vDefault);
5561 /* borderLeftWidth */
5562 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5563 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5566 V_BSTR(&v) = a2bstr("10");
5567 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5568 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5571 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5572 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5573 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5576 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5577 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5578 VariantClear(&vDefault);
5581 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5582 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5585 V_BSTR(&v) = a2bstr("10");
5586 hres = IHTMLStyle_put_wordSpacing(style, v);
5587 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5590 hres = IHTMLStyle_get_wordSpacing(style, &v);
5591 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5592 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5593 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5596 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5597 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5598 VariantClear(&vDefault);
5601 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5602 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5605 V_BSTR(&v) = a2bstr("11");
5606 hres = IHTMLStyle_put_letterSpacing(style, v);
5607 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5610 hres = IHTMLStyle_get_letterSpacing(style, &v);
5611 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5612 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5613 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5616 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5617 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5618 VariantClear(&vDefault);
5620 /* borderTopColor */
5621 hres = IHTMLStyle_get_borderTopColor(style, &vDefault);
5622 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5625 V_BSTR(&v) = a2bstr("red");
5626 hres = IHTMLStyle_put_borderTopColor(style, v);
5627 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5630 hres = IHTMLStyle_get_borderTopColor(style, &v);
5631 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5632 ok(!strcmp_wa(V_BSTR(&v), "red"), "expecte red = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5635 hres = IHTMLStyle_put_borderTopColor(style, vDefault);
5636 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5638 /* borderRightColor */
5639 hres = IHTMLStyle_get_borderRightColor(style, &vDefault);
5640 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5643 V_BSTR(&v) = a2bstr("blue");
5644 hres = IHTMLStyle_put_borderRightColor(style, v);
5645 ok(hres == S_OK, "put_borderRightColor: %08x\n", hres);
5648 hres = IHTMLStyle_get_borderRightColor(style, &v);
5649 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5650 ok(!strcmp_wa(V_BSTR(&v), "blue"), "expected blue = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5653 hres = IHTMLStyle_put_borderRightColor(style, vDefault);
5654 ok(hres == S_OK, "putborderRightColorr: %08x\n", hres);
5656 /* borderBottomColor */
5657 hres = IHTMLStyle_get_borderBottomColor(style, &vDefault);
5658 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5661 V_BSTR(&v) = a2bstr("cyan");
5662 hres = IHTMLStyle_put_borderBottomColor(style, v);
5663 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5666 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5667 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5668 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5671 hres = IHTMLStyle_put_borderBottomColor(style, vDefault);
5672 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5674 /* borderLeftColor */
5675 hres = IHTMLStyle_get_borderLeftColor(style, &vDefault);
5676 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5679 V_BSTR(&v) = a2bstr("cyan");
5680 hres = IHTMLStyle_put_borderLeftColor(style, v);
5681 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5684 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5685 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5686 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5689 hres = IHTMLStyle_put_borderLeftColor(style, vDefault);
5690 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5692 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5693 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5694 if(SUCCEEDED(hres)) {
5695 test_style2(style2);
5696 IHTMLStyle2_Release(style2);
5699 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5700 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5701 if(SUCCEEDED(hres)) {
5702 test_style3(style3);
5703 IHTMLStyle3_Release(style3);
5706 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5707 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5708 if(SUCCEEDED(hres)) {
5709 test_style4(style4);
5710 IHTMLStyle4_Release(style4);
5714 #define test_style_filter(a,b) _test_style_filter(__LINE__,a,b)
5715 static void _test_style_filter(unsigned line, IHTMLStyle *style, const char *exval)
5720 str = (void*)0xdeadbeef;
5721 hres = IHTMLStyle_get_filter(style, &str);
5722 ok_(__FILE__,line)(hres == S_OK, "get_filter failed: %08x\n", hres);
5724 ok_(__FILE__,line)(str && !strcmp_wa(str, exval), "filter = %s, expected %s\n", wine_dbgstr_w(str), exval);
5726 ok_(__FILE__,line)(!str, "str = %s, expected NULL\n", wine_dbgstr_w(str));
5731 #define set_style_filter(a,b) _set_style_filter(__LINE__,a,b)
5732 static void _set_style_filter(unsigned line, IHTMLStyle *style, const char *val)
5734 BSTR str = a2bstr(val);
5737 hres = IHTMLStyle_put_filter(style, str);
5738 ok_(__FILE__,line)(hres == S_OK, "put_filter failed: %08x\n", hres);
5741 _test_style_filter(line, style, val);
5744 static void test_style_filters(IHTMLElement *elem)
5749 hres = IHTMLElement_get_style(elem, &style);
5750 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5752 test_style_filter(style, NULL);
5753 set_style_filter(style, "alpha(opacity=50.0040)");
5754 set_style_filter(style, "alpha(opacity=100)");
5756 IHTMLStyle_Release(style);
5758 hres = IHTMLElement_get_style(elem, &style);
5759 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5761 test_style_filter(style, "alpha(opacity=100)");
5762 set_style_filter(style, "xxx(a,b,c) alpha(opacity=100)");
5763 set_style_filter(style, NULL);
5765 IHTMLStyle_Release(style);
5768 static void test_set_csstext(IHTMLStyle *style)
5773 test_style_set_csstext(style, "background-color: black;");
5775 hres = IHTMLStyle_get_backgroundColor(style, &v);
5776 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5777 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5778 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5782 static void test_default_selection(IHTMLDocument2 *doc)
5784 IHTMLSelectionObject *selection;
5785 IHTMLTxtRange *range;
5790 hres = IHTMLDocument2_get_selection(doc, &selection);
5791 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5793 hres = IHTMLSelectionObject_get_type(selection, &str);
5794 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5795 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5798 hres = IHTMLSelectionObject_createRange(selection, &disp);
5799 IHTMLSelectionObject_Release(selection);
5800 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5802 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5803 IDispatch_Release(disp);
5804 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5806 test_range_text(range, NULL);
5807 IHTMLTxtRange_Release(range);
5810 static void test_doc_elem(IHTMLDocument2 *doc)
5812 IHTMLDocument2 *doc_node, *owner_doc;
5814 IHTMLDocument3 *doc3;
5817 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5818 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5820 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5821 IHTMLDocument3_Release(doc3);
5822 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5824 test_node_name((IUnknown*)elem, "HTML");
5825 test_elem_tag((IUnknown*)elem, "HTML");
5827 doc_node = get_doc_node(doc);
5828 owner_doc = get_owner_doc((IUnknown*)elem);
5829 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5830 IHTMLDocument2_Release(owner_doc);
5832 owner_doc = get_owner_doc((IUnknown*)doc_node);
5833 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5834 IHTMLDocument2_Release(doc_node);
5836 test_elem_client_rect((IUnknown*)elem);
5838 IHTMLElement_Release(elem);
5841 static void test_default_body(IHTMLBodyElement *body)
5848 bstr = (void*)0xdeadbeef;
5849 hres = IHTMLBodyElement_get_background(body, &bstr);
5850 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5851 ok(bstr == NULL, "bstr != NULL\n");
5853 l = elem_get_scroll_height((IUnknown*)body);
5854 ok(l != -1, "scrollHeight == -1\n");
5855 l = elem_get_scroll_width((IUnknown*)body);
5856 ok(l != -1, "scrollWidth == -1\n");
5857 l = elem_get_scroll_top((IUnknown*)body);
5858 ok(!l, "scrollTop = %d\n", l);
5859 elem_get_scroll_left((IUnknown*)body);
5861 /* get_text tests */
5862 hres = IHTMLBodyElement_get_text(body, &v);
5863 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5864 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5865 ok(bstr == NULL, "bstr != NULL\n");
5867 /* get_text - Invalid Text */
5869 V_BSTR(&v) = a2bstr("Invalid");
5870 hres = IHTMLBodyElement_put_text(body, v);
5871 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5875 hres = IHTMLBodyElement_get_text(body, &v);
5876 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5877 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5878 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5881 /* get_text - Valid Text */
5883 V_BSTR(&v) = a2bstr("#FF0000");
5884 hres = IHTMLBodyElement_put_text(body, v);
5885 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5889 hres = IHTMLBodyElement_get_text(body, &v);
5890 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5891 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5892 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5896 static void test_body_funs(IHTMLBodyElement *body)
5898 VARIANT vbg, vDefaultbg;
5901 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5902 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5903 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5904 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5906 V_VT(&vbg) = VT_BSTR;
5907 V_BSTR(&vbg) = a2bstr("red");
5908 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5909 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5912 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5913 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5914 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5915 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5918 /* Restore Originial */
5919 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5920 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5921 VariantClear(&vDefaultbg);
5924 static void test_window(IHTMLDocument2 *doc)
5926 IHTMLWindow2 *window, *window2, *self;
5927 IHTMLDocument2 *doc2 = NULL;
5933 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5934 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5935 test_ifaces((IUnknown*)window, window_iids);
5936 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5938 hres = IHTMLWindow2_get_document(window, &doc2);
5939 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5940 ok(doc2 != NULL, "doc2 == NULL\n");
5942 test_ifaces((IUnknown*)doc2, doc_node_iids);
5943 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5945 test_ifaces((IUnknown*)doc, doc_obj_iids);
5946 test_disp((IUnknown*)doc, &DIID_DispHTMLDocument, "[object]");
5948 unk = (void*)0xdeadbeef;
5949 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5950 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5951 ok(!unk, "unk = %p\n", unk);
5953 IHTMLDocument_Release(doc2);
5955 hres = IHTMLWindow2_get_window(window, &window2);
5956 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5957 ok(window2 != NULL, "window2 == NULL\n");
5959 hres = IHTMLWindow2_get_self(window, &self);
5960 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5961 ok(window2 != NULL, "self == NULL\n");
5963 ok(self == window2, "self != window2\n");
5965 IHTMLWindow2_Release(window2);
5966 IHTMLWindow2_Release(self);
5969 hres = IHTMLDocument2_get_Script(doc, &disp);
5970 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5971 ok(disp == (void*)window, "disp != window\n");
5972 IDispatch_Release(disp);
5974 hres = IHTMLWindow2_toString(window, NULL);
5975 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5978 hres = IHTMLWindow2_toString(window, &str);
5979 ok(hres == S_OK, "toString failed: %08x\n", hres);
5980 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5983 test_window_name(window, NULL);
5984 set_window_name(window, "test");
5985 test_window_length(window, 0);
5986 test_screen(window);
5988 IHTMLWindow2_Release(window);
5991 static void test_defaults(IHTMLDocument2 *doc)
5993 IHTMLStyleSheetsCollection *stylesheetcol;
5994 IHTMLCurrentStyle *cstyle;
5995 IHTMLBodyElement *body;
5996 IHTMLElement2 *elem2;
6001 IHTMLElementCollection *collection;
6003 elem = doc_get_body(doc);
6005 hres = IHTMLDocument2_get_images(doc, NULL);
6006 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
6008 hres = IHTMLDocument2_get_images(doc, &collection);
6009 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6012 test_elem_collection((IUnknown*)collection, NULL, 0);
6013 IHTMLElementCollection_Release(collection);
6016 hres = IHTMLDocument2_get_applets(doc, NULL);
6017 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
6019 hres = IHTMLDocument2_get_applets(doc, &collection);
6020 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
6023 test_elem_collection((IUnknown*)collection, NULL, 0);
6024 IHTMLElementCollection_Release(collection);
6027 hres = IHTMLDocument2_get_links(doc, NULL);
6028 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
6030 hres = IHTMLDocument2_get_links(doc, &collection);
6031 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6034 test_elem_collection((IUnknown*)collection, NULL, 0);
6035 IHTMLElementCollection_Release(collection);
6038 hres = IHTMLDocument2_get_forms(doc, NULL);
6039 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
6041 hres = IHTMLDocument2_get_forms(doc, &collection);
6042 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
6045 test_elem_collection((IUnknown*)collection, NULL, 0);
6046 IHTMLElementCollection_Release(collection);
6049 hres = IHTMLDocument2_get_anchors(doc, NULL);
6050 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
6052 hres = IHTMLDocument2_get_anchors(doc, &collection);
6053 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6056 test_elem_collection((IUnknown*)collection, NULL, 0);
6057 IHTMLElementCollection_Release(collection);
6060 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
6061 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
6062 test_default_body(body);
6063 test_body_funs(body);
6064 IHTMLBodyElement_Release(body);
6066 hres = IHTMLElement_get_style(elem, &style);
6067 ok(hres == S_OK, "get_style failed: %08x\n", hres);
6069 test_default_style(style);
6071 test_compatmode(doc);
6073 test_navigator(doc);
6075 elem2 = get_elem2_iface((IUnknown*)elem);
6076 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
6077 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
6078 if(SUCCEEDED(hres)) {
6079 test_current_style(cstyle);
6080 IHTMLCurrentStyle_Release(cstyle);
6082 IHTMLElement2_Release(elem2);
6084 IHTMLElement_Release(elem);
6086 test_set_csstext(style);
6087 IHTMLStyle_Release(style);
6089 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
6090 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
6093 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
6094 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6095 ok(l == 0, "length = %d\n", l);
6097 IHTMLStyleSheetsCollection_Release(stylesheetcol);
6099 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
6100 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
6102 test_default_selection(doc);
6103 test_doc_title(doc, "");
6106 static void test_tr_elem(IHTMLElement *elem)
6108 IHTMLElementCollection *col;
6112 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
6114 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
6115 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
6120 hres = IHTMLTableRow_get_cells(row, &col);
6121 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
6122 ok(col != NULL, "get_cells returned NULL\n");
6124 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
6125 IHTMLElementCollection_Release(col);
6127 IHTMLTable_Release(row);
6130 static void test_table_elem(IHTMLElement *elem)
6132 IHTMLElementCollection *col;
6137 static const elem_type_t row_types[] = {ET_TR,ET_TR};
6138 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
6140 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
6141 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
6146 hres = IHTMLTable_get_rows(table, &col);
6147 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
6148 ok(col != NULL, "get_ros returned NULL\n");
6150 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
6151 IHTMLElementCollection_Release(col);
6153 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
6155 node = clone_node((IUnknown*)table, VARIANT_TRUE);
6156 test_elem_tag((IUnknown*)node, "TABLE");
6157 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
6158 IHTMLDOMNode_Release(node);
6160 node = clone_node((IUnknown*)table, VARIANT_FALSE);
6161 test_elem_tag((IUnknown*)node, "TABLE");
6162 test_elem_all((IUnknown*)node, NULL, 0);
6163 IHTMLDOMNode_Release(node);
6165 IHTMLTable_Release(table);
6168 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
6177 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
6178 SafeArrayAccessData(sa, (void**)&var);
6179 V_VT(var) = VT_BSTR;
6180 V_BSTR(var) = a2bstr(text);
6181 SafeArrayUnaccessData(sa);
6184 hres = IHTMLDocument2_writeln(doc, sa);
6186 hres = IHTMLDocument2_write(doc, sa);
6187 ok(hres == S_OK, "write failed: %08x\n", hres);
6189 SafeArrayDestroy(sa);
6192 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
6194 IHTMLDocument2 *window_doc, *elem_doc;
6195 IHTMLFrameElement3 *frame_elem3;
6196 IHTMLWindow2 *content_window;
6199 content_window = get_frame_content_window(frame_elem);
6200 window_doc = get_window_doc(content_window);
6201 IHTMLWindow2_Release(content_window);
6203 elem_doc = get_elem_doc(frame_elem);
6204 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
6207 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
6208 if(SUCCEEDED(hres)) {
6209 IDispatch *disp = NULL;
6211 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
6212 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
6213 ok(disp != NULL, "contentDocument == NULL\n");
6214 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
6216 IDispatch_Release(disp);
6217 IHTMLFrameElement3_Release(frame_elem3);
6219 win_skip("IHTMLFrameElement3 not supported\n");
6223 IHTMLDocument2_Release(elem_doc);
6224 IHTMLDocument2_Release(window_doc);
6227 static void test_iframe_elem(IHTMLElement *elem)
6229 IHTMLDocument2 *content_doc, *owner_doc;
6230 IHTMLElementCollection *col;
6231 IHTMLWindow2 *content_window;
6237 static const elem_type_t all_types[] = {
6245 test_frame_doc((IUnknown*)elem, TRUE);
6247 content_window = get_frame_content_window((IUnknown*)elem);
6248 test_window_length(content_window, 0);
6250 content_doc = get_window_doc(content_window);
6251 IHTMLWindow2_Release(content_window);
6253 str = a2bstr("text/html");
6254 V_VT(&errv) = VT_ERROR;
6256 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
6258 ok(hres == S_OK, "open failed: %08x\n", hres);
6259 ok(disp != NULL, "disp == NULL\n");
6260 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
6261 IDispatch_Release(disp);
6263 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
6264 doc_write(content_doc, TRUE, "</html>");
6266 hres = IHTMLDocument2_get_all(content_doc, &col);
6267 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6268 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6269 IHTMLElementCollection_Release(col);
6271 hres = IHTMLDocument2_close(content_doc);
6272 ok(hres == S_OK, "close failed: %08x\n", hres);
6274 owner_doc = get_owner_doc((IUnknown*)content_doc);
6275 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
6277 IHTMLDocument2_Release(content_doc);
6280 static void test_stylesheet(IDispatch *disp)
6282 IHTMLStyleSheetRulesCollection *col = NULL;
6283 IHTMLStyleSheet *stylesheet;
6286 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
6287 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
6289 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
6290 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
6291 ok(col != NULL, "col == NULL\n");
6293 IHTMLStyleSheetRulesCollection_Release(col);
6294 IHTMLStyleSheet_Release(stylesheet);
6297 static void test_stylesheets(IHTMLDocument2 *doc)
6299 IHTMLStyleSheetsCollection *col = NULL;
6304 hres = IHTMLDocument2_get_styleSheets(doc, &col);
6305 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
6306 ok(col != NULL, "col == NULL\n");
6308 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
6310 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
6311 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6312 ok(len == 1, "len=%d\n", len);
6318 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6319 ok(hres == S_OK, "item failed: %08x\n", hres);
6320 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
6321 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6322 test_stylesheet(V_DISPATCH(&res));
6329 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6330 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6331 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
6332 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6335 IHTMLStyleSheetsCollection_Release(col);
6338 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
6340 IDispatchEx *dispex;
6342 DISPPARAMS dp = {NULL, NULL, 0, 0};
6350 static const WCHAR w0[] = {'0',0};
6351 static const WCHAR w100[] = {'1','0','0',0};
6353 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
6354 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
6356 bstr = SysAllocString(w0);
6357 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6358 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6359 SysFreeString(bstr);
6362 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
6363 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
6364 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
6365 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
6366 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
6367 type = get_node_type((IUnknown*)node);
6368 ok(type == 3, "type=%d\n", type);
6369 IHTMLDOMNode_Release(node);
6372 bstr = SysAllocString(w100);
6373 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6374 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
6375 SysFreeString(bstr);
6377 IDispatchEx_Release(dispex);
6382 static void test_elems(IHTMLDocument2 *doc)
6384 IHTMLElementCollection *col;
6385 IHTMLDOMChildrenCollection *child_col;
6386 IHTMLElement *elem, *elem2, *elem3;
6387 IHTMLDOMNode *node, *node2;
6388 IHTMLWindow2 *window;
6392 IHTMLElementCollection *collection;
6393 IHTMLDocument3 *doc3;
6396 static const elem_type_t all_types[] = {
6424 static const elem_type_t item_types[] = {
6430 hres = IHTMLDocument2_get_all(doc, &col);
6431 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6432 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6433 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
6434 IHTMLElementCollection_Release(col);
6436 hres = IHTMLDocument2_get_images(doc, &collection);
6437 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6440 static const elem_type_t images_types[] = {ET_IMG};
6441 test_elem_collection((IUnknown*)collection, images_types, 1);
6443 IHTMLElementCollection_Release(collection);
6446 hres = IHTMLDocument2_get_links(doc, &collection);
6447 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6450 static const elem_type_t images_types[] = {ET_A};
6451 test_elem_collection((IUnknown*)collection, images_types, 1);
6453 IHTMLElementCollection_Release(collection);
6456 hres = IHTMLDocument2_get_anchors(doc, &collection);
6457 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6460 static const elem_type_t anchor_types[] = {ET_A};
6461 test_elem_collection((IUnknown*)collection, anchor_types, 1);
6463 IHTMLElementCollection_Release(collection);
6466 elem = get_doc_elem(doc);
6467 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
6468 IHTMLElement_Release(elem);
6470 get_elem_by_id(doc, "xxx", FALSE);
6471 elem = get_doc_elem_by_id(doc, "xxx");
6472 ok(!elem, "elem != NULL\n");
6474 elem = get_doc_elem_by_id(doc, "s");
6475 ok(elem != NULL, "elem == NULL\n");
6477 test_elem_type((IUnknown*)elem, ET_SELECT);
6478 test_elem_attr(elem, "xxx", NULL);
6479 test_elem_attr(elem, "id", "s");
6480 test_elem_class((IUnknown*)elem, NULL);
6481 test_elem_set_class((IUnknown*)elem, "cl");
6482 test_elem_set_class((IUnknown*)elem, NULL);
6483 test_elem_tabindex((IUnknown*)elem, 0);
6484 test_elem_set_tabindex((IUnknown*)elem, 1);
6485 test_elem_filters((IUnknown*)elem);
6487 node = test_node_get_parent((IUnknown*)elem);
6488 ok(node != NULL, "node == NULL\n");
6489 test_node_name((IUnknown*)node, "BODY");
6490 node2 = test_node_get_parent((IUnknown*)node);
6491 IHTMLDOMNode_Release(node);
6492 ok(node2 != NULL, "node == NULL\n");
6493 test_node_name((IUnknown*)node2, "HTML");
6494 node = test_node_get_parent((IUnknown*)node2);
6495 IHTMLDOMNode_Release(node2);
6496 ok(node != NULL, "node == NULL\n");
6499 test_node_name((IUnknown*)node, "#document");
6500 type = get_node_type((IUnknown*)node);
6501 ok(type == 9, "type=%d, expected 9\n", type);
6502 node2 = test_node_get_parent((IUnknown*)node);
6503 IHTMLDOMNode_Release(node);
6504 ok(node2 == NULL, "node != NULL\n");
6507 elem2 = test_elem_get_parent((IUnknown*)elem);
6508 ok(elem2 != NULL, "elem2 == NULL\n");
6509 test_node_name((IUnknown*)elem2, "BODY");
6510 elem3 = test_elem_get_parent((IUnknown*)elem2);
6511 IHTMLElement_Release(elem2);
6512 ok(elem3 != NULL, "elem3 == NULL\n");
6513 test_node_name((IUnknown*)elem3, "HTML");
6514 elem2 = test_elem_get_parent((IUnknown*)elem3);
6515 IHTMLElement_Release(elem3);
6516 ok(elem2 == NULL, "elem2 != NULL\n");
6518 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6519 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6520 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6522 test_elem_innertext(elem, "opt1opt2");
6524 IHTMLElement_Release(elem);
6527 elem = get_elem_by_id(doc, "s", TRUE);
6529 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6530 IHTMLDocument2 *doc_node, *elem_doc;
6532 test_select_elem(select);
6534 test_elem_title((IUnknown*)select, NULL);
6535 test_elem_set_title((IUnknown*)select, "Title");
6536 test_elem_title((IUnknown*)select, "Title");
6537 test_elem_offset((IUnknown*)select, "BODY");
6538 test_elem_bounding_client_rect((IUnknown*)select);
6540 node = get_first_child((IUnknown*)select);
6541 ok(node != NULL, "node == NULL\n");
6543 test_elem_type((IUnknown*)node, ET_OPTION);
6544 IHTMLDOMNode_Release(node);
6547 type = get_node_type((IUnknown*)select);
6548 ok(type == 1, "type=%d\n", type);
6550 IHTMLSelectElement_Release(select);
6552 elem_doc = get_elem_doc((IUnknown*)elem);
6554 doc_node = get_doc_node(doc);
6555 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6556 IHTMLDocument2_Release(doc_node);
6557 IHTMLDocument2_Release(elem_doc);
6559 IHTMLElement_Release(elem);
6562 elem = get_elem_by_id(doc, "sc", TRUE);
6564 IHTMLScriptElement *script;
6567 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6568 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6574 hres = IHTMLScriptElement_put_type (script, NULL);
6575 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6576 hres = IHTMLScriptElement_get_type(script, &type);
6577 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6578 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6580 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6581 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6582 hres = IHTMLScriptElement_get_type(script, &type);
6583 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6584 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6586 SysFreeString(type);
6589 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6590 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6592 hres = IHTMLScriptElement_get_defer(script, &vb);
6593 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6594 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6596 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6597 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6599 str = (BSTR)0xdeadbeef;
6600 hres = IHTMLScriptElement_get_src(script, &str);
6601 ok(hres == S_OK, "get_src failed: %08x\n", hres);
6602 ok(!str, "src = %s\n", wine_dbgstr_w(str));
6605 IHTMLScriptElement_Release(script);
6608 elem = get_elem_by_id(doc, "in", TRUE);
6610 IHTMLInputElement *input;
6612 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6613 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6615 test_elem_id((IUnknown*)elem, "in");
6616 test_elem_put_id((IUnknown*)elem, "newin");
6617 test_input_get_disabled(input, VARIANT_FALSE);
6618 test_input_set_disabled(input, VARIANT_TRUE);
6619 test_input_set_disabled(input, VARIANT_FALSE);
6620 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6621 test_input_get_disabled(input, VARIANT_TRUE);
6622 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6623 test_input_get_disabled(input, VARIANT_FALSE);
6624 test_elem_client_size((IUnknown*)elem);
6625 test_input_type(input, "text");
6627 test_node_get_value_str((IUnknown*)elem, NULL);
6628 test_node_put_value_str((IUnknown*)elem, "test");
6629 test_node_get_value_str((IUnknown*)elem, NULL);
6630 test_input_value((IUnknown*)elem, NULL);
6631 test_input_put_value((IUnknown*)elem, "test");
6632 test_elem_class((IUnknown*)elem, "testclass");
6633 test_elem_tabindex((IUnknown*)elem, 2);
6634 test_elem_set_tabindex((IUnknown*)elem, 3);
6635 test_elem_title((IUnknown*)elem, "test title");
6637 test_input_get_defaultchecked(input, VARIANT_FALSE);
6638 test_input_set_defaultchecked(input, VARIANT_TRUE);
6639 test_input_set_defaultchecked(input, VARIANT_FALSE);
6641 test_input_get_checked(input, VARIANT_FALSE);
6642 test_input_set_checked(input, VARIANT_TRUE);
6643 test_input_set_checked(input, VARIANT_FALSE);
6645 test_input_name(input, NULL);
6646 test_input_set_name(input, "test");
6648 test_input_src(input, NULL);
6649 test_input_set_src(input, "about:blank");
6651 IHTMLInputElement_Release(input);
6652 IHTMLElement_Release(elem);
6655 elem = get_elem_by_id(doc, "imgid", TRUE);
6657 test_img_src((IUnknown*)elem, "", NULL);
6658 test_img_set_src((IUnknown*)elem, "about:blank");
6659 test_img_src((IUnknown*)elem, "about:blank", NULL);
6660 test_img_alt((IUnknown*)elem, NULL);
6661 test_img_set_alt((IUnknown*)elem, "alt test");
6662 test_img_name((IUnknown*)elem, "WineImg");
6663 IHTMLElement_Release(elem);
6666 elem = get_elem_by_id(doc, "styleid", TRUE);
6668 test_style_media((IUnknown*)elem, NULL);
6669 test_style_put_media((IUnknown*)elem, "screen");
6670 test_style_type((IUnknown*)elem, NULL);
6671 test_style_put_type((IUnknown*)elem, "text/css");
6672 IHTMLElement_Release(elem);
6675 elem = get_doc_elem_by_id(doc, "tbl");
6676 ok(elem != NULL, "elem == NULL\n");
6678 test_table_elem(elem);
6679 IHTMLElement_Release(elem);
6682 elem = get_doc_elem_by_id(doc, "row2");
6683 ok(elem != NULL, "elem == NULL\n");
6686 IHTMLElement_Release(elem);
6689 elem = get_doc_elem_by_id(doc, "ifr");
6690 ok(elem != NULL, "elem == NULL\n");
6692 test_iframe_elem(elem);
6693 IHTMLElement_Release(elem);
6696 elem = get_doc_elem_by_id(doc, "objid");
6697 ok(elem != NULL, "elem == NULL\n");
6699 test_object_vspace((IUnknown*)elem, 100);
6700 IHTMLElement_Release(elem);
6703 elem = get_elem_by_id(doc, "a", TRUE);
6705 test_anchor_href((IUnknown*)elem, "http://test/");
6707 /* Change the href */
6708 test_anchor_put_href((IUnknown*)elem, "http://test1/");
6709 test_anchor_href((IUnknown*)elem, "http://test1/");
6711 /* Restore the href */
6712 test_anchor_put_href((IUnknown*)elem, "http://test/");
6713 test_anchor_href((IUnknown*)elem, "http://test/");
6716 test_anchor_get_target((IUnknown*)elem, NULL);
6718 /* Change the target */
6719 test_anchor_put_target((IUnknown*)elem, "wine");
6720 test_anchor_get_target((IUnknown*)elem, "wine");
6722 /* Restore the target */
6723 test_anchor_put_target((IUnknown*)elem, NULL);
6724 test_anchor_get_target((IUnknown*)elem, NULL);
6726 IHTMLElement_Release(elem);
6729 elem = doc_get_body(doc);
6731 node = get_first_child((IUnknown*)elem);
6732 ok(node != NULL, "node == NULL\n");
6734 test_ifaces((IUnknown*)node, text_iids);
6735 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6737 node2 = get_first_child((IUnknown*)node);
6738 ok(!node2, "node2 != NULL\n");
6740 type = get_node_type((IUnknown*)node);
6741 ok(type == 3, "type=%d\n", type);
6743 test_node_get_value_str((IUnknown*)node, "text test");
6744 test_node_put_value_str((IUnknown*)elem, "test text");
6745 test_node_get_value_str((IUnknown*)node, "text test");
6747 IHTMLDOMNode_Release(node);
6750 child_col = get_child_nodes((IUnknown*)elem);
6751 ok(child_col != NULL, "child_coll == NULL\n");
6755 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6757 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6758 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6759 ok(length, "length=0\n");
6762 node = get_child_item(child_col, 0);
6763 ok(node != NULL, "node == NULL\n");
6767 type = get_node_type((IUnknown*)node);
6768 ok(type == 3, "type=%d\n", type);
6769 node2 = node_get_next((IUnknown*)node);
6771 prev = node_get_prev((IUnknown*)node2);
6772 ok(iface_cmp((IUnknown*)node, (IUnknown*)prev), "node != prev\n");
6773 IHTMLDOMNode_Release(prev);
6775 IHTMLDOMNode_Release(node);
6778 node = get_child_item(child_col, 1);
6779 ok(node != NULL, "node == NULL\n");
6781 type = get_node_type((IUnknown*)node);
6782 ok(type == 8, "type=%d\n", type);
6784 test_elem_id((IUnknown*)node, NULL);
6785 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6786 IHTMLDOMNode_Release(node2);
6787 IHTMLDOMNode_Release(node);
6790 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6791 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6793 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6794 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6796 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6797 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6799 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6800 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6802 test_child_col_disp(child_col);
6804 IHTMLDOMChildrenCollection_Release(child_col);
6807 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6808 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6809 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6811 IHTMLElement_Release(elem);
6813 elem = get_doc_elem_by_id(doc, "frm");
6814 ok(elem != NULL, "elem == NULL\n");
6816 test_form_length((IUnknown*)elem, 0);
6817 test_form_elements((IUnknown*)elem);
6818 IHTMLElement_Release(elem);
6821 test_stylesheets(doc);
6822 test_create_option_elem(doc);
6823 test_create_img_elem(doc);
6825 elem = get_doc_elem_by_id(doc, "tbl");
6826 ok(elem != NULL, "elem = NULL\n");
6827 test_elem_set_innertext(elem, "inner text");
6828 IHTMLElement_Release(elem);
6830 test_doc_title(doc, "test");
6831 test_doc_set_title(doc, "test title");
6832 test_doc_title(doc, "test title");
6835 hres = IHTMLDocument2_get_Script(doc, &disp);
6836 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6839 IDispatchEx *dispex;
6840 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6841 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6845 BSTR str = a2bstr("Testing");
6846 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6847 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6848 ok(pid != -1, "pid == -1\n");
6850 IDispatchEx_Release(dispex);
6853 IDispatch_Release(disp);
6855 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6856 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6858 str = a2bstr("img");
6859 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6860 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6864 static const elem_type_t img_types[] = { ET_IMG };
6866 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6867 IHTMLElementCollection_Release(col);
6870 elem = get_doc_elem_by_id(doc, "y");
6871 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6872 test_elem_innerhtml((IUnknown*)elem, "inner html");
6873 test_elem_set_innerhtml((IUnknown*)elem, "");
6874 test_elem_innerhtml((IUnknown*)elem, NULL);
6875 node = node_get_next((IUnknown*)elem);
6876 ok(!node, "node = %p\n", node);
6878 elem2 = get_doc_elem_by_id(doc, "x");
6879 test_elem_tag((IUnknown*)elem2, "A");
6880 node = node_get_next((IUnknown*)elem2);
6881 IHTMLDOMNode_Release(node);
6882 IHTMLElement_Release(elem2);
6883 IHTMLElement_Release(elem);
6885 IHTMLDocument3_Release(doc3);
6887 elem = get_elem_by_id(doc, "s", TRUE);
6889 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6891 test_select_put_length((IUnknown*)elem, 3);
6892 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6893 test_select_put_length((IUnknown*)elem, 1);
6894 test_elem_all((IUnknown*)elem, select_types, 1);
6895 IHTMLElement_Release(elem);
6898 window = get_doc_window(doc);
6899 test_window_name(window, NULL);
6900 set_window_name(window, "test name");
6901 test_window_length(window, 1);
6902 IHTMLWindow2_Release(window);
6905 static void test_attr(IHTMLElement *elem)
6907 IHTMLDOMAttribute *attr, *attr2;
6910 get_elem_attr_node((IUnknown*)elem, "noattr", FALSE);
6912 attr = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6914 test_disp((IUnknown*)attr, &DIID_DispHTMLDOMAttribute, "[object]");
6915 test_ifaces((IUnknown*)attr, attr_iids);
6916 test_no_iface((IUnknown*)attr, &IID_IHTMLDOMNode);
6918 attr2 = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6919 ok(iface_cmp((IUnknown*)attr, (IUnknown*)attr2), "attr != attr2\n");
6920 IHTMLDOMAttribute_Release(attr2);
6922 get_attr_node_value(attr, &v, VT_BSTR);
6923 ok(!strcmp_wa(V_BSTR(&v), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
6926 IHTMLDOMAttribute_Release(attr);
6928 attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
6929 get_attr_node_value(attr, &v, VT_BSTR);
6930 ok(!V_BSTR(&v), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
6932 IHTMLDOMAttribute_Release(attr);
6936 set_dispex_value((IUnknown*)elem, "dispprop", &v);
6937 attr = get_elem_attr_node((IUnknown*)elem, "dispprop", TRUE);
6938 get_attr_node_value(attr, &v, VT_I4);
6939 ok(V_I4(&v) == 100, "V_I4(v) = %d\n", V_I4(&v));
6940 IHTMLDOMAttribute_Release(attr);
6943 static void test_blocked(IHTMLDocument2 *doc, IHTMLElement *outer_elem)
6947 test_elem_set_innerhtml((IUnknown*)outer_elem,
6948 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
6949 elem = get_elem_by_id(doc, "imgid", TRUE);
6951 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
6952 IHTMLElement_Release(elem);
6955 test_elem_set_innerhtml((IUnknown*)outer_elem,
6956 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
6957 elem = get_elem_by_id(doc, "imgid", TRUE);
6959 test_img_src((IUnknown*)elem, "blocke::http://www.winehq.org/img.png", NULL);
6960 test_img_set_src((IUnknown*)elem, "BLOCKED:http://www.winehq.org/img.png");
6961 test_img_src((IUnknown*)elem, "blocked:http://www.winehq.org/img.png", NULL);
6962 test_img_set_src((IUnknown*)elem, "blocked::http://www.winehq.org/img.png");
6963 test_img_src((IUnknown*)elem, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
6964 IHTMLElement_Release(elem);
6968 static void test_elems2(IHTMLDocument2 *doc)
6970 IHTMLElement *elem, *elem2, *div;
6972 static const elem_type_t outer_types[] = {
6977 div = get_doc_elem_by_id(doc, "divid");
6979 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6980 elem2 = get_doc_elem_by_id(doc, "innerid");
6981 ok(elem2 != NULL, "elem2 == NULL\n");
6982 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6983 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6984 IHTMLElement_Release(elem2);
6986 elem2 = get_doc_elem_by_id(doc, "aid");
6987 ok(elem2 != NULL, "elem2 == NULL\n");
6988 test_elem_set_outerhtml((IUnknown*)elem2, "");
6989 test_elem_all((IUnknown*)div, outer_types, 1);
6990 IHTMLElement_Release(elem2);
6992 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6993 elem = get_elem_by_id(doc, "ta", TRUE);
6995 test_textarea_value((IUnknown*)elem, NULL);
6996 test_textarea_put_value((IUnknown*)elem, "test");
6997 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6998 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6999 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
7000 test_textarea_type((IUnknown*)elem);
7001 IHTMLElement_Release(elem);
7004 test_elem_set_innerhtml((IUnknown*)div,
7005 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" /></div></textarea>");
7006 elem = get_elem_by_id(doc, "form", TRUE);
7008 test_form_length((IUnknown*)elem, 2);
7009 test_form_item(elem);
7010 test_form_action((IUnknown*)elem, NULL);
7011 test_form_put_action((IUnknown*)elem, "about:blank");
7012 test_form_method((IUnknown*)elem, "get");
7013 test_form_put_method((IUnknown*)elem, S_OK, "post");
7014 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
7015 test_form_method((IUnknown*)elem, "post");
7016 test_form_name((IUnknown*)elem, NULL);
7017 test_form_put_name((IUnknown*)elem, "Name");
7018 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
7019 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
7020 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
7021 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
7022 test_form_encoding((IUnknown*)elem, "multipart/form-data");
7023 test_form_elements((IUnknown*)elem);
7024 IHTMLElement_Release(elem);
7028 test_style_filters(div);
7029 test_blocked(doc, div);
7031 IHTMLElement_Release(div);
7034 static void test_create_elems(IHTMLDocument2 *doc)
7036 IHTMLElement *elem, *body, *elem2;
7037 IHTMLDOMNode *node, *node2, *node3, *comment;
7038 IHTMLDocument5 *doc5;
7045 static const elem_type_t types1[] = { ET_TESTG };
7047 elem = test_create_elem(doc, "TEST");
7048 test_elem_tag((IUnknown*)elem, "TEST");
7049 type = get_node_type((IUnknown*)elem);
7050 ok(type == 1, "type=%d\n", type);
7051 test_ifaces((IUnknown*)elem, elem_iids);
7052 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
7054 body = doc_get_body(doc);
7055 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
7057 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
7058 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
7059 elem2 = get_elem_iface((IUnknown*)node);
7060 IHTMLElement_Release(elem2);
7062 hres = IHTMLElement_get_all(body, &disp);
7063 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7064 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
7065 IDispatch_Release(disp);
7067 test_node_remove_child((IUnknown*)body, node);
7069 hres = IHTMLElement_get_all(body, &disp);
7070 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7071 test_elem_collection((IUnknown*)disp, NULL, 0);
7072 IDispatch_Release(disp);
7073 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
7075 IHTMLElement_Release(elem);
7076 IHTMLDOMNode_Release(node);
7078 node = test_create_text(doc, "test");
7079 test_ifaces((IUnknown*)node, text_iids);
7080 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
7081 test_text_length((IUnknown*)node, 4);
7083 V_VT(&var) = VT_NULL;
7084 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
7085 IHTMLDOMNode_Release(node);
7087 node = test_create_text(doc, "insert ");
7089 V_VT(&var) = VT_DISPATCH;
7090 V_DISPATCH(&var) = (IDispatch*)node2;
7091 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
7092 IHTMLDOMNode_Release(node);
7093 IHTMLDOMNode_Release(node2);
7094 IHTMLDOMNode_Release(node3);
7096 test_elem_innertext(body, "insert test");
7097 test_elem_innerhtml((IUnknown*)body, "insert test");
7099 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
7102 str = a2bstr("testing");
7103 hres = IHTMLDocument5_createComment(doc5, str, &comment);
7105 ok(hres == S_OK, "createComment failed: %08x\n", hres);
7108 type = get_node_type((IUnknown*)comment);
7109 ok(type == 8, "type=%d, expected 8\n", type);
7111 test_node_get_value_str((IUnknown*)comment, "testing");
7112 test_elem_title((IUnknown*)comment, NULL);
7113 test_elem_set_title((IUnknown*)comment, "comment title");
7114 test_elem_title((IUnknown*)comment, "comment title");
7115 test_comment_text((IUnknown*)comment, "<!--testing-->");
7116 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
7118 IHTMLDOMNode_Release(comment);
7121 IHTMLDocument5_Release(doc5);
7124 IHTMLElement_Release(body);
7127 static void test_null_write(IHTMLDocument2 *doc)
7131 doc_write(doc, FALSE, NULL);
7132 doc_write(doc, TRUE, NULL);
7134 hres = IHTMLDocument2_write(doc, NULL);
7136 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
7138 hres = IHTMLDocument2_writeln(doc, NULL);
7140 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
7143 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
7145 IOleCommandTarget *cmdtrg;
7148 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
7149 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
7151 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
7152 ok(hres == S_OK, "Exec failed: %08x\n", hres);
7154 IOleCommandTarget_Release(cmdtrg);
7157 static void test_indent(IHTMLDocument2 *doc)
7159 IHTMLElementCollection *col;
7160 IHTMLTxtRange *range;
7163 static const elem_type_t all_types[] = {
7172 static const elem_type_t indent_types[] = {
7183 hres = IHTMLDocument2_get_all(doc, &col);
7184 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7185 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7186 IHTMLElementCollection_Release(col);
7188 range = test_create_body_range(doc);
7189 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
7190 IHTMLTxtRange_Release(range);
7192 hres = IHTMLDocument2_get_all(doc, &col);
7193 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7194 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
7195 IHTMLElementCollection_Release(col);
7198 static void test_cond_comment(IHTMLDocument2 *doc)
7200 IHTMLElementCollection *col;
7203 static const elem_type_t all_types[] = {
7211 hres = IHTMLDocument2_get_all(doc, &col);
7212 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7213 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7214 IHTMLElementCollection_Release(col);
7217 static void test_frame(IDispatch *disp, const char *exp_id)
7219 IHTMLWindow2 *frame2, *parent, *top;
7220 IHTMLDocument2 *parent_doc, *top_doc;
7221 IHTMLWindow4 *frame;
7222 IHTMLFrameBase *frame_elem;
7225 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
7226 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
7230 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
7231 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
7232 IHTMLWindow4_Release(frame);
7236 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
7237 test_frame_doc((IUnknown*)frame_elem, FALSE);
7238 test_elem_id((IUnknown*)frame_elem, exp_id);
7239 IHTMLElement_Release(frame_elem);
7241 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
7242 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
7246 hres = IHTMLWindow2_get_parent(frame2, &parent);
7247 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
7249 IHTMLWindow2_Release(frame2);
7253 hres = IHTMLWindow2_get_document(parent, &parent_doc);
7254 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7255 IHTMLWindow2_Release(parent);
7257 IHTMLWindow2_Release(frame2);
7261 test_doc_title(parent_doc, "frameset test");
7262 IHTMLDocument2_Release(parent_doc);
7265 hres = IHTMLWindow2_get_top(frame2, &top);
7266 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
7267 IHTMLWindow2_Release(frame2);
7271 hres = IHTMLWindow2_get_document(top, &top_doc);
7272 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7273 IHTMLWindow2_Release(top);
7277 test_doc_title(top_doc, "frameset test");
7278 IHTMLDocument2_Release(top_doc);
7281 static void test_frameset(IHTMLDocument2 *doc)
7283 IHTMLWindow2 *window;
7284 IHTMLFramesCollection2 *frames;
7286 IHTMLFrameBase *fbase;
7288 VARIANT index_var, result_var;
7292 window = get_doc_window(doc);
7294 /* test using IHTMLFramesCollection object */
7296 hres = IHTMLWindow2_get_frames(window, &frames);
7297 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
7298 IHTMLWindow2_Release(window);
7302 /* test result length */
7303 hres = IHTMLFramesCollection2_get_length(frames, &length);
7304 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
7305 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
7307 /* test first frame */
7308 V_VT(&index_var) = VT_I4;
7309 V_I4(&index_var) = 0;
7310 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7311 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7312 if(SUCCEEDED(hres)) {
7313 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7314 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7316 VariantClear(&result_var);
7318 /* test second frame */
7319 V_I4(&index_var) = 1;
7320 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7321 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7322 if(SUCCEEDED(hres)) {
7323 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7324 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7326 VariantClear(&result_var);
7328 /* fail on next frame */
7329 V_I4(&index_var) = 3;
7330 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7331 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
7332 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7333 VariantClear(&result_var);
7335 /* string argument (element id lookup) */
7336 V_VT(&index_var) = VT_BSTR;
7337 V_BSTR(&index_var) = a2bstr("fr1");
7338 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7339 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7340 if(SUCCEEDED(hres)) {
7341 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7342 test_frame(V_DISPATCH(&result_var), "fr1");
7344 VariantClear(&result_var);
7345 VariantClear(&index_var);
7347 /* invalid argument */
7348 V_VT(&index_var) = VT_BOOL;
7349 V_BOOL(&index_var) = VARIANT_TRUE;
7350 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7351 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
7352 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7353 VariantClear(&result_var);
7355 IHTMLFramesCollection2_Release(frames);
7357 /* test using IHTMLWindow2 inheritance */
7359 /* test result length */
7360 hres = IHTMLWindow2_get_length(window, &length);
7361 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
7362 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
7364 /* test first frame */
7365 V_VT(&index_var) = VT_I4;
7366 V_I4(&index_var) = 0;
7367 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7368 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7369 if(SUCCEEDED(hres)) {
7370 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7371 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7373 VariantClear(&result_var);
7375 /* test second frame */
7376 V_I4(&index_var) = 1;
7377 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7378 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7379 if(SUCCEEDED(hres)) {
7380 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7381 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7383 VariantClear(&result_var);
7385 /* fail on next frame */
7386 V_I4(&index_var) = 3;
7387 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7388 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
7389 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7390 VariantClear(&result_var);
7392 /* string argument (element id lookup) */
7393 V_VT(&index_var) = VT_BSTR;
7394 V_BSTR(&index_var) = a2bstr("fr2");
7395 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7396 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7397 if(SUCCEEDED(hres)) {
7398 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7399 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7401 VariantClear(&result_var);
7402 VariantClear(&index_var);
7404 /* invalid argument */
7405 V_VT(&index_var) = VT_BOOL;
7406 V_BOOL(&index_var) = VARIANT_TRUE;
7407 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7408 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
7409 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7410 VariantClear(&result_var);
7412 /* getElementById with node name attributes */
7413 elem = get_doc_elem_by_id(doc, "nm1");
7414 test_elem_id((IUnknown*)elem, "fr1");
7416 /* get/put scrolling */
7417 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7418 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7420 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7421 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7422 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
7426 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7427 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
7430 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7431 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7432 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7435 str = a2bstr("junk");
7436 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7437 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
7438 "with E_INVALIDARG, instead: 0x%08x\n", hres);
7441 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7442 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7443 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7447 hres = IHTMLFrameBase_get_name(fbase, &str);
7448 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7449 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
7452 IHTMLFrameBase_Release(fbase);
7453 IHTMLElement_Release(elem);
7455 /* get_name with no name attr */
7456 elem = get_doc_elem_by_id(doc, "fr3");
7457 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7458 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7460 hres = IHTMLFrameBase_get_name(fbase, &str);
7461 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7462 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
7465 IHTMLFrameBase_Release(fbase);
7466 IHTMLElement_Release(elem);
7469 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
7471 IHTMLDocument2 *frag;
7472 IHTMLDocument3 *doc3;
7475 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
7476 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
7478 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
7479 IHTMLDocument3_Release(doc3);
7480 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
7481 ok(frag != NULL, "frag == NULL\n");
7486 static void test_docfrag(IHTMLDocument2 *doc)
7488 IHTMLElement *div, *body, *br;
7489 IHTMLElementCollection *col;
7490 IHTMLLocation *location;
7491 IHTMLDocument2 *frag;
7494 static const elem_type_t all_types[] = {
7503 frag = create_docfrag(doc);
7505 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
7507 body = (void*)0xdeadbeef;
7508 hres = IHTMLDocument2_get_body(frag, &body);
7509 ok(hres == S_OK, "get_body failed: %08x\n", hres);
7510 ok(!body, "body != NULL\n");
7512 location = (void*)0xdeadbeef;
7513 hres = IHTMLDocument2_get_location(frag, &location);
7514 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
7515 ok(location == (void*)0xdeadbeef, "location changed\n");
7517 br = test_create_elem(doc, "BR");
7518 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
7519 IHTMLElement_Release(br);
7521 div = get_elem_by_id(doc, "divid", TRUE);
7522 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
7523 IHTMLElement_Release(div);
7525 hres = IHTMLDocument2_get_all(doc, &col);
7526 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7527 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7528 IHTMLElementCollection_Release(col);
7530 IHTMLDocument2_Release(frag);
7533 static IHTMLDocument2 *notif_doc;
7534 static BOOL doc_complete;
7536 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
7537 REFIID riid, void**ppv)
7539 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
7544 ok(0, "unexpected call\n");
7545 return E_NOINTERFACE;
7548 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
7553 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
7558 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
7560 if(dispID == DISPID_READYSTATE){
7564 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
7565 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
7567 if(!strcmp_wa(state, "complete"))
7568 doc_complete = TRUE;
7570 SysFreeString(state);
7576 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
7578 ok(0, "unexpected call\n");
7582 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
7583 PropertyNotifySink_QueryInterface,
7584 PropertyNotifySink_AddRef,
7585 PropertyNotifySink_Release,
7586 PropertyNotifySink_OnChanged,
7587 PropertyNotifySink_OnRequestEdit
7590 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
7592 static IHTMLDocument2 *create_doc_with_string(const char *str)
7594 IPersistStreamInit *init;
7596 IHTMLDocument2 *doc;
7600 notif_doc = doc = create_document();
7604 doc_complete = FALSE;
7606 mem = GlobalAlloc(0, len);
7607 memcpy(mem, str, len);
7608 CreateStreamOnHGlobal(mem, TRUE, &stream);
7610 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
7612 IPersistStreamInit_Load(init, stream);
7613 IPersistStreamInit_Release(init);
7614 IStream_Release(stream);
7619 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
7621 IConnectionPointContainer *container;
7622 IConnectionPoint *cp;
7626 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
7627 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
7629 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
7630 IConnectionPointContainer_Release(container);
7631 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
7633 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
7634 IConnectionPoint_Release(cp);
7635 ok(hres == S_OK, "Advise failed: %08x\n", hres);
7638 typedef void (*domtest_t)(IHTMLDocument2*);
7640 static void run_domtest(const char *str, domtest_t test)
7642 IHTMLDocument2 *doc;
7646 doc = create_doc_with_string(str);
7650 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
7652 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
7653 TranslateMessage(&msg);
7654 DispatchMessage(&msg);
7659 ref = IHTMLDocument2_Release(doc);
7660 ok(!ref || broken(ref == 1), /* Vista */
7668 run_domtest(doc_str1, test_doc_elem);
7669 run_domtest(doc_str1, test_get_set_attr);
7670 run_domtest(range_test_str, test_txtrange);
7671 run_domtest(range_test2_str, test_txtrange2);
7672 if (winetest_interactive || ! is_ie_hardened()) {
7673 run_domtest(elem_test_str, test_elems);
7674 run_domtest(elem_test2_str, test_elems2);
7676 skip("IE running in Enhanced Security Configuration\n");
7678 run_domtest(doc_blank, test_create_elems);
7679 run_domtest(doc_blank, test_defaults);
7680 run_domtest(doc_blank, test_null_write);
7681 run_domtest(indent_test_str, test_indent);
7682 run_domtest(cond_comment_str, test_cond_comment);
7683 run_domtest(frameset_str, test_frameset);
7684 run_domtest(emptydiv_str, test_docfrag);