2 * Copyright 2007-2008 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"
36 static const char doc_blank
[] = "<html></html>";
37 static const char doc_str1
[] = "<html><body>test</body></html>";
38 static const char range_test_str
[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str
[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str
[] =
43 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test /><object id=\"objid\" vspace=100></object><embed />"
52 "<img id=\"imgid\" name=\"WineImg\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "<form id=\"frm\"></form>"
56 static const char elem_test2_str
[] =
57 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
58 "<body><div id=\"divid\"></div></body>"
61 static const char indent_test_str
[] =
62 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
63 static const char cond_comment_str
[] =
64 "<html><head><title>test</title></head><body>"
65 "<!--[if gte IE 4]> <br> <![endif]-->"
67 static const char frameset_str
[] =
68 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
69 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
70 "<frame src=\"about:blank\" id=\"fr3\">"
72 static const char emptydiv_str
[] =
73 "<html><head><title>emptydiv test</title></head>"
74 "<body><div id=\"divid\"></div></body></html>";
76 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
77 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
78 static WCHAR wordW
[] = {'w','o','r','d',0};
112 static const IID
* const none_iids
[] = {
117 static const IID
* const doc_node_iids
[] = {
126 &IID_IConnectionPointContainer
,
127 &IID_IInternetHostSecurityManager
,
132 static const IID
* const doc_obj_iids
[] = {
139 &IID_IConnectionPointContainer
,
145 static const IID
* const elem_iids
[] = {
152 &IID_IConnectionPointContainer
,
156 static const IID
* const body_iids
[] = {
162 &IID_IHTMLTextContainer
,
163 &IID_IHTMLBodyElement
,
165 &IID_IConnectionPointContainer
,
169 static const IID
* const anchor_iids
[] = {
175 &IID_IHTMLAnchorElement
,
177 &IID_IConnectionPointContainer
,
181 static const IID
* const input_iids
[] = {
187 &IID_IHTMLInputElement
,
188 &IID_IHTMLInputTextElement
,
190 &IID_IConnectionPointContainer
,
194 static const IID
* const select_iids
[] = {
200 &IID_IHTMLSelectElement
,
202 &IID_IConnectionPointContainer
,
206 static const IID
* const textarea_iids
[] = {
212 &IID_IHTMLTextAreaElement
,
214 &IID_IConnectionPointContainer
,
218 static const IID
* const option_iids
[] = {
224 &IID_IHTMLOptionElement
,
226 &IID_IConnectionPointContainer
,
230 static const IID
* const table_iids
[] = {
238 &IID_IConnectionPointContainer
,
242 static const IID
* const script_iids
[] = {
248 &IID_IHTMLScriptElement
,
250 &IID_IConnectionPointContainer
,
254 static const IID
* const text_iids
[] = {
257 &IID_IHTMLDOMTextNode
,
261 static const IID
* const location_iids
[] = {
267 static const IID
* const window_iids
[] = {
272 &IID_IServiceProvider
,
276 static const IID
* const comment_iids
[] = {
282 &IID_IHTMLCommentElement
,
284 &IID_IConnectionPointContainer
,
288 static const IID
* const img_iids
[] = {
295 &IID_IHTMLImgElement
,
296 &IID_IConnectionPointContainer
,
300 static const IID
* const tr_iids
[] = {
308 &IID_IConnectionPointContainer
,
312 static const IID
* const td_iids
[] = {
319 &IID_IConnectionPointContainer
,
323 static const IID
* const frame_iids
[] = {
330 &IID_IHTMLFrameBase2
,
332 &IID_IConnectionPointContainer
,
336 static const IID
* const object_iids
[] = {
342 &IID_IHTMLObjectElement
,
344 /* FIXME: No IConnectionPointContainer */
348 static const IID
* const embed_iids
[] = {
354 &IID_IHTMLEmbedElement
,
356 /* FIXME: No IConnectionPointContainer */
360 static const IID
* const iframe_iids
[] = {
367 &IID_IHTMLFrameBase2
,
368 &IID_IHTMLIFrameElement
,
370 &IID_IConnectionPointContainer
,
374 static const IID
* const form_iids
[] = {
380 &IID_IHTMLFormElement
,
382 &IID_IConnectionPointContainer
,
386 static const IID
* const styleelem_iids
[] = {
392 &IID_IHTMLStyleElement
,
394 &IID_IConnectionPointContainer
,
398 static const IID
* const generic_iids
[] = {
404 &IID_IHTMLGenericElement
,
406 &IID_IConnectionPointContainer
,
410 static const IID
* const style_iids
[] = {
421 static const IID
* const cstyle_iids
[] = {
425 &IID_IHTMLCurrentStyle
,
429 static const IID
* const img_factory_iids
[] = {
433 &IID_IHTMLImageElementFactory
,
443 static const elem_type_info_t elem_type_infos
[] = {
444 {"", none_iids
, NULL
},
445 {"HTML", elem_iids
, NULL
},
446 {"HEAD", elem_iids
, NULL
},
447 {"TITLE", elem_iids
, NULL
},
448 {"BODY", body_iids
, &DIID_DispHTMLBody
},
449 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
450 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
451 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
452 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
453 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
454 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
455 {"BLOCKQUOTE",elem_iids
, NULL
},
456 {"P", elem_iids
, NULL
},
457 {"BR", elem_iids
, NULL
},
458 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
459 {"TBODY", elem_iids
, NULL
},
460 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
461 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
462 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
463 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
464 {"IMG", img_iids
, &DIID_DispHTMLImg
},
465 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
466 {"TD", td_iids
, NULL
},
467 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
468 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
469 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
470 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
471 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
472 {"DIV", elem_iids
, NULL
}
475 static const char *dbgstr_guid(REFIID riid
)
479 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
480 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
481 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
482 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
487 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
490 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
491 return lstrcmpA(stra
, buf
);
494 static BSTR
a2bstr(const char *str
)
499 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
500 ret
= SysAllocStringLen(NULL
, len
);
501 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
506 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
508 IUnknown
*unk1
, *unk2
;
513 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
514 IUnknown_Release(unk1
);
515 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
516 IUnknown_Release(unk2
);
521 static IHTMLDocument2
*create_document(void)
524 IHTMLDocument5
*doc5
;
527 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
528 &IID_IHTMLDocument2
, (void**)&doc
);
529 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
533 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
535 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
536 IHTMLDocument2_Release(doc
);
540 IHTMLDocument5_Release(doc5
);
544 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
545 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
547 const IID
* const *piid
;
551 for(piid
= iids
; *piid
; piid
++) {
552 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
553 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
555 IUnknown_Release(unk
);
559 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
560 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
568 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
569 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
574 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
575 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
576 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
578 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
579 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
581 if(SUCCEEDED(hres
)) {
584 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
585 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
587 *iid
= type_attr
->guid
;
591 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
592 ITypeInfo_Release(typeinfo
);
595 IDispatchEx_Release(dispex
);
599 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
600 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
602 DISPPARAMS dp
= {NULL
,NULL
,0,0};
608 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
609 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IDispatchEx interface: %08x\n", hres
);
613 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
614 IDispatchEx_Release(dispex
);
615 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
617 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
618 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
622 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
623 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
627 if(_test_get_dispid(line
, unk
, &iid
))
628 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", dbgstr_guid(&iid
));
631 _test_disp_value(line
, unk
, val
);
634 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
635 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
639 if(_test_get_dispid(line
, unk
, &iid
))
640 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
641 "unexpected guid %s\n", dbgstr_guid(&iid
));
644 _test_disp_value(line
, unk
, val
);
647 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
648 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
653 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
654 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
658 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
659 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
664 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
665 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
669 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
670 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
675 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
676 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
680 #define get_node_iface(u) _get_node_iface(__LINE__,u)
681 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
686 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
687 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
691 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
692 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
697 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
698 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
702 #define get_img_iface(u) _get_img_iface(__LINE__,u)
703 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
705 IHTMLImgElement
*img
;
708 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
709 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
713 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
714 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
716 IHTMLAnchorElement
*anchor
;
719 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
720 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
724 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
725 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
727 IHTMLTextAreaElement
*textarea
;
730 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
731 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
735 #define get_select_iface(u) _get_select_iface(__LINE__,u)
736 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
738 IHTMLSelectElement
*select
;
741 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
742 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
746 #define get_form_iface(u) _get_form_iface(__LINE__,u)
747 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
749 IHTMLFormElement
*form
;
752 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
753 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
757 #define get_text_iface(u) _get_text_iface(__LINE__,u)
758 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
760 IHTMLDOMTextNode
*text
;
763 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
764 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
768 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
769 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
771 IHTMLCommentElement
*comment
;
774 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
775 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
779 #define get_object_iface(u) _get_object_iface(__LINE__,u)
780 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
782 IHTMLObjectElement
*obj
;
785 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
786 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
790 #define get_style_iface(u) _get_style_iface(__LINE__,u)
791 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
793 IHTMLStyleElement
*obj
;
796 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
797 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
801 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
802 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
804 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
808 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
809 IHTMLDOMNode_Release(node
);
810 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
811 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
816 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
817 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
819 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
820 IDispatch
*disp
= (void*)0xdeadbeef;
821 IHTMLDocument2
*doc
= NULL
;
824 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
825 IHTMLDOMNode2_Release(node
);
826 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
829 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
830 IDispatch_Release(disp
);
831 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
837 #define get_doc_window(d) _get_doc_window(__LINE__,d)
838 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
840 IHTMLWindow2
*window
;
844 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
845 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
846 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
851 #define clone_node(n,d) _clone_node(__LINE__,n,d)
852 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
854 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
855 IHTMLDOMNode
*ret
= NULL
;
858 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
859 IHTMLDOMNode_Release(node
);
860 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
861 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
867 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
868 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
870 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
874 hres
= IHTMLElement_get_tagName(elem
, &tag
);
875 IHTMLElement_Release(elem
);
876 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
877 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
882 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
883 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
885 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
886 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
888 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
889 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
892 #define get_node_type(n) _get_node_type(__LINE__,n)
893 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
895 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
899 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
900 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
902 IHTMLDOMNode_Release(node
);
907 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
908 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
910 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
911 IHTMLDOMChildrenCollection
*col
= NULL
;
915 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
916 IHTMLDOMNode_Release(node
);
917 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
921 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
922 IDispatch_Release(disp
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
928 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
929 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
931 IHTMLDOMNode
*node
= NULL
;
935 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
936 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
938 node
= _get_node_iface(line
, (IUnknown
*)disp
);
939 IDispatch_Release(disp
);
944 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
945 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
954 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
956 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
959 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
960 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
962 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
965 VariantClear(&value
);
968 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
969 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
971 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
975 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
976 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
978 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
979 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
981 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
982 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
984 IHTMLElement_Release(elem
);
987 #define get_doc_node(d) _get_doc_node(__LINE__,d)
988 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
990 IHTMLWindow2
*window
;
994 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
995 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
997 hres
= IHTMLWindow2_get_document(window
, &ret
);
998 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
999 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1004 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1005 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1010 hres
= IHTMLWindow2_get_name(window
, &name
);
1011 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1013 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1015 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1016 SysFreeString(name
);
1019 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1020 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1026 hres
= IHTMLWindow2_put_name(window
, str
);
1028 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1030 _test_window_name(line
, window
, name
);
1033 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1034 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1039 hres
= IHTMLWindow2_get_length(window
, &length
);
1040 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1041 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1044 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1045 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1047 IHTMLFrameBase2
*base2
;
1048 IHTMLWindow2
*window
;
1051 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1052 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1055 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1056 IHTMLFrameBase2_Release(base2
);
1057 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1058 ok(window
!= NULL
, "contentWindow = NULL\n");
1063 static void test_get_set_attr(IHTMLDocument2
*doc
)
1066 IHTMLDocument3
*doc3
;
1071 /* grab an element to test with */
1072 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1073 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1075 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1076 IHTMLDocument3_Release(doc3
);
1077 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1079 /* get a non-present attribute */
1080 bstr
= a2bstr("notAnAttribute");
1081 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1082 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1083 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1085 SysFreeString(bstr
);
1087 /* get a present attribute */
1088 bstr
= a2bstr("scrollHeight");
1089 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1090 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1091 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1093 SysFreeString(bstr
);
1095 /* create a new BSTR attribute */
1096 bstr
= a2bstr("newAttribute");
1098 V_VT(&val
) = VT_BSTR
;
1099 V_BSTR(&val
) = a2bstr("the value");
1100 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1101 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1104 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1105 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1106 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1107 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
)));
1110 /* overwrite the attribute with a BOOL */
1111 V_VT(&val
) = VT_BOOL
;
1112 V_BOOL(&val
) = VARIANT_TRUE
;
1113 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1114 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
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
));
1123 SysFreeString(bstr
);
1125 /* case-insensitive */
1126 bstr
= a2bstr("newattribute");
1127 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1128 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1129 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1130 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1132 SysFreeString(bstr
);
1134 IHTMLElement_Release(elem
);
1137 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1138 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1141 IHTMLDocument3
*doc3
;
1144 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1145 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1146 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1147 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1148 IHTMLDocument3_Release(doc3
);
1153 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1154 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1156 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1160 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1161 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1162 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1165 _test_disp_value(line
, unk
, exhref
);
1168 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1169 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1174 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1175 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1176 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1177 SysFreeString(bstr
);
1180 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1181 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1186 bstr
= a2bstr(text
);
1187 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1188 SysFreeString(bstr
);
1189 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1191 _test_option_text(line
, option
, text
);
1194 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1195 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1200 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1201 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1202 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1203 SysFreeString(bstr
);
1206 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1207 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1212 bstr
= a2bstr(value
);
1213 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1214 SysFreeString(bstr
);
1215 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1217 _test_option_value(line
, option
, value
);
1220 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1221 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1223 VARIANT_BOOL b
= 0x100;
1226 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1227 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1228 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1231 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1232 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1236 hres
= IHTMLOptionElement_put_selected(option
, b
);
1237 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1238 _test_option_selected(line
, option
, b
);
1241 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1242 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1244 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1245 BSTR value
= (void*)0xdeadbeef;
1248 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1249 IHTMLTextAreaElement_Release(textarea
);
1250 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1252 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1254 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1255 SysFreeString(value
);
1258 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1259 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1261 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1262 BSTR tmp
= a2bstr(value
);
1265 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1266 IHTMLTextAreaElement_Release(textarea
);
1267 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1270 _test_textarea_value(line
, unk
, value
);
1273 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1274 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1276 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1277 VARIANT_BOOL b
= 0x100;
1280 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1281 IHTMLTextAreaElement_Release(textarea
);
1282 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1283 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1286 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1287 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1289 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1292 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1293 IHTMLTextAreaElement_Release(textarea
);
1294 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1296 _test_textarea_readonly(line
, unk
, b
);
1299 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1300 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1302 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1303 BSTR type
= (void*)0xdeadbeef;
1306 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1307 IHTMLTextAreaElement_Release(textarea
);
1308 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1309 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1310 SysFreeString(type
);
1313 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1314 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1316 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1320 text
= a2bstr(extext
);
1321 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1322 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1323 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1325 IHTMLCommentElement_Release(comment
);
1326 SysFreeString(text
);
1329 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1330 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1332 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1337 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1338 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1339 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1340 IHTMLObjectElement_Release(object
);
1343 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1344 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1345 const char *txt
, const char *val
)
1347 IHTMLOptionElementFactory
*factory
;
1348 IHTMLOptionElement
*option
;
1349 IHTMLWindow2
*window
;
1350 VARIANT text
, value
, empty
;
1353 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1354 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1356 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1357 IHTMLWindow2_Release(window
);
1358 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1360 V_VT(&text
) = VT_BSTR
;
1361 V_BSTR(&text
) = a2bstr(txt
);
1362 V_VT(&value
) = VT_BSTR
;
1363 V_BSTR(&value
) = a2bstr(val
);
1364 V_VT(&empty
) = VT_EMPTY
;
1366 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1367 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1369 IHTMLOptionElementFactory_Release(factory
);
1370 VariantClear(&text
);
1371 VariantClear(&value
);
1373 _test_option_text(line
, option
, txt
);
1374 _test_option_value(line
, option
, val
);
1375 _test_option_selected(line
, option
, VARIANT_FALSE
);
1380 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1381 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1386 hres
= IHTMLImgElement_get_width(img
, &found
);
1387 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1388 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1391 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1392 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1396 hres
= IHTMLImgElement_put_width(img
, width
);
1397 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1399 _test_img_width(line
, img
, width
);
1402 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1403 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1408 hres
= IHTMLImgElement_get_height(img
, &found
);
1409 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1410 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1413 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1414 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1418 hres
= IHTMLImgElement_put_height(img
, height
);
1419 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1421 _test_img_height(line
, img
, height
);
1424 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1425 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1426 LONG wdth
, LONG hght
)
1428 IHTMLImageElementFactory
*factory
;
1429 IHTMLImgElement
*img
;
1430 IHTMLWindow2
*window
;
1431 VARIANT width
, height
;
1435 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1436 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1438 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1439 IHTMLWindow2_Release(window
);
1440 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1442 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1443 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1446 snprintf(buf
, 16, "%d", wdth
);
1447 V_VT(&width
) = VT_BSTR
;
1448 V_BSTR(&width
) = a2bstr(buf
);
1450 V_VT(&width
) = VT_EMPTY
;
1455 snprintf(buf
, 16, "%d", hght
);
1456 V_VT(&height
) = VT_BSTR
;
1457 V_BSTR(&height
) = a2bstr(buf
);
1459 V_VT(&height
) = VT_EMPTY
;
1463 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1464 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1466 IHTMLImageElementFactory_Release(factory
);
1467 VariantClear(&width
);
1468 VariantClear(&height
);
1470 if(SUCCEEDED(hres
)) {
1471 _test_img_width(line
, img
, wdth
);
1472 _test_img_height(line
, img
, hght
);
1479 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1480 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1482 LONG len
= 0xdeadbeef;
1485 hres
= IHTMLSelectElement_get_length(select
, &len
);
1486 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1487 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1490 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1491 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1493 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1496 hres
= IHTMLSelectElement_put_length(select
, length
);
1497 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1498 _test_select_length(line
, select
, length
);
1499 IHTMLSelectElement_Release(select
);
1502 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1503 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1505 LONG idx
= 0xdeadbeef;
1508 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1509 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1510 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1513 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1514 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1518 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1519 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1520 _test_select_selidx(line
, select
, index
);
1523 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1524 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1529 hres
= IHTMLSelectElement_get_value(select
, &val
);
1530 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1532 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1534 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1538 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1539 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1545 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1546 SysFreeString(bstr
);
1547 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1550 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1551 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1556 hres
= IHTMLSelectElement_get_type(select
, &type
);
1557 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1558 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1559 SysFreeString(type
);
1562 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1563 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1568 hres
= IHTMLTxtRange_get_text(range
, &text
);
1569 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1572 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1573 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1575 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1578 SysFreeString(text
);
1582 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1583 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1587 hres
= IHTMLTxtRange_collapse(range
, b
);
1588 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1589 _test_range_text(line
, range
, NULL
);
1592 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1593 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1594 VARIANT_BOOL exb
, const char *extext
)
1596 VARIANT_BOOL b
= 0xe0e0;
1599 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1600 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1601 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1602 _test_range_text(line
, range
, extext
);
1605 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1606 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1608 LONG c
= 0xdeadbeef;
1611 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1612 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1613 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1614 _test_range_text(line
, range
, NULL
);
1617 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1618 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1619 LPWSTR unit
, LONG cnt
, LONG excnt
)
1621 LONG c
= 0xdeadbeef;
1624 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1625 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1626 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1629 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1630 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1632 LONG c
= 0xdeadbeef;
1635 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1636 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1637 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1640 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1641 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1644 BSTR bstr
= a2bstr(text
);
1646 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1647 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1648 SysFreeString(bstr
);
1649 _test_range_text(line
, range
, NULL
);
1652 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1653 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1659 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1660 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1661 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1664 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1665 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1671 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1672 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1673 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1676 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1677 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1678 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1681 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1682 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1686 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1687 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1692 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1693 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1695 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1697 IHTMLElement_Release(elem
);
1700 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1701 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1702 const elem_type_t
*elem_types
, LONG exlen
)
1704 IHTMLElementCollection
*col
;
1707 VARIANT name
, index
;
1708 IDispatch
*disp
, *disp2
;
1711 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1712 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1714 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1716 hres
= IHTMLElementCollection_get_length(col
, &len
);
1717 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1718 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1723 V_VT(&index
) = VT_EMPTY
;
1725 for(i
=0; i
<len
; i
++) {
1726 V_VT(&name
) = VT_I4
;
1728 disp
= (void*)0xdeadbeef;
1729 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1730 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1731 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1732 if(FAILED(hres
) || !disp
)
1735 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1738 V_VT(&name
) = VT_UINT
;
1740 disp2
= (void*)0xdeadbeef;
1741 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1742 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1743 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1745 IDispatch_Release(disp2
);
1748 IDispatch_Release(disp
);
1751 V_VT(&name
) = VT_I4
;
1753 disp
= (void*)0xdeadbeef;
1754 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1755 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1756 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1758 V_VT(&name
) = VT_I4
;
1760 disp
= (void*)0xdeadbeef;
1761 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1762 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1763 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1765 IHTMLElementCollection_Release(col
);
1768 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1769 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1771 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1775 hres
= IHTMLElement_get_all(elem
, &disp
);
1776 IHTMLElement_Release(elem
);
1777 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1779 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1780 IDispatch_Release(disp
);
1783 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1784 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1786 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1787 IHTMLElementCollection
*col
= NULL
;
1788 elem_type_t
*types
= NULL
;
1793 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1794 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1796 IHTMLElement2_Release(elem
);
1797 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1798 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1801 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1802 for(i
=0; i
<exlen
; i
++)
1806 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1808 HeapFree(GetProcessHeap(), 0, types
);
1811 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1812 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1817 hres
= IHTMLElement_get_innerText(elem
, &text
);
1818 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1819 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1820 wine_dbgstr_w(text
), extext
);
1821 SysFreeString(text
);
1824 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1825 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1827 IHTMLDOMChildrenCollection
*col
;
1832 hres
= IHTMLElement_put_innerText(elem
, str
);
1833 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1836 _test_elem_innertext(line
, elem
, text
);
1839 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1840 ok(col
!= NULL
, "col == NULL\n");
1842 LONG length
= 0, type
;
1845 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1846 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1847 ok(length
== 1, "length = %d\n", length
);
1849 node
= _get_child_item(line
, col
, 0);
1850 ok(node
!= NULL
, "node == NULL\n");
1852 type
= _get_node_type(line
, (IUnknown
*)node
);
1853 ok(type
== 3, "type=%d\n", type
);
1854 IHTMLDOMNode_Release(node
);
1857 IHTMLDOMChildrenCollection_Release(col
);
1862 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1863 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1865 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1869 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
1870 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
1872 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
1874 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
1876 IHTMLElement_Release(elem
);
1877 SysFreeString(html
);
1880 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1881 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1883 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1887 html
= a2bstr(inner_html
);
1888 hres
= IHTMLElement_put_innerHTML(elem
, html
);
1889 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
1891 IHTMLElement_Release(elem
);
1892 SysFreeString(html
);
1895 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1896 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1898 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1902 html
= a2bstr(outer_html
);
1903 hres
= IHTMLElement_put_outerHTML(elem
, html
);
1904 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
1906 IHTMLElement_Release(elem
);
1907 SysFreeString(html
);
1910 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1911 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1913 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1917 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
1918 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
1919 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
1921 IHTMLElement_Release(elem
);
1922 SysFreeString(html
);
1925 #define get_first_child(n) _get_first_child(__LINE__,n)
1926 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1928 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1929 IHTMLDOMNode
*child
= NULL
;
1932 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1933 IHTMLDOMNode_Release(node
);
1934 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1939 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1940 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1942 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1943 VARIANT_BOOL b
= 0xdead;
1946 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1947 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1948 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1950 IHTMLDOMNode_Release(node
);
1953 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1954 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1956 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1957 IHTMLDOMNode
*parent
;
1960 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1961 IHTMLDOMNode_Release(node
);
1962 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1967 #define node_get_next(u) _node_get_next(__LINE__,u)
1968 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
1970 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1974 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
1975 IHTMLDOMNode_Release(node
);
1976 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
1981 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1982 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1984 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1985 IHTMLElement
*parent
;
1988 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1989 IHTMLElement_Release(elem
);
1990 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1995 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1996 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1998 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1999 VARIANT_BOOL disabled
= 100;
2003 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2004 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2005 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2006 IHTMLElement3_Release(elem3
);
2009 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2010 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2012 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2016 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2017 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2019 IHTMLElement3_Release(elem3
);
2020 _test_elem3_get_disabled(line
, unk
, b
);
2023 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2024 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2026 VARIANT_BOOL disabled
= 100;
2029 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2030 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2031 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2033 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2036 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2037 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
2039 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2043 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
2044 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2045 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
2046 IHTMLDOMTextNode_Release(text
);
2049 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2050 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
2054 hres
= IHTMLSelectElement_put_disabled(select
, b
);
2055 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2057 _test_select_get_disabled(line
, select
, b
);
2060 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2061 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
2063 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2064 IHTMLTextContainer
*txtcont
;
2065 LONG l
= -1, l2
= -1;
2068 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
2069 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
2070 IHTMLElement2_Release(elem
);
2072 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2073 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2075 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
2076 IHTMLTextContainer_Release(txtcont
);
2077 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
2078 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
2083 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2084 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
2086 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2087 IHTMLTextContainer
*txtcont
;
2088 LONG l
= -1, l2
= -1;
2091 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
2092 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
2093 IHTMLElement2_Release(elem
);
2095 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2096 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2098 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
2099 IHTMLTextContainer_Release(txtcont
);
2100 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
2101 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
2106 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2107 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
2109 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2110 IHTMLTextContainer
*txtcont
;
2111 LONG l
= -1, l2
= -1;
2114 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
2115 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2116 IHTMLElement2_Release(elem
);
2118 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2119 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2121 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
2122 IHTMLTextContainer_Release(txtcont
);
2123 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
2124 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2129 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2130 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2132 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2133 IHTMLTextContainer
*txtcont
;
2134 LONG l
= -1, l2
= -1;
2137 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2138 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2140 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2141 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2142 IHTMLElement2_Release(elem
);
2144 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2145 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2147 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2148 IHTMLTextContainer_Release(txtcont
);
2149 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2150 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2153 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2154 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
2156 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2160 hres
= IHTMLImgElement_get_src(img
, &src
);
2161 IHTMLImgElement_Release(img
);
2162 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2163 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2167 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2168 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2170 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2175 hres
= IHTMLImgElement_put_src(img
, tmp
);
2176 IHTMLImgElement_Release(img
);
2178 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2180 _test_img_src(line
, unk
, src
);
2183 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2184 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2186 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2190 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2191 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2193 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2195 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2199 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2200 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2202 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2207 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2208 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2211 _test_img_alt(line
, unk
, alt
);
2214 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2215 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2217 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2221 hres
= IHTMLImgElement_get_name(img
, &sName
);
2222 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2223 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2224 IHTMLImgElement_Release(img
);
2225 SysFreeString(sName
);
2228 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2229 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
2234 hres
= IHTMLInputElement_get_type(input
, &type
);
2235 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2236 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2237 SysFreeString(type
);
2240 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2241 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
2243 BSTR name
= (BSTR
)0xdeadbeef;
2246 hres
= IHTMLInputElement_get_name(input
, &name
);
2247 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2249 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
2251 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
2252 SysFreeString(name
);
2255 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2256 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
2258 BSTR tmp
= a2bstr(name
);
2261 hres
= IHTMLInputElement_put_name(input
, tmp
);
2262 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
2265 _test_input_name(line
, input
, name
);
2268 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2269 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2271 VARIANT_BOOL disabled
= 100;
2274 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
2275 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2276 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2278 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
2281 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2282 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2286 hres
= IHTMLInputElement_put_disabled(input
, b
);
2287 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2289 _test_input_get_disabled(line
, input
, b
);
2292 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2293 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2295 VARIANT_BOOL checked
= 100;
2298 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
2299 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2300 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2303 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2304 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2308 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2309 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2311 _test_input_get_defaultchecked(line
, input
, b
);
2314 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2315 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2317 VARIANT_BOOL checked
= 100;
2320 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2321 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2322 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2325 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2326 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2330 hres
= IHTMLInputElement_put_checked(input
, b
);
2331 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2333 _test_input_get_checked(line
, input
, b
);
2336 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2337 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2339 IHTMLInputElement
*input
;
2343 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2344 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2348 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2349 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2351 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2353 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
2354 SysFreeString(bstr
);
2355 IHTMLInputElement_Release(input
);
2358 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2359 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2361 IHTMLInputElement
*input
;
2365 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2366 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2371 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2372 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2373 SysFreeString(bstr
);
2374 IHTMLInputElement_Release(input
);
2377 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2378 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2383 hres
= IHTMLInputElement_get_src(input
, &src
);
2384 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2386 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2388 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2392 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2393 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2399 hres
= IHTMLInputElement_put_src(input
, tmp
);
2401 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2403 _test_input_src(line
, input
, src
);
2406 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2407 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2409 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2410 BSTR
class = (void*)0xdeadbeef;
2413 hres
= IHTMLElement_get_className(elem
, &class);
2414 IHTMLElement_Release(elem
);
2415 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2417 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2419 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2420 SysFreeString(class);
2423 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2424 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2426 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2430 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2431 IHTMLElement2_Release(elem2
);
2432 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2433 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2436 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2437 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2439 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2442 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2443 IHTMLElement2_Release(elem2
);
2444 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2446 _test_elem_tabindex(line
, unk
, index
);
2449 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2450 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
2452 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2456 hres
= IHTMLStyleElement_get_media(style
, &media
);
2457 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
2459 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
2461 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
2463 IHTMLStyleElement_Release(style
);
2464 SysFreeString(media
);
2467 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2468 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
2470 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
2474 str
= a2bstr(media
);
2475 hres
= IHTMLStyleElement_put_media(style
, str
);
2476 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
2477 IHTMLStyleElement_Release(style
);
2480 _test_style_media(line
, unk
, media
);
2483 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2484 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2486 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2488 IHTMLFiltersCollection
*filters
;
2490 hres
= IHTMLElement_get_filters(elem
, &filters
);
2491 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2492 "get_filters failed: %08x\n", hres
);
2496 IDispatchEx
*dispex
;
2498 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2499 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2500 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2502 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2503 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2504 "Could not get IDispatchEx interface: %08x\n", hres
);
2505 if(SUCCEEDED(hres
)) {
2506 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2507 IDispatchEx_Release(dispex
);
2510 IHTMLFiltersCollection_Release(filters
);
2513 IHTMLElement_Release(elem
);
2516 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2517 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2519 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2523 tmp
= class ? a2bstr(class) : NULL
;
2524 hres
= IHTMLElement_put_className(elem
, tmp
);
2525 IHTMLElement_Release(elem
);
2526 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
2529 _test_elem_class(line
, unk
, class);
2532 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2533 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
2535 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2536 BSTR id
= (void*)0xdeadbeef;
2539 hres
= IHTMLElement_get_id(elem
, &id
);
2540 IHTMLElement_Release(elem
);
2541 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
2544 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
2546 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
2551 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2552 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
2554 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2555 BSTR tmp
= a2bstr(new_id
);
2558 hres
= IHTMLElement_put_id(elem
, tmp
);
2559 IHTMLElement_Release(elem
);
2561 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
2563 _test_elem_id(line
, unk
, new_id
);
2566 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2567 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
2569 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2573 hres
= IHTMLElement_get_title(elem
, &title
);
2574 IHTMLElement_Release(elem
);
2575 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2577 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2579 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
2581 SysFreeString(title
);
2584 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2585 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
2587 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2591 tmp
= a2bstr(title
);
2592 hres
= IHTMLElement_put_title(elem
, tmp
);
2593 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2595 IHTMLElement_Release(elem
);
2599 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2600 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
2602 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2606 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
2607 IHTMLDOMNode_Release(node
);
2608 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2611 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
2612 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2614 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
2620 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2621 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
2623 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2627 V_VT(&var
) = VT_BSTR
;
2628 V_BSTR(&var
) = a2bstr(val
);
2630 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
2631 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2632 IHTMLDOMNode_Release(node
);
2636 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2637 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
2639 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2643 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
2644 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
2645 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
2646 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
2648 IHTMLElement2_Release(elem
);
2651 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2652 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
2654 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2658 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
2659 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
2660 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
2662 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
2663 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
2664 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
2666 IHTMLElement2_Release(elem
);
2669 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2670 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
2672 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2673 LONG len
= 0xdeadbeef;
2676 hres
= IHTMLFormElement_get_length(form
, &len
);
2677 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2678 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
2680 IHTMLFormElement_Release(form
);
2683 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2684 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
2686 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2687 BSTR action
= (void*)0xdeadbeef;
2690 hres
= IHTMLFormElement_get_action(form
, &action
);
2691 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
2693 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
2695 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
2697 SysFreeString(action
);
2698 IHTMLFormElement_Release(form
);
2701 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2702 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
2704 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2705 BSTR tmp
= a2bstr(action
);
2708 hres
= IHTMLFormElement_put_action(form
, tmp
);
2709 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
2711 IHTMLFormElement_Release(form
);
2713 _test_form_action(line
, unk
, action
);
2716 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2717 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
2719 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2720 BSTR method
= (void*)0xdeadbeef;
2723 hres
= IHTMLFormElement_get_method(form
, &method
);
2724 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
2726 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
2728 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
2730 SysFreeString(method
);
2731 IHTMLFormElement_Release(form
);
2734 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2735 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
2737 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2738 BSTR tmp
= a2bstr(method
);
2741 hres
= IHTMLFormElement_put_method(form
, tmp
);
2742 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
2744 IHTMLFormElement_Release(form
);
2746 if(exp_hres
== S_OK
)
2747 _test_form_method(line
, unk
, method
);
2750 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2751 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
2753 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2754 BSTR name
= (void*)0xdeadbeef;
2757 hres
= IHTMLFormElement_get_name(form
, &name
);
2758 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2760 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
2762 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
2764 SysFreeString(name
);
2765 IHTMLFormElement_Release(form
);
2768 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2769 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
2771 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2772 BSTR tmp
= a2bstr(name
);
2775 hres
= IHTMLFormElement_put_name(form
, tmp
);
2776 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2778 IHTMLFormElement_Release(form
);
2780 _test_form_name(line
, unk
, name
);
2783 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2784 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
2786 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2787 BSTR encoding
= (void*)0xdeadbeef;
2790 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
2791 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
2793 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
2795 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
2797 SysFreeString(encoding
);
2798 IHTMLFormElement_Release(form
);
2801 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2802 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
2804 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2805 BSTR tmp
= a2bstr(encoding
);
2808 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
2809 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
2811 IHTMLFormElement_Release(form
);
2813 if(exp_hres
== S_OK
)
2814 _test_form_encoding(line
, unk
, encoding
);
2817 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2818 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
2820 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2821 IHTMLDocument2
*doc
;
2826 hres
= IHTMLElement_get_document(elem
, &disp
);
2827 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2828 ok(disp
!= NULL
, "disp == NULL\n");
2830 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
2831 IDispatch_Release(disp
);
2832 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
2837 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2838 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
2840 IHTMLDocument2
*doc
;
2844 hres
= IHTMLWindow2_get_document(window
, &doc
);
2845 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2846 ok(doc
!= NULL
, "disp == NULL\n");
2851 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2852 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
2857 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2858 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2859 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
2864 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2865 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
2867 IHTMLElement
*elem
= NULL
;
2872 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
2873 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2874 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
2879 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2880 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
2882 IHTMLDocument3
*doc3
;
2883 IHTMLDOMNode
*node
= NULL
;
2887 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2888 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
2891 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
2892 IHTMLDocument3_Release(doc3
);
2893 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2894 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
2899 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2900 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
2902 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2903 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
2904 IHTMLDOMNode
*new_child
= NULL
;
2907 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
2908 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
2909 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2910 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2912 IHTMLDOMNode_Release(node
);
2913 IHTMLDOMNode_Release(child
);
2918 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2919 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
2921 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2922 IHTMLDOMNode
*new_child
= NULL
;
2925 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
2926 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
2927 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2928 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2930 IHTMLDOMNode_Release(node
);
2935 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2936 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
2938 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2939 IHTMLDOMNode
*new_node
= NULL
;
2942 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
2943 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
2944 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
2945 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2947 IHTMLDOMNode_Release(node
);
2948 IHTMLDOMNode_Release(new_node
);
2951 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2952 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
2957 hres
= IHTMLDocument2_get_title(doc
, &title
);
2958 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2959 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2960 SysFreeString(title
);
2963 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2964 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
2969 tmp
= a2bstr(title
);
2970 hres
= IHTMLDocument2_put_title(doc
, tmp
);
2971 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2975 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2976 static void _test_border_styles(unsigned line
, IHTMLStyle
*pStyle
, BSTR Name
)
2981 hres
= IHTMLStyle_GetIDsOfNames(pStyle
, &IID_NULL
, &Name
, 1,
2982 LOCALE_USER_DEFAULT
, &dispid
);
2983 ok_(__FILE__
,line
) (hres
== S_OK
, "GetIDsOfNames: %08x\n", hres
);
2986 DISPPARAMS params
= {NULL
,NULL
,0,0};
2987 DISPID dispidNamed
= DISPID_PROPERTYPUT
;
2992 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2993 DISPATCH_PROPERTYGET
, ¶ms
, &vDefault
, NULL
, NULL
);
2994 ok_(__FILE__
,line
) (hres
== S_OK
, "get_default. ret: %08x\n", hres
);
2997 params
.cNamedArgs
= 1;
2998 params
.rgdispidNamedArgs
= &dispidNamed
;
2999 V_VT(&arg
) = VT_BSTR
;
3000 V_BSTR(&arg
) = a2bstr("none");
3001 params
.rgvarg
= &arg
;
3002 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3003 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3004 ok_(__FILE__
,line
) (hres
== S_OK
, "none. ret: %08x\n", hres
);
3007 V_VT(&arg
) = VT_BSTR
;
3008 V_BSTR(&arg
) = a2bstr("dotted");
3009 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3010 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3011 ok_(__FILE__
,line
) (hres
== S_OK
, "dotted. ret: %08x\n", hres
);
3014 V_VT(&arg
) = VT_BSTR
;
3015 V_BSTR(&arg
) = a2bstr("dashed");
3016 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3017 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3018 ok_(__FILE__
,line
) (hres
== S_OK
, "dashed. ret: %08x\n", hres
);
3021 V_VT(&arg
) = VT_BSTR
;
3022 V_BSTR(&arg
) = a2bstr("solid");
3023 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3024 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3025 ok_(__FILE__
,line
) (hres
== S_OK
, "solid. ret: %08x\n", hres
);
3028 V_VT(&arg
) = VT_BSTR
;
3029 V_BSTR(&arg
) = a2bstr("double");
3030 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3031 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3032 ok_(__FILE__
,line
) (hres
== S_OK
, "double. ret: %08x\n", hres
);
3035 V_VT(&arg
) = VT_BSTR
;
3036 V_BSTR(&arg
) = a2bstr("groove");
3037 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3038 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3039 ok_(__FILE__
,line
) (hres
== S_OK
, "groove. ret: %08x\n", hres
);
3042 V_VT(&arg
) = VT_BSTR
;
3043 V_BSTR(&arg
) = a2bstr("ridge");
3044 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3045 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3046 ok_(__FILE__
,line
) (hres
== S_OK
, "ridge. ret: %08x\n", hres
);
3049 V_VT(&arg
) = VT_BSTR
;
3050 V_BSTR(&arg
) = a2bstr("inset");
3051 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3052 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3053 ok_(__FILE__
,line
) (hres
== S_OK
, "inset. ret: %08x\n", hres
);
3056 V_VT(&arg
) = VT_BSTR
;
3057 V_BSTR(&arg
) = a2bstr("outset");
3058 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3059 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3060 ok_(__FILE__
,line
) (hres
== S_OK
, "outset. ret: %08x\n", hres
);
3063 V_VT(&arg
) = VT_BSTR
;
3064 V_BSTR(&arg
) = a2bstr("invalid");
3065 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3066 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3067 ok_(__FILE__
,line
) (FAILED(hres
), "invalid value passed.\n");
3070 params
.rgvarg
= &vDefault
;
3071 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
3072 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
3073 ok_(__FILE__
,line
) (hres
== S_OK
, "default. ret: %08x\n", hres
);
3077 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3078 static void _test_style_csstext(unsigned line
, IHTMLStyle
*style
, const char *extext
)
3080 BSTR text
= (void*)0xdeadbeef;
3083 hres
= IHTMLStyle_get_cssText(style
, &text
);
3084 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
3086 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "cssText = %s\n", wine_dbgstr_w(text
));
3088 ok_(__FILE__
,line
)(!text
, "cssText = %s\n", wine_dbgstr_w(text
));
3090 SysFreeString(text
);
3093 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3094 static void _test_style_set_csstext(unsigned line
, IHTMLStyle
*style
, const char *text
)
3100 hres
= IHTMLStyle_put_cssText(style
, tmp
);
3101 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
3105 static void test_elem_bounding_client_rect(IUnknown
*unk
)
3107 IHTMLRect
*rect
, *rect2
;
3108 IHTMLElement2
*elem2
;
3112 elem2
= get_elem2_iface(unk
);
3113 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
3114 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
3115 IHTMLElement2_Release(elem2
);
3116 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
3117 ok(rect
!= NULL
, "rect == NULL\n");
3118 ok(rect
!= rect2
, "rect == rect2\n");
3119 IHTMLRect_Release(rect2
);
3121 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
3124 hres
= IHTMLRect_get_top(rect
, &l
);
3125 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3126 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3129 hres
= IHTMLRect_get_left(rect
, &l
);
3130 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3131 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3134 hres
= IHTMLRect_get_bottom(rect
, &l
);
3135 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3136 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3139 hres
= IHTMLRect_get_right(rect
, &l
);
3140 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3141 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
3143 IHTMLRect_Release(rect
);
3146 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
3147 const elem_type_t
*elem_types
, LONG len
)
3150 VARIANT name
, index
;
3154 V_VT(&index
) = VT_EMPTY
;
3155 V_VT(&name
) = VT_BSTR
;
3156 V_BSTR(&name
) = a2bstr(n
);
3158 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3159 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3161 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
3162 IDispatch_Release(disp
);
3163 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
3167 V_VT(&index
) = VT_I4
;
3169 for(i
=0; i
<len
; i
++) {
3171 disp
= (void*)0xdeadbeef;
3172 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3173 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3174 ok(disp
!= NULL
, "disp == NULL\n");
3175 if(FAILED(hres
) || !disp
)
3178 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
3180 IDispatch_Release(disp
);
3184 disp
= (void*)0xdeadbeef;
3185 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3186 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3187 ok(disp
== NULL
, "disp != NULL\n");
3190 disp
= (void*)0xdeadbeef;
3191 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3192 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3193 ok(disp
== NULL
, "disp != NULL\n");
3196 SysFreeString(V_BSTR(&name
));
3199 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
3201 IHTMLElementCollection
*col
;
3203 IDispatch
*disp
= (void*)0xdeadbeef;
3204 VARIANT name
, index
;
3207 hres
= IHTMLDocument2_get_all(doc
, &col
);
3208 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3209 ok(col
!= NULL
, "col == NULL\n");
3210 if(FAILED(hres
) || !col
)
3213 V_VT(&index
) = VT_EMPTY
;
3214 V_VT(&name
) = VT_BSTR
;
3215 V_BSTR(&name
) = a2bstr(id
);
3217 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
3218 IHTMLElementCollection_Release(col
);
3219 SysFreeString(V_BSTR(&name
));
3220 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3221 if(!expect_success
) {
3222 ok(disp
== NULL
, "disp != NULL\n");
3226 ok(disp
!= NULL
, "disp == NULL\n");
3230 elem
= get_elem_iface((IUnknown
*)disp
);
3231 IDispatch_Release(disp
);
3236 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
3238 IHTMLDocument3
*doc3
;
3243 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
3244 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
3247 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
3249 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
3251 IHTMLDocument3_Release(doc3
);
3256 static void test_select_elem(IHTMLSelectElement
*select
)
3258 IDispatch
*disp
, *disp2
;
3259 VARIANT name
, index
;
3262 test_select_type(select
, "select-one");
3263 test_select_length(select
, 2);
3264 test_select_selidx(select
, 0);
3265 test_select_put_selidx(select
, 1);
3267 test_select_set_value(select
, "val1");
3268 test_select_value(select
, "val1");
3270 test_select_get_disabled(select
, VARIANT_FALSE
);
3271 test_select_set_disabled(select
, VARIANT_TRUE
);
3272 test_select_set_disabled(select
, VARIANT_FALSE
);
3275 hres
= IHTMLSelectElement_get_options(select
, &disp
);
3276 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
3277 ok(disp
!= NULL
, "options == NULL\n");
3278 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
3279 IDispatch_Release(disp
);
3281 V_VT(&index
) = VT_EMPTY
;
3282 V_VT(&name
) = VT_I4
;
3284 disp
= (void*)0xdeadbeef;
3285 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3286 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3287 ok(!disp
, "disp = %p\n", disp
);
3290 disp
= (void*)0xdeadbeef;
3291 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3292 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3293 ok(!disp
, "disp = %p\n", disp
);
3296 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
3297 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
3300 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
3301 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3302 ok(disp
!= NULL
, "disp = NULL\n");
3303 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
3305 V_VT(&index
) = VT_I4
;
3308 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
3309 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3310 ok(disp2
!= NULL
, "disp = NULL\n");
3311 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
3312 IDispatch_Release(disp2
);
3313 IDispatch_Release(disp
);
3316 static void test_form_item(IHTMLElement
*elem
)
3318 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
3319 IDispatch
*disp
, *disp2
;
3320 VARIANT name
, index
;
3323 V_VT(&index
) = VT_EMPTY
;
3324 V_VT(&name
) = VT_I4
;
3326 disp
= (void*)0xdeadbeef;
3327 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3328 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3329 ok(!disp
, "disp = %p\n", disp
);
3332 disp
= (void*)0xdeadbeef;
3333 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3334 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3335 ok(!disp
, "disp = %p\n", disp
);
3338 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
3339 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3342 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
3343 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3344 ok(disp
!= NULL
, "disp = NULL\n");
3345 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
3347 V_VT(&index
) = VT_I4
;
3350 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
3351 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3352 ok(disp2
!= NULL
, "disp = NULL\n");
3353 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
3354 IDispatch_Release(disp2
);
3355 IDispatch_Release(disp
);
3358 static void test_create_option_elem(IHTMLDocument2
*doc
)
3360 IHTMLOptionElement
*option
;
3362 option
= create_option_elem(doc
, "test text", "test value");
3364 test_option_put_text(option
, "new text");
3365 test_option_put_value(option
, "new value");
3366 test_option_put_selected(option
, VARIANT_TRUE
);
3367 test_option_put_selected(option
, VARIANT_FALSE
);
3369 IHTMLOptionElement_Release(option
);
3372 static void test_create_img_elem(IHTMLDocument2
*doc
)
3374 IHTMLImgElement
*img
;
3376 img
= create_img_elem(doc
, 10, 15);
3379 test_img_put_width(img
, 5);
3380 test_img_put_height(img
, 20);
3382 IHTMLImgElement_Release(img
);
3386 img
= create_img_elem(doc
, -1, -1);
3389 test_img_put_width(img
, 5);
3390 test_img_put_height(img
, 20);
3392 IHTMLImgElement_Release(img
);
3396 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
3398 IHTMLBodyElement
*body
;
3399 IHTMLTxtRange
*range
;
3403 elem
= doc_get_body(doc
);
3404 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
3405 IHTMLElement_Release(elem
);
3407 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
3408 IHTMLBodyElement_Release(body
);
3409 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
3414 static void test_txtrange(IHTMLDocument2
*doc
)
3416 IHTMLTxtRange
*body_range
, *range
, *range2
;
3417 IHTMLSelectionObject
*selection
;
3418 IDispatch
*disp_range
;
3421 body_range
= test_create_body_range(doc
);
3423 test_range_text(body_range
, "test abc 123\r\nit's text");
3425 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3426 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3428 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
3429 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3430 test_range_isequal(range
, range2
, VARIANT_TRUE
);
3432 test_range_text(range
, "test abc 123\r\nit's text");
3433 test_range_text(body_range
, "test abc 123\r\nit's text");
3435 test_range_collapse(range
, TRUE
);
3436 test_range_isequal(range
, range2
, VARIANT_FALSE
);
3437 test_range_inrange(range
, range2
, VARIANT_FALSE
);
3438 test_range_inrange(range2
, range
, VARIANT_TRUE
);
3439 IHTMLTxtRange_Release(range2
);
3441 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3442 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
3443 test_range_move(range
, characterW
, 2, 2);
3444 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3446 test_range_collapse(range
, FALSE
);
3447 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
3449 test_range_collapse(range
, FALSE
);
3450 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3451 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
3452 test_range_move(range
, characterW
, 2, 2);
3453 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3454 test_range_moveend(range
, characterW
, -5, -5);
3455 test_range_text(range
, NULL
);
3456 test_range_moveend(range
, characterW
, 3, 3);
3457 test_range_text(range
, "c 1");
3458 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
3459 test_range_collapse(range
, TRUE
);
3460 test_range_move(range
, characterW
, 4, 4);
3461 test_range_moveend(range
, characterW
, 1, 1);
3462 test_range_text(range
, " ");
3463 test_range_move(range
, wordW
, 1, 1);
3464 test_range_moveend(range
, characterW
, 2, 2);
3465 test_range_text(range
, "ab");
3467 IHTMLTxtRange_Release(range
);
3469 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3470 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3472 test_range_text(range
, "test abc 123\r\nit's text");
3473 test_range_move(range
, characterW
, 3, 3);
3474 test_range_moveend(range
, characterW
, 1, 1);
3475 test_range_text(range
, "t");
3476 test_range_moveend(range
, characterW
, 3, 3);
3477 test_range_text(range
, "t ab");
3478 test_range_moveend(range
, characterW
, -2, -2);
3479 test_range_text(range
, "t ");
3480 test_range_move(range
, characterW
, 6, 6);
3481 test_range_moveend(range
, characterW
, 3, 3);
3482 test_range_text(range
, "123");
3483 test_range_moveend(range
, characterW
, 2, 2);
3484 test_range_text(range
, "123\r\ni");
3486 IHTMLTxtRange_Release(range
);
3488 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3489 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3491 test_range_move(range
, wordW
, 1, 1);
3492 test_range_moveend(range
, characterW
, 2, 2);
3493 test_range_text(range
, "ab");
3495 test_range_move(range
, characterW
, -2, -2);
3496 test_range_moveend(range
, characterW
, 2, 2);
3497 test_range_text(range
, "t ");
3499 test_range_move(range
, wordW
, 3, 3);
3500 test_range_move(range
, wordW
, -2, -2);
3501 test_range_moveend(range
, characterW
, 2, 2);
3502 test_range_text(range
, "ab");
3504 test_range_move(range
, characterW
, -6, -5);
3505 test_range_moveend(range
, characterW
, -1, 0);
3506 test_range_moveend(range
, characterW
, -6, 0);
3507 test_range_move(range
, characterW
, 2, 2);
3508 test_range_moveend(range
, characterW
, 2, 2);
3509 test_range_text(range
, "st");
3510 test_range_moveend(range
, characterW
, -6, -4);
3511 test_range_moveend(range
, characterW
, 2, 2);
3513 IHTMLTxtRange_Release(range
);
3515 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3516 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3518 test_range_move(range
, wordW
, 2, 2);
3519 test_range_moveend(range
, characterW
, 2, 2);
3520 test_range_text(range
, "12");
3522 test_range_move(range
, characterW
, 15, 14);
3523 test_range_move(range
, characterW
, -2, -2);
3524 test_range_moveend(range
, characterW
, 3, 2);
3525 test_range_text(range
, "t");
3526 test_range_moveend(range
, characterW
, -1, -1);
3527 test_range_text(range
, "t");
3528 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
3529 test_range_move(range
, characterW
, -2, -2);
3530 test_range_moveend(range
, characterW
, 2, 2);
3531 test_range_text(range
, "s ");
3532 test_range_move(range
, characterW
, 100, 7);
3533 test_range_move(range
, wordW
, 1, 0);
3534 test_range_move(range
, characterW
, -2, -2);
3535 test_range_moveend(range
, characterW
, 3, 2);
3536 test_range_text(range
, "t");
3538 IHTMLTxtRange_Release(range
);
3540 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3541 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3543 test_range_collapse(range
, TRUE
);
3544 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3545 test_range_put_text(range
, "word");
3546 test_range_text(body_range
, "wordabc 123\r\nit's text");
3547 test_range_text(range
, NULL
);
3548 test_range_moveend(range
, characterW
, 3, 3);
3549 test_range_text(range
, "abc");
3550 test_range_movestart(range
, characterW
, -2, -2);
3551 test_range_text(range
, "rdabc");
3552 test_range_movestart(range
, characterW
, 3, 3);
3553 test_range_text(range
, "bc");
3554 test_range_movestart(range
, characterW
, 4, 4);
3555 test_range_text(range
, NULL
);
3556 test_range_movestart(range
, characterW
, -3, -3);
3557 test_range_text(range
, "c 1");
3558 test_range_movestart(range
, characterW
, -7, -6);
3559 test_range_text(range
, "wordabc 1");
3560 test_range_movestart(range
, characterW
, 100, 22);
3561 test_range_text(range
, NULL
);
3563 IHTMLTxtRange_Release(range
);
3564 IHTMLTxtRange_Release(body_range
);
3566 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
3567 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
3569 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
3570 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
3571 IHTMLSelectionObject_Release(selection
);
3573 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
3574 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
3575 IDispatch_Release(disp_range
);
3577 test_range_text(range
, NULL
);
3578 test_range_moveend(range
, characterW
, 3, 3);
3579 test_range_text(range
, "wor");
3580 test_range_parent(range
, ET_BODY
);
3581 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3582 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3583 test_range_move(range
, characterW
, 3, 3);
3584 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
3585 test_range_moveend(range
, characterW
, -4, -4);
3586 test_range_put_text(range
, "abc def ");
3587 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
3588 test_range_move(range
, wordW
, 1, 1);
3589 test_range_movestart(range
, characterW
, -1, -1);
3590 test_range_text(range
, " ");
3591 test_range_move(range
, wordW
, 1, 1);
3592 test_range_moveend(range
, characterW
, 3, 3);
3593 test_range_text(range
, "def");
3594 test_range_put_text(range
, "xyz");
3595 test_range_moveend(range
, characterW
, 1, 1);
3596 test_range_move(range
, wordW
, 1, 1);
3597 test_range_moveend(range
, characterW
, 2, 2);
3598 test_range_text(range
, "ab");
3600 IHTMLTxtRange_Release(range
);
3603 static void test_txtrange2(IHTMLDocument2
*doc
)
3605 IHTMLTxtRange
*range
;
3607 range
= test_create_body_range(doc
);
3609 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3610 test_range_move(range
, characterW
, 5, 5);
3611 test_range_moveend(range
, characterW
, 1, 1);
3612 test_range_text(range
, "2");
3613 test_range_move(range
, characterW
, -3, -3);
3614 test_range_moveend(range
, characterW
, 3, 3);
3615 test_range_text(range
, "c\r\n\r\n1");
3616 test_range_collapse(range
, VARIANT_FALSE
);
3617 test_range_moveend(range
, characterW
, 4, 4);
3618 test_range_text(range
, "23");
3619 test_range_moveend(range
, characterW
, 1, 1);
3620 test_range_text(range
, "23\r\n\r\n\r\nd");
3621 test_range_moveend(range
, characterW
, -1, -1);
3622 test_range_text(range
, "23");
3623 test_range_moveend(range
, characterW
, -1, -1);
3624 test_range_text(range
, "23");
3625 test_range_moveend(range
, characterW
, -2, -2);
3626 test_range_text(range
, "2");
3628 IHTMLTxtRange_Release(range
);
3631 static void test_compatmode(IHTMLDocument2
*doc
)
3633 IHTMLDocument5
*doc5
;
3637 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3638 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
3642 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
3643 IHTMLDocument5_Release(doc5
);
3644 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
3645 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
3646 SysFreeString(mode
);
3649 static void test_location(IHTMLDocument2
*doc
)
3651 IHTMLLocation
*location
, *location2
;
3652 IHTMLWindow2
*window
;
3657 hres
= IHTMLDocument2_get_location(doc
, &location
);
3658 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3660 hres
= IHTMLDocument2_get_location(doc
, &location2
);
3661 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3663 ok(location
== location2
, "location != location2\n");
3664 IHTMLLocation_Release(location2
);
3666 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3667 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3669 hres
= IHTMLWindow2_get_location(window
, &location2
);
3670 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3671 ok(location
== location2
, "location != location2\n");
3672 IHTMLLocation_Release(location2
);
3674 test_ifaces((IUnknown
*)location
, location_iids
);
3675 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
3677 hres
= IHTMLLocation_get_pathname(location
, &str
);
3678 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
3679 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
3682 hres
= IHTMLLocation_get_href(location
, NULL
);
3683 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
3685 hres
= IHTMLLocation_get_href(location
, &str
);
3686 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
3687 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
3690 ref
= IHTMLLocation_Release(location
);
3691 ok(!ref
, "location chould be destroyed here\n");
3694 static void test_plugins_col(IOmNavigator
*nav
)
3696 IHTMLPluginsCollection
*col
, *col2
;
3700 hres
= IOmNavigator_get_plugins(nav
, &col
);
3701 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
3703 hres
= IOmNavigator_get_plugins(nav
, &col2
);
3704 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
3705 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
3706 IHTMLPluginsCollection_Release(col2
);
3708 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
3710 ref
= IHTMLPluginsCollection_Release(col
);
3711 ok(!ref
, "ref=%d\n", ref
);
3714 static void test_navigator(IHTMLDocument2
*doc
)
3716 IHTMLWindow2
*window
;
3717 IOmNavigator
*navigator
, *navigator2
;
3724 static const WCHAR v40
[] = {'4','.','0'};
3726 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3727 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
3729 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
3730 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3731 ok(navigator
!= NULL
, "navigator == NULL\n");
3732 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
3734 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
3735 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3736 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
3738 IHTMLWindow2_Release(window
);
3739 IOmNavigator_Release(navigator2
);
3741 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
3742 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
3743 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3744 SysFreeString(bstr
);
3747 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
3748 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
3749 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3750 SysFreeString(bstr
);
3753 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
3754 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
3756 ok(!strcmp_wa(bstr
, "Win64") || broken(!strcmp_wa(bstr
, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3758 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3760 SysFreeString(bstr
);
3763 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3764 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3765 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
3766 SysFreeString(bstr
);
3768 hres
= IOmNavigator_toString(navigator
, NULL
);
3769 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
3772 hres
= IOmNavigator_toString(navigator
, &bstr
);
3773 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
3774 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
3775 SysFreeString(bstr
);
3778 hres
= ObtainUserAgentString(0, buf
, &size
);
3779 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
3782 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
3783 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
3784 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
3785 SysFreeString(bstr
);
3787 if(!strncmp(buf
, "Mozilla/", 8)) {
3789 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3790 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3791 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
3792 SysFreeString(bstr
);
3794 skip("nonstandard user agent\n");
3797 test_plugins_col(navigator
);
3799 ref
= IOmNavigator_Release(navigator
);
3800 ok(!ref
, "navigator should be destroyed here\n");
3803 static void test_screen(IHTMLWindow2
*window
)
3805 IHTMLScreen
*screen
, *screen2
;
3806 IDispatchEx
*dispex
;
3812 hres
= IHTMLWindow2_get_screen(window
, &screen
);
3813 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3814 ok(screen
!= NULL
, "screen == NULL\n");
3817 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
3818 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3819 ok(screen2
!= NULL
, "screen == NULL\n");
3820 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
3821 IHTMLScreen_Release(screen2
);
3823 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
3824 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
3825 if(SUCCEEDED(hres
)) {
3826 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
3827 IDispatchEx_Release(dispex
);
3830 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
3832 exl
= GetDeviceCaps(hdc
, HORZRES
);
3834 hres
= IHTMLScreen_get_width(screen
, &l
);
3835 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3836 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
3838 exl
= GetDeviceCaps(hdc
, VERTRES
);
3840 hres
= IHTMLScreen_get_height(screen
, &l
);
3841 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3842 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3844 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
3846 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
3847 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3848 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3852 IHTMLScreen_Release(screen
);
3855 static void test_current_style(IHTMLCurrentStyle
*current_style
)
3861 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
, "[object]");
3862 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
3864 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
3865 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3866 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", wine_dbgstr_w(str
));
3869 hres
= IHTMLCurrentStyle_get_position(current_style
, &str
);
3870 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3871 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3874 hres
= IHTMLCurrentStyle_get_fontFamily(current_style
, &str
);
3875 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3878 hres
= IHTMLCurrentStyle_get_fontStyle(current_style
, &str
);
3879 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
3880 ok(!strcmp_wa(str
, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str
));
3883 hres
= IHTMLCurrentStyle_get_backgroundImage(current_style
, &str
);
3884 ok(hres
== S_OK
, "get_backgroundImage failed: %08x\n", hres
);
3885 ok(!strcmp_wa(str
, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str
));
3888 hres
= IHTMLCurrentStyle_get_fontVariant(current_style
, &str
);
3889 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3890 ok(!strcmp_wa(str
, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str
));
3893 hres
= IHTMLCurrentStyle_get_borderTopStyle(current_style
, &str
);
3894 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
3895 ok(!strcmp_wa(str
, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str
));
3898 hres
= IHTMLCurrentStyle_get_borderRightStyle(current_style
, &str
);
3899 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
3900 ok(!strcmp_wa(str
, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str
));
3903 hres
= IHTMLCurrentStyle_get_borderBottomStyle(current_style
, &str
);
3904 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
3905 ok(!strcmp_wa(str
, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str
));
3908 hres
= IHTMLCurrentStyle_get_borderLeftStyle(current_style
, &str
);
3909 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
3910 ok(!strcmp_wa(str
, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str
));
3913 hres
= IHTMLCurrentStyle_get_textAlign(current_style
, &str
);
3914 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
3915 ok(!strcmp_wa(str
, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str
));
3918 hres
= IHTMLCurrentStyle_get_textDecoration(current_style
, &str
);
3919 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3920 ok(!strcmp_wa(str
, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str
));
3923 hres
= IHTMLCurrentStyle_get_cursor(current_style
, &str
);
3924 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
3925 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
3928 hres
= IHTMLCurrentStyle_get_backgroundRepeat(current_style
, &str
);
3929 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
3930 ok(!strcmp_wa(str
, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str
));
3933 hres
= IHTMLCurrentStyle_get_borderColor(current_style
, &str
);
3934 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
3937 hres
= IHTMLCurrentStyle_get_borderStyle(current_style
, &str
);
3938 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
3941 hres
= IHTMLCurrentStyle_get_visibility(current_style
, &str
);
3942 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3945 hres
= IHTMLCurrentStyle_get_overflow(current_style
, &str
);
3946 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
3949 hres
= IHTMLCurrentStyle_get_borderWidth(current_style
, &str
);
3950 ok(hres
== S_OK
, "get_borderWidth failed: %08x\n", hres
);
3953 hres
= IHTMLCurrentStyle_get_margin(current_style
, &str
);
3954 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3957 hres
= IHTMLCurrentStyle_get_fontWeight(current_style
, &v
);
3958 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3959 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3960 ok( V_I4(&v
) == 400, "expect 400 got (%d)\n", V_I4(&v
));
3963 hres
= IHTMLCurrentStyle_get_fontSize(current_style
, &v
);
3964 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3965 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3968 hres
= IHTMLCurrentStyle_get_left(current_style
, &v
);
3969 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3970 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3973 hres
= IHTMLCurrentStyle_get_top(current_style
, &v
);
3974 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3975 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3978 hres
= IHTMLCurrentStyle_get_width(current_style
, &v
);
3979 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3980 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3983 hres
= IHTMLCurrentStyle_get_height(current_style
, &v
);
3984 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3985 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3988 hres
= IHTMLCurrentStyle_get_paddingLeft(current_style
, &v
);
3989 ok(hres
== S_OK
, "get_paddingLeft failed: %08x\n", hres
);
3990 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3993 hres
= IHTMLCurrentStyle_get_zIndex(current_style
, &v
);
3994 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
3995 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3996 ok( V_I4(&v
) == 1, "expect 1 got (%d)\n", V_I4(&v
));
3999 hres
= IHTMLCurrentStyle_get_verticalAlign(current_style
, &v
);
4000 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4001 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4002 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4005 hres
= IHTMLCurrentStyle_get_marginRight(current_style
, &v
);
4006 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
4007 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4010 hres
= IHTMLCurrentStyle_get_marginLeft(current_style
, &v
);
4011 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
4012 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4015 hres
= IHTMLCurrentStyle_get_borderLeftWidth(current_style
, &v
);
4016 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
4017 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4021 hres
= IHTMLCurrentStyle_get_borderRightWidth(current_style
, &v
);
4022 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
4023 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4026 hres
= IHTMLCurrentStyle_get_borderBottomWidth(current_style
, &v
);
4027 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
4028 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4031 hres
= IHTMLCurrentStyle_get_borderTopWidth(current_style
, &v
);
4032 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
4033 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4036 hres
= IHTMLCurrentStyle_get_color(current_style
, &v
);
4037 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
4038 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4041 hres
= IHTMLCurrentStyle_get_backgroundColor(current_style
, &v
);
4042 ok(hres
== S_OK
, "get_backgroundColor failed: %08x\n", hres
);
4043 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4046 hres
= IHTMLCurrentStyle_get_borderLeftColor(current_style
, &v
);
4047 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
4048 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4051 hres
= IHTMLCurrentStyle_get_borderTopColor(current_style
, &v
);
4052 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
4053 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4056 hres
= IHTMLCurrentStyle_get_borderRightColor(current_style
, &v
);
4057 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
4058 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4061 hres
= IHTMLCurrentStyle_get_borderBottomColor(current_style
, &v
);
4062 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
4063 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4066 hres
= IHTMLCurrentStyle_get_paddingTop(current_style
, &v
);
4067 ok(hres
== S_OK
, "get_paddingTop failed: %08x\n", hres
);
4068 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4071 hres
= IHTMLCurrentStyle_get_paddingRight(current_style
, &v
);
4072 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
4073 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4076 hres
= IHTMLCurrentStyle_get_paddingBottom(current_style
, &v
);
4077 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
4078 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4081 hres
= IHTMLCurrentStyle_get_letterSpacing(current_style
, &v
);
4082 ok(hres
== S_OK
, "get_letterSpacing failed: %08x\n", hres
);
4083 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4086 hres
= IHTMLCurrentStyle_get_marginTop(current_style
, &v
);
4087 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4088 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4091 hres
= IHTMLCurrentStyle_get_marginBottom(current_style
, &v
);
4092 ok(hres
== S_OK
, "get_marginBottom failed: %08x\n", hres
);
4093 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4096 hres
= IHTMLCurrentStyle_get_right(current_style
, &v
);
4097 ok(hres
== S_OK
, "get_Right failed: %08x\n", hres
);
4098 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4101 hres
= IHTMLCurrentStyle_get_bottom(current_style
, &v
);
4102 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4103 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4106 hres
= IHTMLCurrentStyle_get_lineHeight(current_style
, &v
);
4107 ok(hres
== S_OK
, "get_lineHeight failed: %08x\n", hres
);
4108 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4111 hres
= IHTMLCurrentStyle_get_textIndent(current_style
, &v
);
4112 ok(hres
== S_OK
, "get_textIndent failed: %08x\n", hres
);
4113 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4117 static void test_style2(IHTMLStyle2
*style2
)
4123 str
= (void*)0xdeadbeef;
4124 hres
= IHTMLStyle2_get_position(style2
, &str
);
4125 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
4126 ok(!str
, "str != NULL\n");
4128 str
= a2bstr("absolute");
4129 hres
= IHTMLStyle2_put_position(style2
, str
);
4130 ok(hres
== S_OK
, "put_position failed: %08x\n", hres
);
4134 hres
= IHTMLStyle2_get_position(style2
, &str
);
4135 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
4136 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
4140 V_VT(&v
) = VT_EMPTY
;
4141 hres
= IHTMLStyle2_get_right(style2
, &v
);
4142 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4143 ok(V_VT(&v
) == VT_BSTR
, "V_VT(right)=%d\n", V_VT(&v
));
4144 ok(!V_BSTR(&v
), "V_BSTR(right) != NULL\n");
4148 V_BSTR(&v
) = a2bstr("3px");
4149 hres
= IHTMLStyle2_put_right(style2
, v
);
4150 ok(hres
== S_OK
, "put_right failed: %08x\n", hres
);
4153 V_VT(&v
) = VT_EMPTY
;
4154 hres
= IHTMLStyle2_get_right(style2
, &v
);
4155 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4156 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4157 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4161 static void test_style3(IHTMLStyle3
*style3
)
4166 str
= (void*)0xdeadbeef;
4167 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
4168 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
4169 ok(!str
, "str != NULL\n");
4171 str
= a2bstr("break-word");
4172 hres
= IHTMLStyle3_put_wordWrap(style3
, str
);
4173 ok(hres
== S_OK
, "put_wordWrap failed: %08x\n", hres
);
4177 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
4178 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
4179 ok(!strcmp_wa(str
, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str
));
4183 static void test_style4(IHTMLStyle4
*style4
)
4189 hres
= IHTMLStyle4_get_minHeight(style4
, &vdefault
);
4190 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
4193 V_BSTR(&v
) = a2bstr("10px");
4194 hres
= IHTMLStyle4_put_minHeight(style4
, v
);
4195 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
4198 hres
= IHTMLStyle4_get_minHeight(style4
, &v
);
4199 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
4200 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
4201 ok( !strcmp_wa(V_BSTR(&v
), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4204 hres
= IHTMLStyle4_put_minHeight(style4
, vdefault
);
4205 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
4206 VariantClear(&vdefault
);
4209 static void test_default_style(IHTMLStyle
*style
)
4211 IHTMLStyle2
*style2
;
4212 IHTMLStyle3
*style3
;
4213 IHTMLStyle4
*style4
;
4219 BSTR sOverflowDefault
;
4223 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
4224 test_ifaces((IUnknown
*)style
, style_iids
);
4226 test_style_csstext(style
, NULL
);
4228 hres
= IHTMLStyle_get_position(style
, &str
);
4229 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
4230 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4233 hres
= IHTMLStyle_get_marginRight(style
, &v
);
4234 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
4235 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginRight) = %d\n", V_VT(&v
));
4236 ok(!V_BSTR(&v
), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4239 hres
= IHTMLStyle_get_marginLeft(style
, &v
);
4240 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
4241 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginLeft) = %d\n", V_VT(&v
));
4242 ok(!V_BSTR(&v
), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4244 str
= (void*)0xdeadbeef;
4245 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
4246 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
4247 ok(!str
, "fontFamily = %s\n", wine_dbgstr_w(str
));
4249 str
= (void*)0xdeadbeef;
4250 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
4251 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
4252 ok(!str
, "fontWeight = %s\n", wine_dbgstr_w(str
));
4254 hres
= IHTMLStyle_get_fontWeight(style
, &sDefault
);
4255 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
4257 str
= a2bstr("test");
4258 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4259 ok(hres
== E_INVALIDARG
, "put_fontWeight failed: %08x\n", hres
);
4262 str
= a2bstr("bold");
4263 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4264 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4267 str
= a2bstr("bolder");
4268 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4269 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4272 str
= a2bstr("lighter");
4273 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4274 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4277 str
= a2bstr("100");
4278 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4279 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4282 str
= a2bstr("200");
4283 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4284 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4287 str
= a2bstr("300");
4288 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4289 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4292 str
= a2bstr("400");
4293 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4294 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4297 str
= a2bstr("500");
4298 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4299 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4302 str
= a2bstr("600");
4303 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4304 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4307 str
= a2bstr("700");
4308 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4309 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4312 str
= a2bstr("800");
4313 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4314 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4317 str
= a2bstr("900");
4318 hres
= IHTMLStyle_put_fontWeight(style
, str
);
4319 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4322 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
4323 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
4324 ok(!strcmp_wa(str
, "900"), "str != style900\n");
4327 hres
= IHTMLStyle_put_fontWeight(style
, sDefault
);
4328 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
4329 SysFreeString(sDefault
);
4332 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
4333 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
4335 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
4336 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
4338 str
= a2bstr("test");
4339 hres
= IHTMLStyle_put_fontVariant(style
, str
);
4340 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
4343 str
= a2bstr("small-caps");
4344 hres
= IHTMLStyle_put_fontVariant(style
, str
);
4345 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
4348 str
= a2bstr("normal");
4349 hres
= IHTMLStyle_put_fontVariant(style
, str
);
4350 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
4353 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
4354 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
4355 SysFreeString(sDefault
);
4357 str
= (void*)0xdeadbeef;
4358 hres
= IHTMLStyle_get_display(style
, &str
);
4359 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
4360 ok(!str
, "display = %s\n", wine_dbgstr_w(str
));
4362 str
= (void*)0xdeadbeef;
4363 hres
= IHTMLStyle_get_visibility(style
, &str
);
4364 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
4365 ok(!str
, "visibility = %s\n", wine_dbgstr_w(str
));
4368 hres
= IHTMLStyle_get_fontSize(style
, &v
);
4369 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
4370 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
4371 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4374 hres
= IHTMLStyle_get_color(style
, &v
);
4375 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
4376 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
4377 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4380 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
4381 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
4382 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
4384 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_TRUE
);
4385 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
4386 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
4388 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
4389 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
4390 ok(b
== VARIANT_TRUE
, "textDecorationUnderline = %x\n", b
);
4392 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_FALSE
);
4393 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
4396 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
4397 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
4398 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
4400 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_TRUE
);
4401 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
4402 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
4404 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
4405 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
4406 ok(b
== VARIANT_TRUE
, "textDecorationLineThrough = %x\n", b
);
4408 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_FALSE
);
4409 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
4412 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
4413 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
4414 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
4416 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_TRUE
);
4417 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
4418 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
4420 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
4421 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
4422 ok(b
== VARIANT_TRUE
, "textDecorationNone = %x\n", b
);
4424 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_FALSE
);
4425 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
4428 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
4429 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
4430 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
4432 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_TRUE
);
4433 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
4434 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
4436 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
4437 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
4438 ok(b
== VARIANT_TRUE
, "textDecorationOverline = %x\n", b
);
4440 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_FALSE
);
4441 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
4444 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
4445 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
4446 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
4448 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_TRUE
);
4449 ok(hres
== S_OK
, "put_textDecorationBlink failed: %08x\n", hres
);
4450 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
4452 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
4453 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
4454 ok(b
== VARIANT_TRUE
, "textDecorationBlink = %x\n", b
);
4456 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_FALSE
);
4457 ok(hres
== S_OK
, "textDecorationBlink failed: %08x\n", hres
);
4459 hres
= IHTMLStyle_get_textDecoration(style
, &sDefault
);
4460 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
4462 str
= a2bstr("invalid");
4463 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4464 ok(hres
== E_INVALIDARG
, "put_textDecoration failed: %08x\n", hres
);
4467 str
= a2bstr("none");
4468 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4469 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4472 str
= a2bstr("underline");
4473 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4474 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4477 str
= a2bstr("overline");
4478 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4479 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4482 str
= a2bstr("line-through");
4483 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4484 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4487 str
= a2bstr("blink");
4488 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4489 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4492 hres
= IHTMLStyle_get_textDecoration(style
, &str
);
4493 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
4494 ok(!strcmp_wa(str
, "blink"), "str != blink\n");
4497 hres
= IHTMLStyle_put_textDecoration(style
, sDefault
);
4498 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4499 SysFreeString(sDefault
);
4501 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
4502 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
4504 hres
= IHTMLStyle_get_posWidth(style
, &f
);
4505 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
4506 ok(f
== 0.0f
, "f = %f\n", f
);
4508 V_VT(&v
) = VT_EMPTY
;
4509 hres
= IHTMLStyle_get_width(style
, &v
);
4510 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4511 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4512 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
4514 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
4515 ok(hres
== S_OK
, "put_posWidth failed: %08x\n", hres
);
4517 hres
= IHTMLStyle_get_posWidth(style
, &f
);
4518 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
4520 f
== 2.2f
, /* IE8 */
4524 V_BSTR(&v
) = a2bstr("auto");
4525 hres
= IHTMLStyle_put_width(style
, v
);
4526 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4529 V_VT(&v
) = VT_EMPTY
;
4530 hres
= IHTMLStyle_get_width(style
, &v
);
4531 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4532 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4533 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4538 hres
= IHTMLStyle_put_width(style
, v
);
4539 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4541 V_VT(&v
) = VT_EMPTY
;
4542 hres
= IHTMLStyle_get_width(style
, &v
);
4543 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4544 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4545 ok(!strcmp_wa(V_BSTR(&v
), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4549 str
= (void*)0xdeadbeef;
4550 hres
= IHTMLStyle_get_margin(style
, &str
);
4551 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4552 ok(!str
, "margin = %s\n", wine_dbgstr_w(str
));
4555 hres
= IHTMLStyle_put_margin(style
, str
);
4556 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4559 hres
= IHTMLStyle_get_margin(style
, &str
);
4560 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4561 ok(!strcmp_wa(str
, "1px"), "margin = %s\n", wine_dbgstr_w(str
));
4564 hres
= IHTMLStyle_put_margin(style
, NULL
);
4565 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4567 str
= (void*)0xdeadbeef;
4568 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4569 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4570 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4571 ok(!V_BSTR(&v
), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4574 V_BSTR(&v
) = a2bstr("6px");
4575 hres
= IHTMLStyle_put_marginTop(style
, v
);
4576 SysFreeString(V_BSTR(&v
));
4577 ok(hres
== S_OK
, "put_marginTop failed: %08x\n", hres
);
4579 str
= (void*)0xdeadbeef;
4580 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4581 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4582 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4583 ok(!strcmp_wa(V_BSTR(&v
), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4587 hres
= IHTMLStyle_get_border(style
, &str
);
4588 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
4589 ok(!str
|| !*str
, "str is not empty\n");
4592 str
= a2bstr("1px");
4593 hres
= IHTMLStyle_put_border(style
, str
);
4594 ok(hres
== S_OK
, "put_border failed: %08x\n", hres
);
4597 V_VT(&v
) = VT_EMPTY
;
4598 hres
= IHTMLStyle_get_left(style
, &v
);
4599 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4600 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4601 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4605 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
4606 ok(hres
== E_POINTER
, "get_posLeft failed: %08x\n", hres
);
4609 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4610 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4611 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4613 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
4614 ok(hres
== S_OK
, "put_posLeft failed: %08x\n", hres
);
4616 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4617 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4619 f
== 4.9f
, /* IE8 */
4620 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4622 /* Ensure left is updated correctly. */
4623 V_VT(&v
) = VT_EMPTY
;
4624 hres
= IHTMLStyle_get_left(style
, &v
);
4625 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4626 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4627 ok(!strcmp_wa(V_BSTR(&v
), "4px") ||
4628 !strcmp_wa(V_BSTR(&v
), "4.9px"), /* IE8 */
4629 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4634 V_BSTR(&v
) = a2bstr("3px");
4635 hres
= IHTMLStyle_put_left(style
, v
);
4636 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4639 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4640 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4641 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4643 V_VT(&v
) = VT_EMPTY
;
4644 hres
= IHTMLStyle_get_left(style
, &v
);
4645 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4646 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4647 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4651 hres
= IHTMLStyle_put_left(style
, v
);
4652 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4654 V_VT(&v
) = VT_EMPTY
;
4655 hres
= IHTMLStyle_get_left(style
, &v
);
4656 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4657 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4658 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4661 V_VT(&v
) = VT_EMPTY
;
4662 hres
= IHTMLStyle_get_top(style
, &v
);
4663 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4664 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4665 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4669 hres
= IHTMLStyle_get_posTop(style
, NULL
);
4670 ok(hres
== E_POINTER
, "get_posTop failed: %08x\n", hres
);
4673 hres
= IHTMLStyle_get_posTop(style
, &f
);
4674 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4675 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4677 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
4678 ok(hres
== S_OK
, "put_posTop failed: %08x\n", hres
);
4680 hres
= IHTMLStyle_get_posTop(style
, &f
);
4681 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4683 f
== 4.9f
, /* IE8 */
4684 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4687 V_BSTR(&v
) = a2bstr("3px");
4688 hres
= IHTMLStyle_put_top(style
, v
);
4689 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4692 V_VT(&v
) = VT_EMPTY
;
4693 hres
= IHTMLStyle_get_top(style
, &v
);
4694 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4695 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4696 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4699 hres
= IHTMLStyle_get_posTop(style
, &f
);
4700 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4701 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4704 hres
= IHTMLStyle_put_top(style
, v
);
4705 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4707 V_VT(&v
) = VT_EMPTY
;
4708 hres
= IHTMLStyle_get_top(style
, &v
);
4709 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4710 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4711 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4714 /* Test posHeight */
4715 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
4716 ok(hres
== E_POINTER
, "get_posHeight failed: %08x\n", hres
);
4718 V_VT(&v
) = VT_EMPTY
;
4719 hres
= IHTMLStyle_get_height(style
, &v
);
4720 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4721 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4722 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4726 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4727 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4728 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4730 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
4731 ok(hres
== S_OK
, "put_posHeight failed: %08x\n", hres
);
4733 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4734 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4736 f
== 4.9f
, /* IE8 */
4737 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4740 V_BSTR(&v
) = a2bstr("64px");
4741 hres
= IHTMLStyle_put_height(style
, v
);
4742 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
4745 V_VT(&v
) = VT_EMPTY
;
4746 hres
= IHTMLStyle_get_height(style
, &v
);
4747 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4748 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4749 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4752 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4753 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4754 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
4756 str
= (void*)0xdeadbeef;
4757 hres
= IHTMLStyle_get_cursor(style
, &str
);
4758 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4759 ok(!str
, "get_cursor != NULL\n");
4762 str
= a2bstr("default");
4763 hres
= IHTMLStyle_put_cursor(style
, str
);
4764 ok(hres
== S_OK
, "put_cursor failed: %08x\n", hres
);
4768 hres
= IHTMLStyle_get_cursor(style
, &str
);
4769 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4770 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
4773 V_VT(&v
) = VT_EMPTY
;
4774 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4775 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
4776 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4777 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4781 V_BSTR(&v
) = a2bstr("middle");
4782 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
4783 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
4786 V_VT(&v
) = VT_EMPTY
;
4787 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4788 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4789 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4790 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4793 str
= (void*)0xdeadbeef;
4794 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4795 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4796 ok(!str
, "textAlign != NULL\n");
4798 str
= a2bstr("center");
4799 hres
= IHTMLStyle_put_textAlign(style
, str
);
4800 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
4804 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4805 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4806 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4809 str
= (void*)0xdeadbeef;
4810 hres
= IHTMLStyle_get_filter(style
, &str
);
4811 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
4812 ok(!str
, "filter != NULL\n");
4814 str
= a2bstr("alpha(opacity=100)");
4815 hres
= IHTMLStyle_put_filter(style
, str
);
4816 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
4819 V_VT(&v
) = VT_EMPTY
;
4820 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4821 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4822 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4823 ok(!V_I4(&v
), "V_I4(v) != 0\n");
4827 V_BSTR(&v
) = a2bstr("1");
4828 hres
= IHTMLStyle_put_zIndex(style
, v
);
4829 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
4832 V_VT(&v
) = VT_EMPTY
;
4833 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4834 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4835 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4836 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
4840 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
4841 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
4843 str
= a2bstr("test");
4844 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4845 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
4848 str
= a2bstr("italic");
4849 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4850 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4853 str
= a2bstr("oblique");
4854 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4855 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4858 str
= a2bstr("normal");
4859 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4860 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4863 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
4864 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4865 SysFreeString(sDefault
);
4868 hres
= IHTMLStyle_get_overflow(style
, NULL
);
4869 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
4871 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
4872 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4874 str
= a2bstr("test");
4875 hres
= IHTMLStyle_put_overflow(style
, str
);
4876 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
4879 str
= a2bstr("visible");
4880 hres
= IHTMLStyle_put_overflow(style
, str
);
4881 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4884 str
= a2bstr("scroll");
4885 hres
= IHTMLStyle_put_overflow(style
, str
);
4886 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4889 str
= a2bstr("hidden");
4890 hres
= IHTMLStyle_put_overflow(style
, str
);
4891 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4894 str
= a2bstr("auto");
4895 hres
= IHTMLStyle_put_overflow(style
, str
);
4896 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4899 hres
= IHTMLStyle_get_overflow(style
, &str
);
4900 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4901 ok(!strcmp_wa(str
, "auto"), "str=%s\n", wine_dbgstr_w(str
));
4905 hres
= IHTMLStyle_put_overflow(style
, str
);
4906 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4909 hres
= IHTMLStyle_get_overflow(style
, &str
);
4910 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4911 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4914 /* restore overflow default */
4915 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
4916 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4917 SysFreeString(sOverflowDefault
);
4919 /* Attribute Tests*/
4920 hres
= IHTMLStyle_getAttribute(style
, NULL
, 1, &v
);
4921 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4923 str
= a2bstr("position");
4924 hres
= IHTMLStyle_getAttribute(style
, str
, 1, NULL
);
4925 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4927 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4928 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4929 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4932 hres
= IHTMLStyle_setAttribute(style
, NULL
, v
, 1);
4933 ok(hres
== E_INVALIDARG
, "setAttribute failed: %08x\n", hres
);
4936 V_BSTR(&v
) = a2bstr("absolute");
4937 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4938 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4941 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4942 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4943 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4944 ok(!strcmp_wa(V_BSTR(&v
), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4949 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4950 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4955 str
= a2bstr("borderLeftStyle");
4956 test_border_styles(style
, str
);
4959 str
= a2bstr("borderbottomstyle");
4960 test_border_styles(style
, str
);
4963 str
= a2bstr("borderrightstyle");
4964 test_border_styles(style
, str
);
4967 str
= a2bstr("bordertopstyle");
4968 test_border_styles(style
, str
);
4971 hres
= IHTMLStyle_get_borderStyle(style
, &sDefault
);
4972 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4974 str
= a2bstr("none dotted dashed solid");
4975 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4976 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4979 str
= a2bstr("none dotted dashed solid");
4980 hres
= IHTMLStyle_get_borderStyle(style
, &str
);
4981 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4982 ok(!strcmp_wa(str
, "none dotted dashed solid"),
4983 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4986 str
= a2bstr("double groove ridge inset");
4987 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4988 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4991 str
= a2bstr("window-inset outset ridge inset");
4992 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4993 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4996 str
= a2bstr("window-inset");
4997 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4998 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
5001 str
= a2bstr("none none none none none");
5002 hres
= IHTMLStyle_put_borderStyle(style
, str
);
5003 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
5006 str
= a2bstr("invalid none none none");
5007 hres
= IHTMLStyle_put_borderStyle(style
, str
);
5008 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
5011 str
= a2bstr("none invalid none none");
5012 hres
= IHTMLStyle_put_borderStyle(style
, str
);
5013 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
5016 hres
= IHTMLStyle_put_borderStyle(style
, sDefault
);
5017 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
5018 SysFreeString(sDefault
);
5020 /* backgoundColor */
5021 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
5022 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
5023 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
5024 ok(!V_BSTR(&v
), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5028 hres
= IHTMLStyle_get_padding(style
, &str
);
5029 ok(hres
== S_OK
, "get_padding failed: %08x\n", hres
);
5030 ok(!str
, "padding = %s\n", wine_dbgstr_w(str
));
5034 hres
= IHTMLStyle_put_padding(style
, str
);
5035 ok(hres
== S_OK
, "put_padding failed: %08x\n", hres
);
5038 hres
= IHTMLStyle_get_padding(style
, &str
);
5039 ok(hres
== S_OK
, "get_padding failed: %08x\n", hres
);
5040 ok(!strcmp_wa(str
, "1px"), "padding = %s\n", wine_dbgstr_w(str
));
5044 hres
= IHTMLStyle_get_paddingLeft(style
, &vDefault
);
5045 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
5048 V_BSTR(&v
) = a2bstr("10");
5049 hres
= IHTMLStyle_put_paddingLeft(style
, v
);
5050 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
5053 hres
= IHTMLStyle_get_paddingLeft(style
, &v
);
5054 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
5055 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5058 hres
= IHTMLStyle_put_paddingLeft(style
, vDefault
);
5059 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
5061 /* BackgroundRepeat */
5062 hres
= IHTMLStyle_get_backgroundRepeat(style
, &sDefault
);
5063 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
5065 str
= a2bstr("invalid");
5066 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
5067 ok(hres
== E_INVALIDARG
, "put_backgroundRepeat failed: %08x\n", hres
);
5070 str
= a2bstr("repeat");
5071 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
5072 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
5075 str
= a2bstr("no-repeat");
5076 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
5077 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
5080 str
= a2bstr("repeat-x");
5081 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
5082 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
5085 str
= a2bstr("repeat-y");
5086 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
5087 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
5090 hres
= IHTMLStyle_get_backgroundRepeat(style
, &str
);
5091 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
5092 ok(!strcmp_wa(str
, "repeat-y"), "str=%s\n", wine_dbgstr_w(str
));
5095 hres
= IHTMLStyle_put_backgroundRepeat(style
, sDefault
);
5096 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
5097 SysFreeString(sDefault
);
5100 hres
= IHTMLStyle_get_borderColor(style
, &sDefault
);
5101 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
5103 str
= a2bstr("red green red blue");
5104 hres
= IHTMLStyle_put_borderColor(style
, str
);
5105 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
5108 hres
= IHTMLStyle_get_borderColor(style
, &str
);
5109 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
5110 ok(!strcmp_wa(str
, "red green red blue"), "str=%s\n", wine_dbgstr_w(str
));
5113 hres
= IHTMLStyle_put_borderColor(style
, sDefault
);
5114 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
5115 SysFreeString(sDefault
);
5118 hres
= IHTMLStyle_get_borderRight(style
, &sDefault
);
5119 ok(hres
== S_OK
, "get_borderRight failed: %08x\n", hres
);
5121 str
= a2bstr("thick dotted red");
5122 hres
= IHTMLStyle_put_borderRight(style
, str
);
5123 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
5126 /* IHTMLStyle_get_borderRight appears to have a bug where
5127 it returns the first letter of the color. So we check
5128 each style individually.
5131 hres
= IHTMLStyle_get_borderRightColor(style
, &v
);
5132 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
5133 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5137 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
5138 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
5139 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5142 hres
= IHTMLStyle_get_borderRightStyle(style
, &str
);
5143 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
5144 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
5147 hres
= IHTMLStyle_put_borderRight(style
, sDefault
);
5148 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
5149 SysFreeString(sDefault
);
5152 hres
= IHTMLStyle_get_borderTop(style
, &sDefault
);
5153 ok(hres
== S_OK
, "get_borderTop failed: %08x\n", hres
);
5155 str
= a2bstr("thick dotted red");
5156 hres
= IHTMLStyle_put_borderTop(style
, str
);
5157 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
5160 /* IHTMLStyle_get_borderTop appears to have a bug where
5161 it returns the first letter of the color. So we check
5162 each style individually.
5165 hres
= IHTMLStyle_get_borderTopColor(style
, &v
);
5166 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
5167 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5171 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
5172 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
5173 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5176 hres
= IHTMLStyle_get_borderTopStyle(style
, &str
);
5177 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
5178 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
5181 hres
= IHTMLStyle_put_borderTop(style
, sDefault
);
5182 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
5183 SysFreeString(sDefault
);
5186 hres
= IHTMLStyle_get_borderBottom(style
, &sDefault
);
5187 ok(hres
== S_OK
, "get_borderBottom failed: %08x\n", hres
);
5189 str
= a2bstr("thick dotted red");
5190 hres
= IHTMLStyle_put_borderBottom(style
, str
);
5191 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
5194 /* IHTMLStyle_get_borderBottom appears to have a bug where
5195 it returns the first letter of the color. So we check
5196 each style individually.
5199 hres
= IHTMLStyle_get_borderBottomColor(style
, &v
);
5200 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
5201 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5205 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
5206 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
5207 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5210 hres
= IHTMLStyle_get_borderBottomStyle(style
, &str
);
5211 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
5212 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
5215 hres
= IHTMLStyle_put_borderBottom(style
, sDefault
);
5216 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
5217 SysFreeString(sDefault
);
5220 hres
= IHTMLStyle_get_borderLeft(style
, &sDefault
);
5221 ok(hres
== S_OK
, "get_borderLeft failed: %08x\n", hres
);
5223 str
= a2bstr("thick dotted red");
5224 hres
= IHTMLStyle_put_borderLeft(style
, str
);
5225 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
5228 /* IHTMLStyle_get_borderLeft appears to have a bug where
5229 it returns the first letter of the color. So we check
5230 each style individually.
5233 hres
= IHTMLStyle_get_borderLeftColor(style
, &v
);
5234 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
5235 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5239 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
5240 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
5241 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5244 hres
= IHTMLStyle_get_borderLeftStyle(style
, &str
);
5245 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
5246 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
5249 hres
= IHTMLStyle_put_borderLeft(style
, sDefault
);
5250 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
5251 SysFreeString(sDefault
);
5253 /* backgroundPositionX */
5254 hres
= IHTMLStyle_get_backgroundPositionX(style
, &vDefault
);
5255 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
5258 V_BSTR(&v
) = a2bstr("10px");
5259 hres
= IHTMLStyle_put_backgroundPositionX(style
, v
);
5260 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
5263 hres
= IHTMLStyle_get_backgroundPositionX(style
, &v
);
5264 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
5265 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
5268 hres
= IHTMLStyle_put_backgroundPositionX(style
, vDefault
);
5269 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
5270 VariantClear(&vDefault
);
5272 /* backgroundPositionY */
5273 hres
= IHTMLStyle_get_backgroundPositionY(style
, &vDefault
);
5274 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
5277 V_BSTR(&v
) = a2bstr("10px");
5278 hres
= IHTMLStyle_put_backgroundPositionY(style
, v
);
5279 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
5282 hres
= IHTMLStyle_get_backgroundPositionY(style
, &v
);
5283 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
5284 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
5287 hres
= IHTMLStyle_put_backgroundPositionY(style
, vDefault
);
5288 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
5289 VariantClear(&vDefault
);
5291 /* borderTopWidth */
5292 hres
= IHTMLStyle_get_borderTopWidth(style
, &vDefault
);
5293 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
5296 V_BSTR(&v
) = a2bstr("10px");
5297 hres
= IHTMLStyle_put_borderTopWidth(style
, v
);
5298 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
5301 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
5302 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
5303 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5306 hres
= IHTMLStyle_put_borderTopWidth(style
, vDefault
);
5307 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
5308 VariantClear(&vDefault
);
5310 /* borderRightWidth */
5311 hres
= IHTMLStyle_get_borderRightWidth(style
, &vDefault
);
5312 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
5315 V_BSTR(&v
) = a2bstr("10");
5316 hres
= IHTMLStyle_put_borderRightWidth(style
, v
);
5317 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
5320 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
5321 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
5322 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5325 hres
= IHTMLStyle_put_borderRightWidth(style
, vDefault
);
5326 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
5327 VariantClear(&vDefault
);
5329 /* borderBottomWidth */
5330 hres
= IHTMLStyle_get_borderBottomWidth(style
, &vDefault
);
5331 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
5334 V_BSTR(&v
) = a2bstr("10");
5335 hres
= IHTMLStyle_put_borderBottomWidth(style
, v
);
5336 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
5339 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
5340 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
5341 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5344 hres
= IHTMLStyle_put_borderBottomWidth(style
, vDefault
);
5345 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
5346 VariantClear(&vDefault
);
5348 /* borderLeftWidth */
5349 hres
= IHTMLStyle_get_borderLeftWidth(style
, &vDefault
);
5350 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
5353 V_BSTR(&v
) = a2bstr("10");
5354 hres
= IHTMLStyle_put_borderLeftWidth(style
, v
);
5355 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
5358 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
5359 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
5360 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5363 hres
= IHTMLStyle_put_borderLeftWidth(style
, vDefault
);
5364 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
5365 VariantClear(&vDefault
);
5368 hres
= IHTMLStyle_get_wordSpacing(style
, &vDefault
);
5369 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
5372 V_BSTR(&v
) = a2bstr("10");
5373 hres
= IHTMLStyle_put_wordSpacing(style
, v
);
5374 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
5377 hres
= IHTMLStyle_get_wordSpacing(style
, &v
);
5378 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
5379 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
5380 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5383 hres
= IHTMLStyle_put_wordSpacing(style
, vDefault
);
5384 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
5385 VariantClear(&vDefault
);
5388 hres
= IHTMLStyle_get_letterSpacing(style
, &vDefault
);
5389 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
5392 V_BSTR(&v
) = a2bstr("11");
5393 hres
= IHTMLStyle_put_letterSpacing(style
, v
);
5394 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
5397 hres
= IHTMLStyle_get_letterSpacing(style
, &v
);
5398 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
5399 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
5400 ok(!strcmp_wa(V_BSTR(&v
), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
5403 hres
= IHTMLStyle_put_letterSpacing(style
, vDefault
);
5404 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
5405 VariantClear(&vDefault
);
5407 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
5408 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
5409 if(SUCCEEDED(hres
)) {
5410 test_style2(style2
);
5411 IHTMLStyle2_Release(style2
);
5414 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle3
, (void**)&style3
);
5415 ok(hres
== S_OK
, "Could not get IHTMLStyle3 iface: %08x\n", hres
);
5416 if(SUCCEEDED(hres
)) {
5417 test_style3(style3
);
5418 IHTMLStyle3_Release(style3
);
5421 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle4
, (void**)&style4
);
5422 ok(hres
== S_OK
, "Could not get IHTMLStyle4 iface: %08x\n", hres
);
5423 if(SUCCEEDED(hres
)) {
5424 test_style4(style4
);
5425 IHTMLStyle4_Release(style4
);
5429 static void test_set_csstext(IHTMLStyle
*style
)
5434 test_style_set_csstext(style
, "background-color: black;");
5436 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
5437 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
5438 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
5439 ok(!strcmp_wa(V_BSTR(&v
), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5443 static void test_default_selection(IHTMLDocument2
*doc
)
5445 IHTMLSelectionObject
*selection
;
5446 IHTMLTxtRange
*range
;
5451 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5452 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5454 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5455 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5456 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
5459 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
5460 IHTMLSelectionObject_Release(selection
);
5461 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
5463 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
5464 IDispatch_Release(disp
);
5465 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
5467 test_range_text(range
, NULL
);
5468 IHTMLTxtRange_Release(range
);
5471 static void test_doc_elem(IHTMLDocument2
*doc
)
5473 IHTMLDocument2
*doc_node
, *owner_doc
;
5475 IHTMLDocument3
*doc3
;
5478 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5479 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
5481 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
5482 IHTMLDocument3_Release(doc3
);
5483 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
5485 test_node_name((IUnknown
*)elem
, "HTML");
5486 test_elem_tag((IUnknown
*)elem
, "HTML");
5488 doc_node
= get_doc_node(doc
);
5489 owner_doc
= get_owner_doc((IUnknown
*)elem
);
5490 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
5491 IHTMLDocument2_Release(owner_doc
);
5493 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
5494 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5495 IHTMLDocument2_Release(doc_node
);
5497 test_elem_client_rect((IUnknown
*)elem
);
5499 IHTMLElement_Release(elem
);
5502 static void test_default_body(IHTMLBodyElement
*body
)
5509 bstr
= (void*)0xdeadbeef;
5510 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
5511 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
5512 ok(bstr
== NULL
, "bstr != NULL\n");
5514 l
= elem_get_scroll_height((IUnknown
*)body
);
5515 ok(l
!= -1, "scrollHeight == -1\n");
5516 l
= elem_get_scroll_width((IUnknown
*)body
);
5517 ok(l
!= -1, "scrollWidth == -1\n");
5518 l
= elem_get_scroll_top((IUnknown
*)body
);
5519 ok(!l
, "scrollTop = %d\n", l
);
5520 elem_get_scroll_left((IUnknown
*)body
);
5522 /* get_text tests */
5523 hres
= IHTMLBodyElement_get_text(body
, &v
);
5524 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5525 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5526 ok(bstr
== NULL
, "bstr != NULL\n");
5528 /* get_text - Invalid Text */
5530 V_BSTR(&v
) = a2bstr("Invalid");
5531 hres
= IHTMLBodyElement_put_text(body
, v
);
5532 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5536 hres
= IHTMLBodyElement_get_text(body
, &v
);
5537 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5538 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5539 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
5542 /* get_text - Valid Text */
5544 V_BSTR(&v
) = a2bstr("#FF0000");
5545 hres
= IHTMLBodyElement_put_text(body
, v
);
5546 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5550 hres
= IHTMLBodyElement_get_text(body
, &v
);
5551 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5552 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5553 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
5557 static void test_body_funs(IHTMLBodyElement
*body
)
5559 VARIANT vbg
, vDefaultbg
;
5562 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5563 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5564 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5565 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5567 V_VT(&vbg
) = VT_BSTR
;
5568 V_BSTR(&vbg
) = a2bstr("red");
5569 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5570 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5573 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5574 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5575 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
5576 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5579 /* Restore Originial */
5580 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5581 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5582 VariantClear(&vDefaultbg
);
5585 static void test_window(IHTMLDocument2
*doc
)
5587 IHTMLWindow2
*window
, *window2
, *self
;
5588 IHTMLDocument2
*doc2
= NULL
;
5594 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5595 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5596 test_ifaces((IUnknown
*)window
, window_iids
);
5597 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5599 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5600 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5601 ok(doc2
!= NULL
, "doc2 == NULL\n");
5603 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5604 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5606 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5607 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5609 unk
= (void*)0xdeadbeef;
5610 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5611 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5612 ok(!unk
, "unk = %p\n", unk
);
5614 IHTMLDocument_Release(doc2
);
5616 hres
= IHTMLWindow2_get_window(window
, &window2
);
5617 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5618 ok(window2
!= NULL
, "window2 == NULL\n");
5620 hres
= IHTMLWindow2_get_self(window
, &self
);
5621 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5622 ok(window2
!= NULL
, "self == NULL\n");
5624 ok(self
== window2
, "self != window2\n");
5626 IHTMLWindow2_Release(window2
);
5627 IHTMLWindow2_Release(self
);
5630 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5631 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5632 ok(disp
== (void*)window
, "disp != window\n");
5633 IDispatch_Release(disp
);
5635 hres
= IHTMLWindow2_toString(window
, NULL
);
5636 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5639 hres
= IHTMLWindow2_toString(window
, &str
);
5640 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5641 ok(!strcmp_wa(str
, "[object]"), "toString returned %s\n", wine_dbgstr_w(str
));
5644 test_window_name(window
, NULL
);
5645 set_window_name(window
, "test");
5646 test_window_length(window
, 0);
5647 test_screen(window
);
5649 IHTMLWindow2_Release(window
);
5652 static void test_defaults(IHTMLDocument2
*doc
)
5654 IHTMLStyleSheetsCollection
*stylesheetcol
;
5655 IHTMLCurrentStyle
*cstyle
;
5656 IHTMLBodyElement
*body
;
5657 IHTMLElement2
*elem2
;
5662 IHTMLElementCollection
*collection
;
5664 elem
= doc_get_body(doc
);
5666 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5667 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5669 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5670 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5673 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5674 IHTMLElementCollection_Release(collection
);
5677 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5678 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5680 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5681 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5684 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5685 IHTMLElementCollection_Release(collection
);
5688 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5689 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5691 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5692 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5695 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5696 IHTMLElementCollection_Release(collection
);
5699 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5700 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5702 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5703 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5706 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5707 IHTMLElementCollection_Release(collection
);
5710 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5711 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5713 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5714 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5717 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5718 IHTMLElementCollection_Release(collection
);
5721 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5722 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5723 test_default_body(body
);
5724 test_body_funs(body
);
5725 IHTMLBodyElement_Release(body
);
5727 hres
= IHTMLElement_get_style(elem
, &style
);
5728 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5730 test_default_style(style
);
5732 test_compatmode(doc
);
5734 test_navigator(doc
);
5736 elem2
= get_elem2_iface((IUnknown
*)elem
);
5737 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5738 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5739 if(SUCCEEDED(hres
)) {
5740 test_current_style(cstyle
);
5741 IHTMLCurrentStyle_Release(cstyle
);
5743 IHTMLElement2_Release(elem2
);
5745 IHTMLElement_Release(elem
);
5747 test_set_csstext(style
);
5748 IHTMLStyle_Release(style
);
5750 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5751 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5754 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5755 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5756 ok(l
== 0, "length = %d\n", l
);
5758 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5760 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5761 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5763 test_default_selection(doc
);
5764 test_doc_title(doc
, "");
5767 static void test_tr_elem(IHTMLElement
*elem
)
5769 IHTMLElementCollection
*col
;
5773 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
5775 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
5776 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
5781 hres
= IHTMLTableRow_get_cells(row
, &col
);
5782 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
5783 ok(col
!= NULL
, "get_cells returned NULL\n");
5785 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
5786 IHTMLElementCollection_Release(col
);
5788 IHTMLTable_Release(row
);
5791 static void test_table_elem(IHTMLElement
*elem
)
5793 IHTMLElementCollection
*col
;
5798 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
5799 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
5801 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
5802 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
5807 hres
= IHTMLTable_get_rows(table
, &col
);
5808 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5809 ok(col
!= NULL
, "get_ros returned NULL\n");
5811 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
5812 IHTMLElementCollection_Release(col
);
5814 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5816 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
5817 test_elem_tag((IUnknown
*)node
, "TABLE");
5818 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5819 IHTMLDOMNode_Release(node
);
5821 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
5822 test_elem_tag((IUnknown
*)node
, "TABLE");
5823 test_elem_all((IUnknown
*)node
, NULL
, 0);
5824 IHTMLDOMNode_Release(node
);
5826 IHTMLTable_Release(table
);
5829 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
5838 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
5839 SafeArrayAccessData(sa
, (void**)&var
);
5840 V_VT(var
) = VT_BSTR
;
5841 V_BSTR(var
) = a2bstr(text
);
5842 SafeArrayUnaccessData(sa
);
5845 hres
= IHTMLDocument2_writeln(doc
, sa
);
5847 hres
= IHTMLDocument2_write(doc
, sa
);
5848 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
5850 SafeArrayDestroy(sa
);
5853 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
5855 IHTMLDocument2
*window_doc
, *elem_doc
;
5856 IHTMLFrameElement3
*frame_elem3
;
5857 IHTMLWindow2
*content_window
;
5860 content_window
= get_frame_content_window(frame_elem
);
5861 window_doc
= get_window_doc(content_window
);
5862 IHTMLWindow2_Release(content_window
);
5864 elem_doc
= get_elem_doc(frame_elem
);
5865 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
5868 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
5869 if(SUCCEEDED(hres
)) {
5870 IDispatch
*disp
= NULL
;
5872 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
5873 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
5874 ok(disp
!= NULL
, "contentDocument == NULL\n");
5875 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
5877 IDispatch_Release(disp
);
5878 IHTMLFrameElement3_Release(frame_elem3
);
5880 win_skip("IHTMLFrameElement3 not supported\n");
5884 IHTMLDocument2_Release(elem_doc
);
5885 IHTMLDocument2_Release(window_doc
);
5888 static void test_iframe_elem(IHTMLElement
*elem
)
5890 IHTMLDocument2
*content_doc
, *owner_doc
;
5891 IHTMLElementCollection
*col
;
5892 IHTMLWindow2
*content_window
;
5898 static const elem_type_t all_types
[] = {
5906 test_frame_doc((IUnknown
*)elem
, TRUE
);
5908 content_window
= get_frame_content_window((IUnknown
*)elem
);
5909 test_window_length(content_window
, 0);
5911 content_doc
= get_window_doc(content_window
);
5912 IHTMLWindow2_Release(content_window
);
5914 str
= a2bstr("text/html");
5915 V_VT(&errv
) = VT_ERROR
;
5917 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5919 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5920 ok(disp
!= NULL
, "disp == NULL\n");
5921 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5922 IDispatch_Release(disp
);
5924 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head><body><br /></body>");
5925 doc_write(content_doc
, TRUE
, "</html>");
5927 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5928 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5929 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5930 IHTMLElementCollection_Release(col
);
5932 hres
= IHTMLDocument2_close(content_doc
);
5933 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5935 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5936 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5938 IHTMLDocument2_Release(content_doc
);
5941 static void test_stylesheet(IDispatch
*disp
)
5943 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5944 IHTMLStyleSheet
*stylesheet
;
5947 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5948 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5950 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5951 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5952 ok(col
!= NULL
, "col == NULL\n");
5954 IHTMLStyleSheetRulesCollection_Release(col
);
5955 IHTMLStyleSheet_Release(stylesheet
);
5958 static void test_stylesheets(IHTMLDocument2
*doc
)
5960 IHTMLStyleSheetsCollection
*col
= NULL
;
5965 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5966 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5967 ok(col
!= NULL
, "col == NULL\n");
5969 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
5971 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5972 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5973 ok(len
== 1, "len=%d\n", len
);
5979 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5980 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5981 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5982 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5983 test_stylesheet(V_DISPATCH(&res
));
5990 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5991 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5992 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5993 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5996 IHTMLStyleSheetsCollection_Release(col
);
5999 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
6001 IDispatchEx
*dispex
;
6003 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
6011 static const WCHAR w0
[] = {'0',0};
6012 static const WCHAR w100
[] = {'1','0','0',0};
6014 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
6015 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
6017 bstr
= SysAllocString(w0
);
6018 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6019 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6020 SysFreeString(bstr
);
6023 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
6024 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
6025 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
6026 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
6027 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
6028 type
= get_node_type((IUnknown
*)node
);
6029 ok(type
== 3, "type=%d\n", type
);
6030 IHTMLDOMNode_Release(node
);
6033 bstr
= SysAllocString(w100
);
6034 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6035 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
6036 SysFreeString(bstr
);
6038 IDispatchEx_Release(dispex
);
6043 static void test_elems(IHTMLDocument2
*doc
)
6045 IHTMLElementCollection
*col
;
6046 IHTMLDOMChildrenCollection
*child_col
;
6047 IHTMLElement
*elem
, *elem2
, *elem3
;
6048 IHTMLDOMNode
*node
, *node2
;
6049 IHTMLWindow2
*window
;
6053 IHTMLElementCollection
*collection
;
6054 IHTMLDocument3
*doc3
;
6057 static const elem_type_t all_types
[] = {
6085 static const elem_type_t item_types
[] = {
6091 hres
= IHTMLDocument2_get_all(doc
, &col
);
6092 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6093 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6094 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
6095 IHTMLElementCollection_Release(col
);
6097 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6098 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6101 static const elem_type_t images_types
[] = {ET_IMG
};
6102 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
6104 IHTMLElementCollection_Release(collection
);
6107 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6108 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6111 static const elem_type_t images_types
[] = {ET_A
};
6112 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
6114 IHTMLElementCollection_Release(collection
);
6117 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6118 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6121 static const elem_type_t anchor_types
[] = {ET_A
};
6122 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
6124 IHTMLElementCollection_Release(collection
);
6127 elem
= get_doc_elem(doc
);
6128 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
6129 IHTMLElement_Release(elem
);
6131 get_elem_by_id(doc
, "xxx", FALSE
);
6132 elem
= get_doc_elem_by_id(doc
, "xxx");
6133 ok(!elem
, "elem != NULL\n");
6135 elem
= get_doc_elem_by_id(doc
, "s");
6136 ok(elem
!= NULL
, "elem == NULL\n");
6138 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
6139 test_elem_attr(elem
, "xxx", NULL
);
6140 test_elem_attr(elem
, "id", "s");
6141 test_elem_class((IUnknown
*)elem
, NULL
);
6142 test_elem_set_class((IUnknown
*)elem
, "cl");
6143 test_elem_set_class((IUnknown
*)elem
, NULL
);
6144 test_elem_tabindex((IUnknown
*)elem
, 0);
6145 test_elem_set_tabindex((IUnknown
*)elem
, 1);
6146 test_elem_filters((IUnknown
*)elem
);
6148 node
= test_node_get_parent((IUnknown
*)elem
);
6149 ok(node
!= NULL
, "node == NULL\n");
6150 test_node_name((IUnknown
*)node
, "BODY");
6151 node2
= test_node_get_parent((IUnknown
*)node
);
6152 IHTMLDOMNode_Release(node
);
6153 ok(node2
!= NULL
, "node == NULL\n");
6154 test_node_name((IUnknown
*)node2
, "HTML");
6155 node
= test_node_get_parent((IUnknown
*)node2
);
6156 IHTMLDOMNode_Release(node2
);
6157 ok(node
!= NULL
, "node == NULL\n");
6160 test_node_name((IUnknown
*)node
, "#document");
6161 type
= get_node_type((IUnknown
*)node
);
6162 ok(type
== 9, "type=%d, expected 9\n", type
);
6163 node2
= test_node_get_parent((IUnknown
*)node
);
6164 IHTMLDOMNode_Release(node
);
6165 ok(node2
== NULL
, "node != NULL\n");
6168 elem2
= test_elem_get_parent((IUnknown
*)elem
);
6169 ok(elem2
!= NULL
, "elem2 == NULL\n");
6170 test_node_name((IUnknown
*)elem2
, "BODY");
6171 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
6172 IHTMLElement_Release(elem2
);
6173 ok(elem3
!= NULL
, "elem3 == NULL\n");
6174 test_node_name((IUnknown
*)elem3
, "HTML");
6175 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
6176 IHTMLElement_Release(elem3
);
6177 ok(elem2
== NULL
, "elem2 != NULL\n");
6179 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
6180 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
6181 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
6183 test_elem_innertext(elem
, "opt1opt2");
6185 IHTMLElement_Release(elem
);
6188 elem
= get_elem_by_id(doc
, "s", TRUE
);
6190 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
6191 IHTMLDocument2
*doc_node
, *elem_doc
;
6193 test_select_elem(select
);
6195 test_elem_title((IUnknown
*)select
, NULL
);
6196 test_elem_set_title((IUnknown
*)select
, "Title");
6197 test_elem_title((IUnknown
*)select
, "Title");
6198 test_elem_offset((IUnknown
*)select
);
6199 test_elem_bounding_client_rect((IUnknown
*)select
);
6201 node
= get_first_child((IUnknown
*)select
);
6202 ok(node
!= NULL
, "node == NULL\n");
6204 test_elem_type((IUnknown
*)node
, ET_OPTION
);
6205 IHTMLDOMNode_Release(node
);
6208 type
= get_node_type((IUnknown
*)select
);
6209 ok(type
== 1, "type=%d\n", type
);
6211 IHTMLSelectElement_Release(select
);
6213 elem_doc
= get_elem_doc((IUnknown
*)elem
);
6215 doc_node
= get_doc_node(doc
);
6216 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
6217 IHTMLDocument2_Release(doc_node
);
6218 IHTMLDocument2_Release(elem_doc
);
6220 IHTMLElement_Release(elem
);
6223 elem
= get_elem_by_id(doc
, "sc", TRUE
);
6225 IHTMLScriptElement
*script
;
6228 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
6229 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
6235 hres
= IHTMLScriptElement_put_type (script
, NULL
);
6236 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
6237 hres
= IHTMLScriptElement_get_type(script
, &type
);
6238 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
6239 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
6241 hres
= IHTMLScriptElement_put_type (script
, a2bstr ("text/javascript"));
6242 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
6243 hres
= IHTMLScriptElement_get_type(script
, &type
);
6244 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
6245 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
6247 SysFreeString(type
);
6250 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
6251 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
6253 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
6254 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
6255 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
6257 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
6258 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
6260 str
= (BSTR
)0xdeadbeef;
6261 hres
= IHTMLScriptElement_get_src(script
, &str
);
6262 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
6263 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
6266 IHTMLScriptElement_Release(script
);
6269 elem
= get_elem_by_id(doc
, "in", TRUE
);
6271 IHTMLInputElement
*input
;
6273 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
6274 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
6276 test_elem_id((IUnknown
*)elem
, "in");
6277 test_elem_put_id((IUnknown
*)elem
, "newin");
6278 test_input_get_disabled(input
, VARIANT_FALSE
);
6279 test_input_set_disabled(input
, VARIANT_TRUE
);
6280 test_input_set_disabled(input
, VARIANT_FALSE
);
6281 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
6282 test_input_get_disabled(input
, VARIANT_TRUE
);
6283 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
6284 test_input_get_disabled(input
, VARIANT_FALSE
);
6285 test_elem_client_size((IUnknown
*)elem
);
6286 test_input_type(input
, "text");
6288 test_node_get_value_str((IUnknown
*)elem
, NULL
);
6289 test_node_put_value_str((IUnknown
*)elem
, "test");
6290 test_node_get_value_str((IUnknown
*)elem
, NULL
);
6291 test_input_value((IUnknown
*)elem
, NULL
);
6292 test_input_put_value((IUnknown
*)elem
, "test");
6293 test_input_value((IUnknown
*)elem
, NULL
);
6294 test_elem_class((IUnknown
*)elem
, "testclass");
6295 test_elem_tabindex((IUnknown
*)elem
, 2);
6296 test_elem_set_tabindex((IUnknown
*)elem
, 3);
6297 test_elem_title((IUnknown
*)elem
, "test title");
6299 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
6300 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
6301 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
6303 test_input_get_checked(input
, VARIANT_FALSE
);
6304 test_input_set_checked(input
, VARIANT_TRUE
);
6305 test_input_set_checked(input
, VARIANT_FALSE
);
6307 test_input_name(input
, NULL
);
6308 test_input_set_name(input
, "test");
6310 test_input_src(input
, NULL
);
6311 test_input_set_src(input
, "about:blank");
6313 IHTMLInputElement_Release(input
);
6314 IHTMLElement_Release(elem
);
6317 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
6319 test_img_src((IUnknown
*)elem
, "");
6320 test_img_set_src((IUnknown
*)elem
, "about:blank");
6321 test_img_alt((IUnknown
*)elem
, NULL
);
6322 test_img_set_alt((IUnknown
*)elem
, "alt test");
6323 test_img_name((IUnknown
*)elem
, "WineImg");
6324 IHTMLElement_Release(elem
);
6327 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
6329 test_style_media((IUnknown
*)elem
, NULL
);
6330 test_style_put_media((IUnknown
*)elem
, "screen");
6331 IHTMLElement_Release(elem
);
6334 elem
= get_doc_elem_by_id(doc
, "tbl");
6335 ok(elem
!= NULL
, "elem == NULL\n");
6337 test_table_elem(elem
);
6338 IHTMLElement_Release(elem
);
6341 elem
= get_doc_elem_by_id(doc
, "row2");
6342 ok(elem
!= NULL
, "elem == NULL\n");
6345 IHTMLElement_Release(elem
);
6348 elem
= get_doc_elem_by_id(doc
, "ifr");
6349 ok(elem
!= NULL
, "elem == NULL\n");
6351 test_iframe_elem(elem
);
6352 IHTMLElement_Release(elem
);
6355 elem
= get_doc_elem_by_id(doc
, "objid");
6356 ok(elem
!= NULL
, "elem == NULL\n");
6358 test_object_vspace((IUnknown
*)elem
, 100);
6359 IHTMLElement_Release(elem
);
6362 elem
= get_elem_by_id(doc
, "a", TRUE
);
6364 test_anchor_href((IUnknown
*)elem
, "http://test/");
6365 IHTMLElement_Release(elem
);
6368 elem
= doc_get_body(doc
);
6370 node
= get_first_child((IUnknown
*)elem
);
6371 ok(node
!= NULL
, "node == NULL\n");
6373 test_ifaces((IUnknown
*)node
, text_iids
);
6374 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
6376 node2
= get_first_child((IUnknown
*)node
);
6377 ok(!node2
, "node2 != NULL\n");
6379 type
= get_node_type((IUnknown
*)node
);
6380 ok(type
== 3, "type=%d\n", type
);
6382 test_node_get_value_str((IUnknown
*)node
, "text test");
6383 test_node_put_value_str((IUnknown
*)elem
, "test text");
6384 test_node_get_value_str((IUnknown
*)node
, "text test");
6386 IHTMLDOMNode_Release(node
);
6389 child_col
= get_child_nodes((IUnknown
*)elem
);
6390 ok(child_col
!= NULL
, "child_coll == NULL\n");
6394 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
6396 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
6397 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6398 ok(length
, "length=0\n");
6401 node
= get_child_item(child_col
, 0);
6402 ok(node
!= NULL
, "node == NULL\n");
6404 type
= get_node_type((IUnknown
*)node
);
6405 ok(type
== 3, "type=%d\n", type
);
6406 node2
= node_get_next((IUnknown
*)node
);
6407 IHTMLDOMNode_Release(node
);
6410 node
= get_child_item(child_col
, 1);
6411 ok(node
!= NULL
, "node == NULL\n");
6413 type
= get_node_type((IUnknown
*)node
);
6414 ok(type
== 8, "type=%d\n", type
);
6416 test_elem_id((IUnknown
*)node
, NULL
);
6417 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
6418 IHTMLDOMNode_Release(node2
);
6419 IHTMLDOMNode_Release(node
);
6422 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
6423 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
6425 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
6426 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
6428 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
6429 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
6431 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
6432 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
6434 test_child_col_disp(child_col
);
6436 IHTMLDOMChildrenCollection_Release(child_col
);
6439 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
6440 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
6441 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
6443 IHTMLElement_Release(elem
);
6445 elem
= get_doc_elem_by_id(doc
, "frm");
6446 ok(elem
!= NULL
, "elem == NULL\n");
6448 test_form_length((IUnknown
*)elem
, 0);
6449 IHTMLElement_Release(elem
);
6452 test_stylesheets(doc
);
6453 test_create_option_elem(doc
);
6454 test_create_img_elem(doc
);
6456 elem
= get_doc_elem_by_id(doc
, "tbl");
6457 ok(elem
!= NULL
, "elem = NULL\n");
6458 test_elem_set_innertext(elem
, "inner text");
6459 IHTMLElement_Release(elem
);
6461 test_doc_title(doc
, "test");
6462 test_doc_set_title(doc
, "test title");
6463 test_doc_title(doc
, "test title");
6466 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6467 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6470 IDispatchEx
*dispex
;
6471 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
6472 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
6476 BSTR str
= a2bstr("Testing");
6477 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
6478 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6479 ok(pid
!= -1, "pid == -1\n");
6481 IDispatchEx_Release(dispex
);
6484 IDispatch_Release(disp
);
6486 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6487 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
6489 str
= a2bstr("img");
6490 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
6491 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
6495 static const elem_type_t img_types
[] = { ET_IMG
};
6497 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
6498 IHTMLElementCollection_Release(col
);
6501 elem
= get_doc_elem_by_id(doc
, "y");
6502 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
6503 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
6504 test_elem_set_innerhtml((IUnknown
*)elem
, "");
6505 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
6506 node
= node_get_next((IUnknown
*)elem
);
6507 ok(!node
, "node = %p\n", node
);
6509 elem2
= get_doc_elem_by_id(doc
, "x");
6510 test_elem_tag((IUnknown
*)elem2
, "A");
6511 node
= node_get_next((IUnknown
*)elem2
);
6512 IHTMLDOMNode_Release(node
);
6513 IHTMLElement_Release(elem2
);
6514 IHTMLElement_Release(elem
);
6516 IHTMLDocument3_Release(doc3
);
6518 elem
= get_elem_by_id(doc
, "s", TRUE
);
6520 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
6522 test_select_put_length((IUnknown
*)elem
, 3);
6523 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
6524 test_select_put_length((IUnknown
*)elem
, 1);
6525 test_elem_all((IUnknown
*)elem
, select_types
, 1);
6526 IHTMLElement_Release(elem
);
6529 window
= get_doc_window(doc
);
6530 test_window_name(window
, NULL
);
6531 set_window_name(window
, "test name");
6532 test_window_length(window
, 1);
6533 IHTMLWindow2_Release(window
);
6536 static void test_elems2(IHTMLDocument2
*doc
)
6538 IHTMLElement
*elem
, *elem2
, *div
;
6540 static const elem_type_t outer_types
[] = {
6545 div
= get_doc_elem_by_id(doc
, "divid");
6547 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
6548 elem2
= get_doc_elem_by_id(doc
, "innerid");
6549 ok(elem2
!= NULL
, "elem2 == NULL\n");
6550 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6551 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
6552 IHTMLElement_Release(elem2
);
6554 elem2
= get_doc_elem_by_id(doc
, "aid");
6555 ok(elem2
!= NULL
, "elem2 == NULL\n");
6556 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
6557 test_elem_all((IUnknown
*)div
, outer_types
, 1);
6558 IHTMLElement_Release(elem2
);
6560 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
6561 elem
= get_elem_by_id(doc
, "ta", TRUE
);
6563 test_textarea_value((IUnknown
*)elem
, NULL
);
6564 test_textarea_put_value((IUnknown
*)elem
, "test");
6565 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
6566 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
6567 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
6568 test_textarea_type((IUnknown
*)elem
);
6569 IHTMLElement_Release(elem
);
6572 test_elem_set_innerhtml((IUnknown
*)div
,
6573 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6574 elem
= get_elem_by_id(doc
, "form", TRUE
);
6576 test_form_length((IUnknown
*)elem
, 2);
6577 test_form_item(elem
);
6578 test_form_action((IUnknown
*)elem
, NULL
);
6579 test_form_put_action((IUnknown
*)elem
, "about:blank");
6580 test_form_method((IUnknown
*)elem
, "get");
6581 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
6582 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
6583 test_form_method((IUnknown
*)elem
, "post");
6584 test_form_name((IUnknown
*)elem
, NULL
);
6585 test_form_put_name((IUnknown
*)elem
, "Name");
6586 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
6587 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
6588 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
6589 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
6590 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
6591 IHTMLElement_Release(elem
);
6594 IHTMLElement_Release(div
);
6597 static void test_create_elems(IHTMLDocument2
*doc
)
6599 IHTMLElement
*elem
, *body
, *elem2
;
6600 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
6601 IHTMLDocument5
*doc5
;
6608 static const elem_type_t types1
[] = { ET_TESTG
};
6610 elem
= test_create_elem(doc
, "TEST");
6611 test_elem_tag((IUnknown
*)elem
, "TEST");
6612 type
= get_node_type((IUnknown
*)elem
);
6613 ok(type
== 1, "type=%d\n", type
);
6614 test_ifaces((IUnknown
*)elem
, elem_iids
);
6615 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
6617 body
= doc_get_body(doc
);
6618 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6620 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
6621 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
6622 elem2
= get_elem_iface((IUnknown
*)node
);
6623 IHTMLElement_Release(elem2
);
6625 hres
= IHTMLElement_get_all(body
, &disp
);
6626 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6627 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
6628 IDispatch_Release(disp
);
6630 test_node_remove_child((IUnknown
*)body
, node
);
6632 hres
= IHTMLElement_get_all(body
, &disp
);
6633 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6634 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
6635 IDispatch_Release(disp
);
6636 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6638 IHTMLElement_Release(elem
);
6639 IHTMLDOMNode_Release(node
);
6641 node
= test_create_text(doc
, "test");
6642 test_ifaces((IUnknown
*)node
, text_iids
);
6643 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
6644 test_text_length((IUnknown
*)node
, 4);
6646 V_VT(&var
) = VT_NULL
;
6647 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6648 IHTMLDOMNode_Release(node
);
6650 node
= test_create_text(doc
, "insert ");
6652 V_VT(&var
) = VT_DISPATCH
;
6653 V_DISPATCH(&var
) = (IDispatch
*)node2
;
6654 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6655 IHTMLDOMNode_Release(node
);
6656 IHTMLDOMNode_Release(node2
);
6657 IHTMLDOMNode_Release(node3
);
6659 test_elem_innertext(body
, "insert test");
6660 test_elem_innerhtml((IUnknown
*)body
, "insert test");
6662 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
6665 str
= a2bstr("testing");
6666 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
6668 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
6671 type
= get_node_type((IUnknown
*)comment
);
6672 ok(type
== 8, "type=%d, expected 8\n", type
);
6674 test_node_get_value_str((IUnknown
*)comment
, "testing");
6675 test_elem_title((IUnknown
*)comment
, NULL
);
6676 test_elem_set_title((IUnknown
*)comment
, "comment title");
6677 test_elem_title((IUnknown
*)comment
, "comment title");
6678 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
6679 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
6681 IHTMLDOMNode_Release(comment
);
6684 IHTMLDocument5_Release(doc5
);
6687 IHTMLElement_Release(body
);
6690 static void test_null_write(IHTMLDocument2
*doc
)
6694 doc_write(doc
, FALSE
, NULL
);
6695 doc_write(doc
, TRUE
, NULL
);
6697 hres
= IHTMLDocument2_write(doc
, NULL
);
6699 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
6701 hres
= IHTMLDocument2_writeln(doc
, NULL
);
6703 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
6706 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
6708 IOleCommandTarget
*cmdtrg
;
6711 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
6712 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
6714 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
6715 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
6717 IOleCommandTarget_Release(cmdtrg
);
6720 static void test_indent(IHTMLDocument2
*doc
)
6722 IHTMLElementCollection
*col
;
6723 IHTMLTxtRange
*range
;
6726 static const elem_type_t all_types
[] = {
6735 static const elem_type_t indent_types
[] = {
6746 hres
= IHTMLDocument2_get_all(doc
, &col
);
6747 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6748 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6749 IHTMLElementCollection_Release(col
);
6751 range
= test_create_body_range(doc
);
6752 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
6753 IHTMLTxtRange_Release(range
);
6755 hres
= IHTMLDocument2_get_all(doc
, &col
);
6756 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6757 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
6758 IHTMLElementCollection_Release(col
);
6761 static void test_cond_comment(IHTMLDocument2
*doc
)
6763 IHTMLElementCollection
*col
;
6766 static const elem_type_t all_types
[] = {
6774 hres
= IHTMLDocument2_get_all(doc
, &col
);
6775 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6776 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6777 IHTMLElementCollection_Release(col
);
6780 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6782 IHTMLWindow2
*frame2
, *parent
, *top
;
6783 IHTMLDocument2
*parent_doc
, *top_doc
;
6784 IHTMLWindow4
*frame
;
6785 IHTMLFrameBase
*frame_elem
;
6788 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6789 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6793 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6794 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6795 IHTMLWindow4_Release(frame
);
6799 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6800 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6801 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6802 IHTMLElement_Release(frame_elem
);
6804 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6805 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6809 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6810 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6812 IHTMLWindow2_Release(frame2
);
6816 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6817 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6818 IHTMLWindow2_Release(parent
);
6820 IHTMLWindow2_Release(frame2
);
6824 test_doc_title(parent_doc
, "frameset test");
6825 IHTMLDocument2_Release(parent_doc
);
6828 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6829 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6830 IHTMLWindow2_Release(frame2
);
6834 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6835 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6836 IHTMLWindow2_Release(top
);
6840 test_doc_title(top_doc
, "frameset test");
6841 IHTMLDocument2_Release(top_doc
);
6844 static void test_frameset(IHTMLDocument2
*doc
)
6846 IHTMLWindow2
*window
;
6847 IHTMLFramesCollection2
*frames
;
6849 IHTMLFrameBase
*fbase
;
6851 VARIANT index_var
, result_var
;
6855 window
= get_doc_window(doc
);
6857 /* test using IHTMLFramesCollection object */
6859 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6860 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6861 IHTMLWindow2_Release(window
);
6865 /* test result length */
6866 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6867 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6868 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6870 /* test first frame */
6871 V_VT(&index_var
) = VT_I4
;
6872 V_I4(&index_var
) = 0;
6873 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6874 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6875 if(SUCCEEDED(hres
)) {
6876 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6877 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6879 VariantClear(&result_var
);
6881 /* test second frame */
6882 V_I4(&index_var
) = 1;
6883 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6884 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6885 if(SUCCEEDED(hres
)) {
6886 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6887 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6889 VariantClear(&result_var
);
6891 /* fail on next frame */
6892 V_I4(&index_var
) = 3;
6893 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6894 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6895 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6896 VariantClear(&result_var
);
6898 /* string argument (element id lookup) */
6899 V_VT(&index_var
) = VT_BSTR
;
6900 V_BSTR(&index_var
) = a2bstr("fr1");
6901 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6902 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6903 if(SUCCEEDED(hres
)) {
6904 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6905 test_frame(V_DISPATCH(&result_var
), "fr1");
6907 VariantClear(&result_var
);
6908 VariantClear(&index_var
);
6910 /* invalid argument */
6911 V_VT(&index_var
) = VT_BOOL
;
6912 V_BOOL(&index_var
) = VARIANT_TRUE
;
6913 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6914 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6915 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6916 VariantClear(&result_var
);
6918 IHTMLFramesCollection2_Release(frames
);
6920 /* test using IHTMLWindow2 inheritance */
6922 /* test result length */
6923 hres
= IHTMLWindow2_get_length(window
, &length
);
6924 ok(hres
== S_OK
, "IHTMLWindow2_get_length failed: 0x%08x\n", hres
);
6925 ok(length
== 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length
);
6927 /* test first frame */
6928 V_VT(&index_var
) = VT_I4
;
6929 V_I4(&index_var
) = 0;
6930 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6931 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6932 if(SUCCEEDED(hres
)) {
6933 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6934 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6936 VariantClear(&result_var
);
6938 /* test second frame */
6939 V_I4(&index_var
) = 1;
6940 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6941 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6942 if(SUCCEEDED(hres
)) {
6943 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6944 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6946 VariantClear(&result_var
);
6948 /* fail on next frame */
6949 V_I4(&index_var
) = 3;
6950 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6951 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLWindow2_item should have"
6952 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6953 VariantClear(&result_var
);
6955 /* string argument (element id lookup) */
6956 V_VT(&index_var
) = VT_BSTR
;
6957 V_BSTR(&index_var
) = a2bstr("fr2");
6958 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6959 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6960 if(SUCCEEDED(hres
)) {
6961 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6962 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6964 VariantClear(&result_var
);
6965 VariantClear(&index_var
);
6967 /* invalid argument */
6968 V_VT(&index_var
) = VT_BOOL
;
6969 V_BOOL(&index_var
) = VARIANT_TRUE
;
6970 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6971 ok(hres
== E_INVALIDARG
, "IHTMLWindow2_item should have"
6972 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6973 VariantClear(&result_var
);
6975 /* getElementById with node name attributes */
6976 elem
= get_doc_elem_by_id(doc
, "nm1");
6977 test_elem_id((IUnknown
*)elem
, "fr1");
6979 /* get/put scrolling */
6980 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6981 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6983 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6984 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6985 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6989 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6990 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6993 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6994 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6995 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6998 str
= a2bstr("junk");
6999 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
7000 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
7001 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
7004 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
7005 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
7006 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
7010 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
7011 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
7012 ok(!strcmp_wa(str
, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str
));
7015 IHTMLFrameBase_Release(fbase
);
7016 IHTMLElement_Release(elem
);
7018 /* get_name with no name attr */
7019 elem
= get_doc_elem_by_id(doc
, "fr3");
7020 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
7021 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
7023 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
7024 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
7025 ok(str
== NULL
, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str
));
7028 IHTMLFrameBase_Release(fbase
);
7029 IHTMLElement_Release(elem
);
7032 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
7034 IHTMLDocument2
*frag
;
7035 IHTMLDocument3
*doc3
;
7038 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
7039 ok(hres
== S_OK
, "Coult not get IHTMLDocument3 iface: %08x\n", hres
);
7041 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
7042 IHTMLDocument3_Release(doc3
);
7043 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
7044 ok(frag
!= NULL
, "frag == NULL\n");
7049 static void test_docfrag(IHTMLDocument2
*doc
)
7051 IHTMLElement
*div
, *body
, *br
;
7052 IHTMLElementCollection
*col
;
7053 IHTMLLocation
*location
;
7054 IHTMLDocument2
*frag
;
7057 static const elem_type_t all_types
[] = {
7066 frag
= create_docfrag(doc
);
7068 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
7070 body
= (void*)0xdeadbeef;
7071 hres
= IHTMLDocument2_get_body(frag
, &body
);
7072 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
7073 ok(!body
, "body != NULL\n");
7075 location
= (void*)0xdeadbeef;
7076 hres
= IHTMLDocument2_get_location(frag
, &location
);
7077 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
7078 ok(location
== (void*)0xdeadbeef, "location changed\n");
7080 br
= test_create_elem(doc
, "BR");
7081 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
7082 IHTMLElement_Release(br
);
7084 div
= get_elem_by_id(doc
, "divid", TRUE
);
7085 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
7086 IHTMLElement_Release(div
);
7088 hres
= IHTMLDocument2_get_all(doc
, &col
);
7089 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7090 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7091 IHTMLElementCollection_Release(col
);
7093 IHTMLDocument2_Release(frag
);
7096 static IHTMLDocument2
*notif_doc
;
7097 static BOOL doc_complete
;
7099 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
7100 REFIID riid
, void**ppv
)
7102 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
7107 ok(0, "unexpected call\n");
7108 return E_NOINTERFACE
;
7111 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
7116 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
7121 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
7123 if(dispID
== DISPID_READYSTATE
){
7127 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
7128 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
7130 if(!strcmp_wa(state
, "complete"))
7131 doc_complete
= TRUE
;
7133 SysFreeString(state
);
7139 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
7141 ok(0, "unexpected call\n");
7145 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
7146 PropertyNotifySink_QueryInterface
,
7147 PropertyNotifySink_AddRef
,
7148 PropertyNotifySink_Release
,
7149 PropertyNotifySink_OnChanged
,
7150 PropertyNotifySink_OnRequestEdit
7153 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
7155 static IHTMLDocument2
*create_doc_with_string(const char *str
)
7157 IPersistStreamInit
*init
;
7159 IHTMLDocument2
*doc
;
7163 notif_doc
= doc
= create_document();
7167 doc_complete
= FALSE
;
7169 mem
= GlobalAlloc(0, len
);
7170 memcpy(mem
, str
, len
);
7171 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
7173 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
7175 IPersistStreamInit_Load(init
, stream
);
7176 IPersistStreamInit_Release(init
);
7177 IStream_Release(stream
);
7182 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
7184 IConnectionPointContainer
*container
;
7185 IConnectionPoint
*cp
;
7189 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
7190 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
7192 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
7193 IConnectionPointContainer_Release(container
);
7194 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
7196 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
7197 IConnectionPoint_Release(cp
);
7198 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
7201 typedef void (*domtest_t
)(IHTMLDocument2
*);
7203 static void run_domtest(const char *str
, domtest_t test
)
7205 IHTMLDocument2
*doc
;
7209 doc
= create_doc_with_string(str
);
7213 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
7215 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
7216 TranslateMessage(&msg
);
7217 DispatchMessage(&msg
);
7222 ref
= IHTMLDocument2_Release(doc
);
7223 ok(!ref
|| broken(ref
== 1), /* Vista */
7231 run_domtest(doc_str1
, test_doc_elem
);
7232 run_domtest(doc_str1
, test_get_set_attr
);
7233 run_domtest(range_test_str
, test_txtrange
);
7234 run_domtest(range_test2_str
, test_txtrange2
);
7235 if (winetest_interactive
|| ! is_ie_hardened()) {
7236 run_domtest(elem_test_str
, test_elems
);
7238 skip("IE running in Enhanced Security Configuration\n");
7240 run_domtest(elem_test2_str
, test_elems2
);
7241 run_domtest(doc_blank
, test_create_elems
);
7242 run_domtest(doc_blank
, test_defaults
);
7243 run_domtest(doc_blank
, test_null_write
);
7244 run_domtest(indent_test_str
, test_indent
);
7245 run_domtest(cond_comment_str
, test_cond_comment
);
7246 run_domtest(frameset_str
, test_frameset
);
7247 run_domtest(emptydiv_str
, test_docfrag
);