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>.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>"
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\">"
73 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
74 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
75 static WCHAR wordW
[] = {'w','o','r','d',0};
106 static const IID
* const none_iids
[] = {
111 static const IID
* const doc_node_iids
[] = {
120 &IID_IConnectionPointContainer
,
121 &IID_IInternetHostSecurityManager
,
125 static const IID
* const doc_obj_iids
[] = {
132 &IID_IConnectionPointContainer
,
137 static const IID
* const elem_iids
[] = {
144 &IID_IConnectionPointContainer
,
148 static const IID
* const body_iids
[] = {
154 &IID_IHTMLTextContainer
,
155 &IID_IHTMLBodyElement
,
157 &IID_IConnectionPointContainer
,
161 static const IID
* const anchor_iids
[] = {
167 &IID_IHTMLAnchorElement
,
169 &IID_IConnectionPointContainer
,
173 static const IID
* const input_iids
[] = {
179 &IID_IHTMLInputElement
,
180 &IID_IHTMLInputTextElement
,
182 &IID_IConnectionPointContainer
,
186 static const IID
* const select_iids
[] = {
192 &IID_IHTMLSelectElement
,
194 &IID_IConnectionPointContainer
,
198 static const IID
* const textarea_iids
[] = {
204 &IID_IHTMLTextAreaElement
,
206 &IID_IConnectionPointContainer
,
210 static const IID
* const option_iids
[] = {
216 &IID_IHTMLOptionElement
,
218 &IID_IConnectionPointContainer
,
222 static const IID
* const table_iids
[] = {
230 &IID_IConnectionPointContainer
,
234 static const IID
* const script_iids
[] = {
240 &IID_IHTMLScriptElement
,
242 &IID_IConnectionPointContainer
,
246 static const IID
* const text_iids
[] = {
249 &IID_IHTMLDOMTextNode
,
253 static const IID
* const location_iids
[] = {
259 static const IID
* const window_iids
[] = {
267 static const IID
* const comment_iids
[] = {
273 &IID_IHTMLCommentElement
,
275 &IID_IConnectionPointContainer
,
279 static const IID
* const img_iids
[] = {
286 &IID_IHTMLImgElement
,
287 &IID_IConnectionPointContainer
,
291 static const IID
* const tr_iids
[] = {
299 &IID_IConnectionPointContainer
,
303 static const IID
* const td_iids
[] = {
310 &IID_IConnectionPointContainer
,
314 static const IID
* const frame_iids
[] = {
321 &IID_IHTMLFrameBase2
,
323 &IID_IConnectionPointContainer
,
327 static const IID
* const iframe_iids
[] = {
334 &IID_IHTMLFrameBase2
,
335 &IID_IHTMLIFrameElement
,
337 &IID_IConnectionPointContainer
,
341 static const IID
* const form_iids
[] = {
347 &IID_IHTMLFormElement
,
349 &IID_IConnectionPointContainer
,
353 static const IID
* const generic_iids
[] = {
359 &IID_IHTMLGenericElement
,
361 &IID_IConnectionPointContainer
,
365 static const IID
* const style_iids
[] = {
376 static const IID
* const cstyle_iids
[] = {
380 &IID_IHTMLCurrentStyle
,
384 static const IID
* const img_factory_iids
[] = {
388 &IID_IHTMLImageElementFactory
,
398 static const elem_type_info_t elem_type_infos
[] = {
399 {"", none_iids
, NULL
},
400 {"HTML", elem_iids
, NULL
},
401 {"HEAD", elem_iids
, NULL
},
402 {"TITLE", elem_iids
, NULL
},
403 {"BODY", body_iids
, &DIID_DispHTMLBody
},
404 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
405 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
406 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
407 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
408 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
409 {"STYLE", elem_iids
, NULL
},
410 {"BLOCKQUOTE",elem_iids
, NULL
},
411 {"P", elem_iids
, NULL
},
412 {"BR", elem_iids
, NULL
},
413 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
414 {"TBODY", elem_iids
, NULL
},
415 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
416 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
417 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
418 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
419 {"IMG", img_iids
, &DIID_DispHTMLImg
},
420 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
421 {"TD", td_iids
, NULL
},
422 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
423 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
424 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
}
427 static const char *dbgstr_guid(REFIID riid
)
431 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
432 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
433 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
434 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
439 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
442 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
443 return lstrcmpA(stra
, buf
);
446 static BSTR
a2bstr(const char *str
)
451 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
452 ret
= SysAllocStringLen(NULL
, len
);
453 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
458 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
460 IUnknown
*unk1
, *unk2
;
465 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
466 IUnknown_Release(unk1
);
467 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
468 IUnknown_Release(unk2
);
473 static IHTMLDocument2
*create_document(void)
476 IHTMLDocument5
*doc5
;
479 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
480 &IID_IHTMLDocument2
, (void**)&doc
);
481 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
485 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
487 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
488 IHTMLDocument2_Release(doc
);
492 IHTMLDocument5_Release(doc5
);
496 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
497 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
499 const IID
* const *piid
;
503 for(piid
= iids
; *piid
; piid
++) {
504 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
505 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
507 IUnknown_Release(unk
);
511 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
512 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
520 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
521 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
526 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
527 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
528 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
530 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
531 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
533 if(SUCCEEDED(hres
)) {
536 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
537 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
539 *iid
= type_attr
->guid
;
543 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
544 ITypeInfo_Release(typeinfo
);
547 IDispatchEx_Release(dispex
);
551 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
552 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
554 DISPPARAMS dp
= {NULL
,NULL
,0,0};
560 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
561 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IDispatchEx interface: %08x\n", hres
);
565 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
566 IDispatchEx_Release(dispex
);
567 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
569 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
570 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
574 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
575 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
579 if(_test_get_dispid(line
, unk
, &iid
))
580 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", dbgstr_guid(&iid
));
583 _test_disp_value(line
, unk
, val
);
586 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
587 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
591 if(_test_get_dispid(line
, unk
, &iid
))
592 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
593 "unexpected guid %s\n", dbgstr_guid(&iid
));
596 _test_disp_value(line
, unk
, val
);
599 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
600 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
605 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
606 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
610 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
611 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
616 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
617 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
621 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
622 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
627 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
628 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
632 #define get_node_iface(u) _get_node_iface(__LINE__,u)
633 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
638 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
639 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
643 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
644 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
649 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
650 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
654 #define get_img_iface(u) _get_img_iface(__LINE__,u)
655 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
657 IHTMLImgElement
*img
;
660 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
661 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
665 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
666 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
668 IHTMLAnchorElement
*anchor
;
671 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
672 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
676 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
677 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
679 IHTMLTextAreaElement
*textarea
;
682 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
683 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
687 #define get_select_iface(u) _get_select_iface(__LINE__,u)
688 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
690 IHTMLSelectElement
*select
;
693 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
694 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
698 #define get_form_iface(u) _get_form_iface(__LINE__,u)
699 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
701 IHTMLFormElement
*form
;
704 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
705 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
709 #define get_text_iface(u) _get_text_iface(__LINE__,u)
710 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
712 IHTMLDOMTextNode
*text
;
715 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
716 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
720 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
721 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
723 IHTMLCommentElement
*comment
;
726 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
727 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
731 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
732 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
734 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
738 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
739 IHTMLDOMNode_Release(node
);
740 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
741 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
746 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
747 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
749 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
750 IDispatch
*disp
= (void*)0xdeadbeef;
751 IHTMLDocument2
*doc
= NULL
;
754 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
755 IHTMLDOMNode2_Release(node
);
756 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
759 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
760 IDispatch_Release(disp
);
761 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
767 #define get_doc_window(d) _get_doc_window(__LINE__,d)
768 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
770 IHTMLWindow2
*window
;
774 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
775 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
776 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
781 #define clone_node(n,d) _clone_node(__LINE__,n,d)
782 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
784 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
785 IHTMLDOMNode
*ret
= NULL
;
788 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
789 IHTMLDOMNode_Release(node
);
790 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
791 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
797 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
798 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
800 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
804 hres
= IHTMLElement_get_tagName(elem
, &tag
);
805 IHTMLElement_Release(elem
);
806 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
807 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
812 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
813 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
815 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
816 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
818 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
819 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
822 #define get_node_type(n) _get_node_type(__LINE__,n)
823 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
825 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
829 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
830 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
832 IHTMLDOMNode_Release(node
);
837 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
838 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
840 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
841 IHTMLDOMChildrenCollection
*col
= NULL
;
845 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
846 IHTMLDOMNode_Release(node
);
847 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
851 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
852 IDispatch_Release(disp
);
853 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
858 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
859 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
861 IHTMLDOMNode
*node
= NULL
;
865 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
866 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
868 node
= _get_node_iface(line
, (IUnknown
*)disp
);
869 IDispatch_Release(disp
);
874 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
875 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
884 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
886 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
889 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
890 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
892 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
895 VariantClear(&value
);
898 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
899 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
901 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
905 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
906 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
908 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
909 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
911 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
914 IHTMLElement_Release(elem
);
917 #define get_doc_node(d) _get_doc_node(__LINE__,d)
918 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
920 IHTMLWindow2
*window
;
924 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
925 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
927 hres
= IHTMLWindow2_get_document(window
, &ret
);
928 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
929 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
934 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
935 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
940 hres
= IHTMLWindow2_get_name(window
, &name
);
941 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
943 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
945 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
948 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
949 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
955 hres
= IHTMLWindow2_put_name(window
, str
);
957 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
959 _test_window_name(line
, window
, name
);
962 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
963 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
968 hres
= IHTMLWindow2_get_length(window
, &length
);
969 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
970 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
973 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
974 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
976 IHTMLFrameBase2
*base2
;
977 IHTMLWindow2
*window
;
980 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
981 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
984 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
985 IHTMLFrameBase2_Release(base2
);
986 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
987 ok(window
!= NULL
, "contentWindow = NULL\n");
992 static void test_get_set_attr(IHTMLDocument2
*doc
)
995 IHTMLDocument3
*doc3
;
1000 /* grab an element to test with */
1001 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1002 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1004 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1005 IHTMLDocument3_Release(doc3
);
1006 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1008 /* get a non-present attribute */
1009 bstr
= a2bstr("notAnAttribute");
1010 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1011 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1012 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1014 SysFreeString(bstr
);
1016 /* get a present attribute */
1017 bstr
= a2bstr("scrollHeight");
1018 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1019 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1020 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1022 SysFreeString(bstr
);
1024 /* create a new BSTR attribute */
1025 bstr
= a2bstr("newAttribute");
1027 V_VT(&val
) = VT_BSTR
;
1028 V_BSTR(&val
) = a2bstr("the value");
1029 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1030 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1033 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1034 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1035 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1036 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
)));
1039 /* overwrite the attribute with a BOOL */
1040 V_VT(&val
) = VT_BOOL
;
1041 V_BOOL(&val
) = VARIANT_TRUE
;
1042 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1043 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1046 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1047 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1048 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1049 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1052 SysFreeString(bstr
);
1054 /* case-insensitive */
1055 bstr
= a2bstr("newattribute");
1056 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1057 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1058 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1059 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1061 SysFreeString(bstr
);
1063 IHTMLElement_Release(elem
);
1066 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1067 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1070 IHTMLDocument3
*doc3
;
1073 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1074 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1075 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1076 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1077 IHTMLDocument3_Release(doc3
);
1082 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1083 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1085 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1089 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1090 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1091 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1094 _test_disp_value(line
, unk
, exhref
);
1097 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1098 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1103 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1104 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1105 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1106 SysFreeString(bstr
);
1109 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1110 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1115 bstr
= a2bstr(text
);
1116 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1117 SysFreeString(bstr
);
1118 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1120 _test_option_text(line
, option
, text
);
1123 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1124 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1129 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1130 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1131 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1132 SysFreeString(bstr
);
1135 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1136 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1141 bstr
= a2bstr(value
);
1142 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1143 SysFreeString(bstr
);
1144 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1146 _test_option_value(line
, option
, value
);
1149 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1150 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1152 VARIANT_BOOL b
= 0x100;
1155 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1156 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1157 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1160 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1161 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1165 hres
= IHTMLOptionElement_put_selected(option
, b
);
1166 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1167 _test_option_selected(line
, option
, b
);
1170 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1171 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1173 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1174 BSTR value
= (void*)0xdeadbeef;
1177 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1178 IHTMLTextAreaElement_Release(textarea
);
1179 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1181 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1183 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1184 SysFreeString(value
);
1187 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1188 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1190 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1191 BSTR tmp
= a2bstr(value
);
1194 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1195 IHTMLTextAreaElement_Release(textarea
);
1196 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1199 _test_textarea_value(line
, unk
, value
);
1202 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1203 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1205 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1209 text
= a2bstr(extext
);
1210 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1211 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1212 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1214 IHTMLCommentElement_Release(comment
);
1215 SysFreeString(text
);
1218 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1219 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1220 const char *txt
, const char *val
)
1222 IHTMLOptionElementFactory
*factory
;
1223 IHTMLOptionElement
*option
;
1224 IHTMLWindow2
*window
;
1225 VARIANT text
, value
, empty
;
1228 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1229 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1231 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1232 IHTMLWindow2_Release(window
);
1233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1235 V_VT(&text
) = VT_BSTR
;
1236 V_BSTR(&text
) = a2bstr(txt
);
1237 V_VT(&value
) = VT_BSTR
;
1238 V_BSTR(&value
) = a2bstr(val
);
1239 V_VT(&empty
) = VT_EMPTY
;
1241 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1242 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1244 IHTMLOptionElementFactory_Release(factory
);
1245 VariantClear(&text
);
1246 VariantClear(&value
);
1248 _test_option_text(line
, option
, txt
);
1249 _test_option_value(line
, option
, val
);
1250 _test_option_selected(line
, option
, VARIANT_FALSE
);
1255 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1256 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1261 hres
= IHTMLImgElement_get_width(img
, &found
);
1262 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1263 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1266 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1267 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1271 hres
= IHTMLImgElement_put_width(img
, width
);
1272 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1274 _test_img_width(line
, img
, width
);
1277 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1278 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1283 hres
= IHTMLImgElement_get_height(img
, &found
);
1284 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1285 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1288 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1289 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1293 hres
= IHTMLImgElement_put_height(img
, height
);
1294 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1296 _test_img_height(line
, img
, height
);
1299 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1300 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1301 LONG wdth
, LONG hght
)
1303 IHTMLImageElementFactory
*factory
;
1304 IHTMLImgElement
*img
;
1305 IHTMLWindow2
*window
;
1306 VARIANT width
, height
;
1310 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1311 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1313 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1314 IHTMLWindow2_Release(window
);
1315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1317 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1318 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1321 snprintf(buf
, 16, "%d", wdth
);
1322 V_VT(&width
) = VT_BSTR
;
1323 V_BSTR(&width
) = a2bstr(buf
);
1325 V_VT(&width
) = VT_EMPTY
;
1330 snprintf(buf
, 16, "%d", hght
);
1331 V_VT(&height
) = VT_BSTR
;
1332 V_BSTR(&height
) = a2bstr(buf
);
1334 V_VT(&height
) = VT_EMPTY
;
1338 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1339 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1341 IHTMLImageElementFactory_Release(factory
);
1342 VariantClear(&width
);
1343 VariantClear(&height
);
1345 if(SUCCEEDED(hres
)) {
1346 _test_img_width(line
, img
, wdth
);
1347 _test_img_height(line
, img
, hght
);
1354 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1355 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1357 LONG len
= 0xdeadbeef;
1360 hres
= IHTMLSelectElement_get_length(select
, &len
);
1361 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1362 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1365 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1366 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1368 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1371 hres
= IHTMLSelectElement_put_length(select
, length
);
1372 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1373 _test_select_length(line
, select
, length
);
1374 IHTMLSelectElement_Release(select
);
1377 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1378 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1380 LONG idx
= 0xdeadbeef;
1383 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1384 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1385 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1388 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1389 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1393 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1394 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1395 _test_select_selidx(line
, select
, index
);
1398 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1399 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1404 hres
= IHTMLSelectElement_get_value(select
, &val
);
1405 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1407 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1409 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1412 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1413 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1419 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1420 SysFreeString(bstr
);
1421 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1424 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1425 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1430 hres
= IHTMLSelectElement_get_type(select
, &type
);
1431 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1432 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1435 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1436 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1441 hres
= IHTMLTxtRange_get_text(range
, &text
);
1442 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1445 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1446 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1448 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1451 SysFreeString(text
);
1455 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1456 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1460 hres
= IHTMLTxtRange_collapse(range
, b
);
1461 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1462 _test_range_text(line
, range
, NULL
);
1465 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1466 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1467 VARIANT_BOOL exb
, const char *extext
)
1469 VARIANT_BOOL b
= 0xe0e0;
1472 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1473 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1474 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1475 _test_range_text(line
, range
, extext
);
1478 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1479 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1481 LONG c
= 0xdeadbeef;
1484 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1485 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1486 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1487 _test_range_text(line
, range
, NULL
);
1490 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1491 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1492 LPWSTR unit
, LONG cnt
, LONG excnt
)
1494 LONG c
= 0xdeadbeef;
1497 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1498 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1499 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1502 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1503 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1505 LONG c
= 0xdeadbeef;
1508 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1509 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1510 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1513 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1514 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1517 BSTR bstr
= a2bstr(text
);
1519 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1520 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1521 SysFreeString(bstr
);
1522 _test_range_text(line
, range
, NULL
);
1525 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1526 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1532 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1533 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1534 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1537 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1538 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1544 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1545 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1546 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1549 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1550 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1551 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1554 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1555 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1559 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1560 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1565 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1566 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1568 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1570 IHTMLElement_Release(elem
);
1573 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1574 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1575 const elem_type_t
*elem_types
, LONG exlen
)
1577 IHTMLElementCollection
*col
;
1580 VARIANT name
, index
;
1581 IDispatch
*disp
, *disp2
;
1584 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1585 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1587 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1589 hres
= IHTMLElementCollection_get_length(col
, &len
);
1590 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1591 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1596 V_VT(&index
) = VT_EMPTY
;
1598 for(i
=0; i
<len
; i
++) {
1599 V_VT(&name
) = VT_I4
;
1601 disp
= (void*)0xdeadbeef;
1602 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1603 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1604 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1605 if(FAILED(hres
) || !disp
)
1608 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1611 V_VT(&name
) = VT_UINT
;
1613 disp2
= (void*)0xdeadbeef;
1614 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1615 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1616 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1618 IDispatch_Release(disp2
);
1621 IDispatch_Release(disp
);
1624 V_VT(&name
) = VT_I4
;
1626 disp
= (void*)0xdeadbeef;
1627 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1628 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1629 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1631 V_VT(&name
) = VT_I4
;
1633 disp
= (void*)0xdeadbeef;
1634 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1635 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1636 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1638 IHTMLElementCollection_Release(col
);
1641 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1642 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1644 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1648 hres
= IHTMLElement_get_all(elem
, &disp
);
1649 IHTMLElement_Release(elem
);
1650 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1652 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1653 IDispatch_Release(disp
);
1656 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1657 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1659 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1660 IHTMLElementCollection
*col
= NULL
;
1661 elem_type_t
*types
= NULL
;
1666 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1667 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1669 IHTMLElement2_Release(elem
);
1670 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1671 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1674 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1675 for(i
=0; i
<exlen
; i
++)
1679 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1681 HeapFree(GetProcessHeap(), 0, types
);
1684 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1685 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1690 hres
= IHTMLElement_get_innerText(elem
, &text
);
1691 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1692 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1693 wine_dbgstr_w(text
), extext
);
1694 SysFreeString(text
);
1697 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1698 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1700 IHTMLDOMChildrenCollection
*col
;
1705 hres
= IHTMLElement_put_innerText(elem
, str
);
1706 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1709 _test_elem_innertext(line
, elem
, text
);
1712 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1713 ok(col
!= NULL
, "col == NULL\n");
1715 LONG length
= 0, type
;
1718 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1719 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1720 ok(length
== 1, "length = %d\n", length
);
1722 node
= _get_child_item(line
, col
, 0);
1723 ok(node
!= NULL
, "node == NULL\n");
1725 type
= _get_node_type(line
, (IUnknown
*)node
);
1726 ok(type
== 3, "type=%d\n", type
);
1727 IHTMLDOMNode_Release(node
);
1730 IHTMLDOMChildrenCollection_Release(col
);
1735 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1736 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1738 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1742 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
1743 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
1745 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
1747 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
1749 IHTMLElement_Release(elem
);
1750 SysFreeString(html
);
1753 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1754 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1756 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1760 html
= a2bstr(inner_html
);
1761 hres
= IHTMLElement_put_innerHTML(elem
, html
);
1762 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
1764 IHTMLElement_Release(elem
);
1765 SysFreeString(html
);
1768 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1769 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1771 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1775 html
= a2bstr(outer_html
);
1776 hres
= IHTMLElement_put_outerHTML(elem
, html
);
1777 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
1779 IHTMLElement_Release(elem
);
1780 SysFreeString(html
);
1783 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1784 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1786 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1790 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
1791 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
1792 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
1794 IHTMLElement_Release(elem
);
1795 SysFreeString(html
);
1798 #define get_first_child(n) _get_first_child(__LINE__,n)
1799 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1801 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1802 IHTMLDOMNode
*child
= NULL
;
1805 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1806 IHTMLDOMNode_Release(node
);
1807 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1812 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1813 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1815 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1816 VARIANT_BOOL b
= 0xdead;
1819 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1820 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1821 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1823 IHTMLDOMNode_Release(node
);
1826 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1827 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1829 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1830 IHTMLDOMNode
*parent
;
1833 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1834 IHTMLDOMNode_Release(node
);
1835 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1840 #define node_get_next(u) _node_get_next(__LINE__,u)
1841 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
1843 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1847 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
1848 IHTMLDOMNode_Release(node
);
1849 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
1854 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1855 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1857 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1858 IHTMLElement
*parent
;
1861 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1862 IHTMLElement_Release(elem
);
1863 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1868 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1869 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1871 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1872 VARIANT_BOOL disabled
= 100;
1876 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1877 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1878 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1879 IHTMLElement3_Release(elem3
);
1882 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1883 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1885 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1889 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1890 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1892 IHTMLElement3_Release(elem3
);
1893 _test_elem3_get_disabled(line
, unk
, b
);
1896 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1897 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1899 VARIANT_BOOL disabled
= 100;
1902 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1903 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1904 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1906 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1909 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1910 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
1912 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
1916 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
1917 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1918 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
1919 IHTMLDOMTextNode_Release(text
);
1922 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1923 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1927 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1928 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1930 _test_select_get_disabled(line
, select
, b
);
1933 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1934 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1936 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1937 IHTMLTextContainer
*txtcont
;
1938 LONG l
= -1, l2
= -1;
1941 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1942 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1943 IHTMLElement2_Release(elem
);
1945 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1946 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1948 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1949 IHTMLTextContainer_Release(txtcont
);
1950 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
1951 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
1956 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1957 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1959 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1960 IHTMLTextContainer
*txtcont
;
1961 LONG l
= -1, l2
= -1;
1964 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1965 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1966 IHTMLElement2_Release(elem
);
1968 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1969 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1971 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1972 IHTMLTextContainer_Release(txtcont
);
1973 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
1974 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
1979 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1980 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1982 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1983 IHTMLTextContainer
*txtcont
;
1984 LONG l
= -1, l2
= -1;
1987 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1988 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1989 IHTMLElement2_Release(elem
);
1991 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1992 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1994 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1995 IHTMLTextContainer_Release(txtcont
);
1996 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
1997 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2002 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2003 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2005 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2006 IHTMLTextContainer
*txtcont
;
2007 LONG l
= -1, l2
= -1;
2010 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2011 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2013 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2014 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2015 IHTMLElement2_Release(elem
);
2017 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2018 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2020 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2021 IHTMLTextContainer_Release(txtcont
);
2022 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2023 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2026 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2027 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
2029 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2033 hres
= IHTMLImgElement_get_src(img
, &src
);
2034 IHTMLImgElement_Release(img
);
2035 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2036 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2040 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2041 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2043 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2048 hres
= IHTMLImgElement_put_src(img
, tmp
);
2049 IHTMLImgElement_Release(img
);
2051 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2053 _test_img_src(line
, unk
, src
);
2056 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2057 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2059 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2063 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2064 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2066 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2068 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2072 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2073 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2075 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2080 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2081 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2084 _test_img_alt(line
, unk
, alt
);
2087 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2088 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2090 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2094 hres
= IHTMLImgElement_get_name(img
, &sName
);
2095 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2096 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2097 IHTMLImgElement_Release(img
);
2098 SysFreeString(sName
);
2101 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2102 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
2107 hres
= IHTMLInputElement_get_type(input
, &type
);
2108 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2109 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2110 SysFreeString(type
);
2113 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2114 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
2116 BSTR name
= (BSTR
)0xdeadbeef;
2119 hres
= IHTMLInputElement_get_name(input
, &name
);
2120 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2122 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
2124 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
2125 SysFreeString(name
);
2128 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2129 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
2131 BSTR tmp
= a2bstr(name
);
2134 hres
= IHTMLInputElement_put_name(input
, tmp
);
2135 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
2138 _test_input_name(line
, input
, name
);
2141 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2142 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2144 VARIANT_BOOL disabled
= 100;
2147 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
2148 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2149 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2151 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
2154 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2155 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2159 hres
= IHTMLInputElement_put_disabled(input
, b
);
2160 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2162 _test_input_get_disabled(line
, input
, b
);
2165 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2166 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2168 VARIANT_BOOL checked
= 100;
2171 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
2172 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2173 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2176 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2177 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2181 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2182 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2184 _test_input_get_defaultchecked(line
, input
, b
);
2187 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2188 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2190 VARIANT_BOOL checked
= 100;
2193 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2194 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2195 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2198 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2199 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2203 hres
= IHTMLInputElement_put_checked(input
, b
);
2204 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2206 _test_input_get_checked(line
, input
, b
);
2209 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2210 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2212 IHTMLInputElement
*input
;
2216 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2217 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2221 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2222 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2224 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2226 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
2227 SysFreeString(bstr
);
2228 IHTMLInputElement_Release(input
);
2231 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2232 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2234 IHTMLInputElement
*input
;
2238 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2239 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2244 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2245 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2246 SysFreeString(bstr
);
2247 IHTMLInputElement_Release(input
);
2250 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2251 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2256 hres
= IHTMLInputElement_get_src(input
, &src
);
2257 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2259 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2261 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2265 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2266 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2272 hres
= IHTMLInputElement_put_src(input
, tmp
);
2274 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2276 _test_input_src(line
, input
, src
);
2279 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2280 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2282 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2283 BSTR
class = (void*)0xdeadbeef;
2286 hres
= IHTMLElement_get_className(elem
, &class);
2287 IHTMLElement_Release(elem
);
2288 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2290 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2292 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2293 SysFreeString(class);
2296 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2297 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2299 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2303 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2304 IHTMLElement2_Release(elem2
);
2305 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2306 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2309 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2310 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2312 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2315 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2316 IHTMLElement2_Release(elem2
);
2317 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2319 _test_elem_tabindex(line
, unk
, index
);
2322 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2323 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2325 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2327 IHTMLFiltersCollection
*filters
;
2329 hres
= IHTMLElement_get_filters(elem
, &filters
);
2330 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2331 "get_filters failed: %08x\n", hres
);
2335 IDispatchEx
*dispex
;
2337 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2338 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2339 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2341 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2342 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2343 "Could not get IDispatchEx interface: %08x\n", hres
);
2344 if(SUCCEEDED(hres
)) {
2345 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2346 IDispatchEx_Release(dispex
);
2349 IHTMLFiltersCollection_Release(filters
);
2352 IHTMLElement_Release(elem
);
2355 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2356 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2358 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2362 tmp
= class ? a2bstr(class) : NULL
;
2363 hres
= IHTMLElement_put_className(elem
, tmp
);
2364 IHTMLElement_Release(elem
);
2365 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
2368 _test_elem_class(line
, unk
, class);
2371 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2372 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
2374 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2375 BSTR id
= (void*)0xdeadbeef;
2378 hres
= IHTMLElement_get_id(elem
, &id
);
2379 IHTMLElement_Release(elem
);
2380 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
2383 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
2385 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
2390 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2391 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
2393 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2394 BSTR tmp
= a2bstr(new_id
);
2397 hres
= IHTMLElement_put_id(elem
, tmp
);
2398 IHTMLElement_Release(elem
);
2400 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
2402 _test_elem_id(line
, unk
, new_id
);
2405 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2406 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
2408 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2412 hres
= IHTMLElement_get_title(elem
, &title
);
2413 IHTMLElement_Release(elem
);
2414 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2416 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2418 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
2420 SysFreeString(title
);
2423 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2424 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
2426 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2430 tmp
= a2bstr(title
);
2431 hres
= IHTMLElement_put_title(elem
, tmp
);
2432 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2434 IHTMLElement_Release(elem
);
2438 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2439 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
2441 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2445 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
2446 IHTMLDOMNode_Release(node
);
2447 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2450 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
2451 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2453 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
2459 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2460 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
2462 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2466 V_VT(&var
) = VT_BSTR
;
2467 V_BSTR(&var
) = a2bstr(val
);
2469 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
2470 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2471 IHTMLDOMNode_Release(node
);
2475 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2476 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
2478 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2482 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
2483 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
2484 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
2485 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
2487 IHTMLElement2_Release(elem
);
2490 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2491 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
2493 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2497 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
2498 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
2499 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
2501 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
2502 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
2503 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
2505 IHTMLElement2_Release(elem
);
2508 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2509 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
2511 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2512 LONG len
= 0xdeadbeef;
2515 hres
= IHTMLFormElement_get_length(form
, &len
);
2516 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2517 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
2519 IHTMLFormElement_Release(form
);
2522 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2523 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
2525 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2526 IHTMLDocument2
*doc
;
2531 hres
= IHTMLElement_get_document(elem
, &disp
);
2532 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2533 ok(disp
!= NULL
, "disp == NULL\n");
2535 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
2536 IDispatch_Release(disp
);
2537 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
2542 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2543 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
2545 IHTMLDocument2
*doc
;
2549 hres
= IHTMLWindow2_get_document(window
, &doc
);
2550 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2551 ok(doc
!= NULL
, "disp == NULL\n");
2556 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2557 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
2559 IHTMLElement
*elem
= NULL
;
2564 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
2565 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2566 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
2571 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2572 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
2574 IHTMLDocument3
*doc3
;
2575 IHTMLDOMNode
*node
= NULL
;
2579 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2580 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
2583 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
2584 IHTMLDocument3_Release(doc3
);
2585 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2586 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
2591 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2592 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
2594 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2595 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
2596 IHTMLDOMNode
*new_child
= NULL
;
2599 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
2600 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
2601 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2602 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2604 IHTMLDOMNode_Release(node
);
2605 IHTMLDOMNode_Release(child
);
2610 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2611 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
2613 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2614 IHTMLDOMNode
*new_child
= NULL
;
2617 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
2618 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
2619 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2620 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2622 IHTMLDOMNode_Release(node
);
2627 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2628 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
2630 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2631 IHTMLDOMNode
*new_node
= NULL
;
2634 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
2635 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
2636 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
2637 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2639 IHTMLDOMNode_Release(node
);
2640 IHTMLDOMNode_Release(new_node
);
2643 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2644 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
2649 hres
= IHTMLDocument2_get_title(doc
, &title
);
2650 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2651 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2652 SysFreeString(title
);
2655 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2656 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
2661 tmp
= a2bstr(title
);
2662 hres
= IHTMLDocument2_put_title(doc
, tmp
);
2663 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2667 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2668 static void _test_border_styles(unsigned line
, IHTMLStyle
*pStyle
, BSTR Name
)
2673 hres
= IHTMLStyle_GetIDsOfNames(pStyle
, &IID_NULL
, &Name
, 1,
2674 LOCALE_USER_DEFAULT
, &dispid
);
2675 ok_(__FILE__
,line
) (hres
== S_OK
, "GetIDsOfNames: %08x\n", hres
);
2678 DISPPARAMS params
= {NULL
,NULL
,0,0};
2679 DISPID dispidNamed
= DISPID_PROPERTYPUT
;
2684 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2685 DISPATCH_PROPERTYGET
, ¶ms
, &vDefault
, NULL
, NULL
);
2686 ok_(__FILE__
,line
) (hres
== S_OK
, "get_default. ret: %08x\n", hres
);
2689 params
.cNamedArgs
= 1;
2690 params
.rgdispidNamedArgs
= &dispidNamed
;
2691 V_VT(&arg
) = VT_BSTR
;
2692 V_BSTR(&arg
) = a2bstr("none");
2693 params
.rgvarg
= &arg
;
2694 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2695 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2696 ok_(__FILE__
,line
) (hres
== S_OK
, "none. ret: %08x\n", hres
);
2699 V_VT(&arg
) = VT_BSTR
;
2700 V_BSTR(&arg
) = a2bstr("dotted");
2701 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2702 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2703 ok_(__FILE__
,line
) (hres
== S_OK
, "dotted. ret: %08x\n", hres
);
2706 V_VT(&arg
) = VT_BSTR
;
2707 V_BSTR(&arg
) = a2bstr("dashed");
2708 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2709 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2710 ok_(__FILE__
,line
) (hres
== S_OK
, "dashed. ret: %08x\n", hres
);
2713 V_VT(&arg
) = VT_BSTR
;
2714 V_BSTR(&arg
) = a2bstr("solid");
2715 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2716 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2717 ok_(__FILE__
,line
) (hres
== S_OK
, "solid. ret: %08x\n", hres
);
2720 V_VT(&arg
) = VT_BSTR
;
2721 V_BSTR(&arg
) = a2bstr("double");
2722 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2723 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2724 ok_(__FILE__
,line
) (hres
== S_OK
, "double. ret: %08x\n", hres
);
2727 V_VT(&arg
) = VT_BSTR
;
2728 V_BSTR(&arg
) = a2bstr("groove");
2729 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2730 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2731 ok_(__FILE__
,line
) (hres
== S_OK
, "groove. ret: %08x\n", hres
);
2734 V_VT(&arg
) = VT_BSTR
;
2735 V_BSTR(&arg
) = a2bstr("ridge");
2736 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2737 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2738 ok_(__FILE__
,line
) (hres
== S_OK
, "ridge. ret: %08x\n", hres
);
2741 V_VT(&arg
) = VT_BSTR
;
2742 V_BSTR(&arg
) = a2bstr("inset");
2743 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2744 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2745 ok_(__FILE__
,line
) (hres
== S_OK
, "inset. ret: %08x\n", hres
);
2748 V_VT(&arg
) = VT_BSTR
;
2749 V_BSTR(&arg
) = a2bstr("outset");
2750 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2751 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2752 ok_(__FILE__
,line
) (hres
== S_OK
, "outset. ret: %08x\n", hres
);
2755 V_VT(&arg
) = VT_BSTR
;
2756 V_BSTR(&arg
) = a2bstr("invalid");
2757 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2758 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2759 ok_(__FILE__
,line
) (FAILED(hres
), "invalid value passed.\n");
2762 params
.rgvarg
= &vDefault
;
2763 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2764 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2765 ok_(__FILE__
,line
) (hres
== S_OK
, "default. ret: %08x\n", hres
);
2769 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2770 static void _test_style_csstext(unsigned line
, IHTMLStyle
*style
, const char *extext
)
2772 BSTR text
= (void*)0xdeadbeef;
2775 hres
= IHTMLStyle_get_cssText(style
, &text
);
2776 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
2778 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "cssText = %s\n", wine_dbgstr_w(text
));
2780 ok_(__FILE__
,line
)(!text
, "cssText = %s\n", wine_dbgstr_w(text
));
2782 SysFreeString(text
);
2785 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2786 static void _test_style_set_csstext(unsigned line
, IHTMLStyle
*style
, const char *text
)
2792 hres
= IHTMLStyle_put_cssText(style
, tmp
);
2793 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
2797 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
2798 const elem_type_t
*elem_types
, LONG len
)
2801 VARIANT name
, index
;
2805 V_VT(&index
) = VT_EMPTY
;
2806 V_VT(&name
) = VT_BSTR
;
2807 V_BSTR(&name
) = a2bstr(n
);
2809 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2810 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2812 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
2813 IDispatch_Release(disp
);
2814 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
2818 V_VT(&index
) = VT_I4
;
2820 for(i
=0; i
<len
; i
++) {
2822 disp
= (void*)0xdeadbeef;
2823 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2824 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2825 ok(disp
!= NULL
, "disp == NULL\n");
2826 if(FAILED(hres
) || !disp
)
2829 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
2831 IDispatch_Release(disp
);
2835 disp
= (void*)0xdeadbeef;
2836 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2837 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2838 ok(disp
== NULL
, "disp != NULL\n");
2841 disp
= (void*)0xdeadbeef;
2842 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2843 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2844 ok(disp
== NULL
, "disp != NULL\n");
2847 SysFreeString(V_BSTR(&name
));
2850 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
2852 IHTMLElementCollection
*col
;
2854 IDispatch
*disp
= (void*)0xdeadbeef;
2855 VARIANT name
, index
;
2858 hres
= IHTMLDocument2_get_all(doc
, &col
);
2859 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2860 ok(col
!= NULL
, "col == NULL\n");
2861 if(FAILED(hres
) || !col
)
2864 V_VT(&index
) = VT_EMPTY
;
2865 V_VT(&name
) = VT_BSTR
;
2866 V_BSTR(&name
) = a2bstr(id
);
2868 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2869 IHTMLElementCollection_Release(col
);
2870 SysFreeString(V_BSTR(&name
));
2871 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2872 if(!expect_success
) {
2873 ok(disp
== NULL
, "disp != NULL\n");
2877 ok(disp
!= NULL
, "disp == NULL\n");
2881 elem
= get_elem_iface((IUnknown
*)disp
);
2882 IDispatch_Release(disp
);
2887 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
2889 IHTMLDocument3
*doc3
;
2894 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2895 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
2898 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
2900 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
2902 IHTMLDocument3_Release(doc3
);
2907 static void test_select_elem(IHTMLSelectElement
*select
)
2909 IDispatch
*disp
, *disp2
;
2910 VARIANT name
, index
;
2913 test_select_type(select
, "select-one");
2914 test_select_length(select
, 2);
2915 test_select_selidx(select
, 0);
2916 test_select_put_selidx(select
, 1);
2918 test_select_set_value(select
, "val1");
2919 test_select_value(select
, "val1");
2921 test_select_get_disabled(select
, VARIANT_FALSE
);
2922 test_select_set_disabled(select
, VARIANT_TRUE
);
2923 test_select_set_disabled(select
, VARIANT_FALSE
);
2926 hres
= IHTMLSelectElement_get_options(select
, &disp
);
2927 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
2928 ok(disp
!= NULL
, "options == NULL\n");
2929 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
2930 IDispatch_Release(disp
);
2932 V_VT(&index
) = VT_EMPTY
;
2933 V_VT(&name
) = VT_I4
;
2935 disp
= (void*)0xdeadbeef;
2936 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
2937 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2938 ok(!disp
, "disp = %p\n", disp
);
2941 disp
= (void*)0xdeadbeef;
2942 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
2943 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2944 ok(!disp
, "disp = %p\n", disp
);
2947 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
2948 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
2951 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
2952 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2953 ok(disp
!= NULL
, "disp = NULL\n");
2954 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
2956 V_VT(&index
) = VT_I4
;
2959 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
2960 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2961 ok(disp2
!= NULL
, "disp = NULL\n");
2962 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2963 IDispatch_Release(disp2
);
2964 IDispatch_Release(disp
);
2967 static void test_create_option_elem(IHTMLDocument2
*doc
)
2969 IHTMLOptionElement
*option
;
2971 option
= create_option_elem(doc
, "test text", "test value");
2973 test_option_put_text(option
, "new text");
2974 test_option_put_value(option
, "new value");
2975 test_option_put_selected(option
, VARIANT_TRUE
);
2976 test_option_put_selected(option
, VARIANT_FALSE
);
2978 IHTMLOptionElement_Release(option
);
2981 static void test_create_img_elem(IHTMLDocument2
*doc
)
2983 IHTMLImgElement
*img
;
2985 img
= create_img_elem(doc
, 10, 15);
2988 test_img_put_width(img
, 5);
2989 test_img_put_height(img
, 20);
2991 IHTMLImgElement_Release(img
);
2995 img
= create_img_elem(doc
, -1, -1);
2998 test_img_put_width(img
, 5);
2999 test_img_put_height(img
, 20);
3001 IHTMLImgElement_Release(img
);
3005 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
3007 IHTMLBodyElement
*body
;
3008 IHTMLTxtRange
*range
;
3012 hres
= IHTMLDocument2_get_body(doc
, &elem
);
3013 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3015 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
3016 IHTMLElement_Release(elem
);
3018 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
3019 IHTMLBodyElement_Release(body
);
3020 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
3025 static void test_txtrange(IHTMLDocument2
*doc
)
3027 IHTMLTxtRange
*body_range
, *range
, *range2
;
3028 IHTMLSelectionObject
*selection
;
3029 IDispatch
*disp_range
;
3032 body_range
= test_create_body_range(doc
);
3034 test_range_text(body_range
, "test abc 123\r\nit's text");
3036 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3037 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3039 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
3040 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3041 test_range_isequal(range
, range2
, VARIANT_TRUE
);
3043 test_range_text(range
, "test abc 123\r\nit's text");
3044 test_range_text(body_range
, "test abc 123\r\nit's text");
3046 test_range_collapse(range
, TRUE
);
3047 test_range_isequal(range
, range2
, VARIANT_FALSE
);
3048 test_range_inrange(range
, range2
, VARIANT_FALSE
);
3049 test_range_inrange(range2
, range
, VARIANT_TRUE
);
3050 IHTMLTxtRange_Release(range2
);
3052 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3053 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
3054 test_range_move(range
, characterW
, 2, 2);
3055 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3057 test_range_collapse(range
, FALSE
);
3058 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
3060 test_range_collapse(range
, FALSE
);
3061 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3062 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
3063 test_range_move(range
, characterW
, 2, 2);
3064 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
3065 test_range_moveend(range
, characterW
, -5, -5);
3066 test_range_text(range
, NULL
);
3067 test_range_moveend(range
, characterW
, 3, 3);
3068 test_range_text(range
, "c 1");
3069 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
3070 test_range_collapse(range
, TRUE
);
3071 test_range_move(range
, characterW
, 4, 4);
3072 test_range_moveend(range
, characterW
, 1, 1);
3073 test_range_text(range
, " ");
3074 test_range_move(range
, wordW
, 1, 1);
3075 test_range_moveend(range
, characterW
, 2, 2);
3076 test_range_text(range
, "ab");
3078 IHTMLTxtRange_Release(range
);
3080 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3081 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3083 test_range_text(range
, "test abc 123\r\nit's text");
3084 test_range_move(range
, characterW
, 3, 3);
3085 test_range_moveend(range
, characterW
, 1, 1);
3086 test_range_text(range
, "t");
3087 test_range_moveend(range
, characterW
, 3, 3);
3088 test_range_text(range
, "t ab");
3089 test_range_moveend(range
, characterW
, -2, -2);
3090 test_range_text(range
, "t ");
3091 test_range_move(range
, characterW
, 6, 6);
3092 test_range_moveend(range
, characterW
, 3, 3);
3093 test_range_text(range
, "123");
3094 test_range_moveend(range
, characterW
, 2, 2);
3095 test_range_text(range
, "123\r\ni");
3097 IHTMLTxtRange_Release(range
);
3099 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3100 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3102 test_range_move(range
, wordW
, 1, 1);
3103 test_range_moveend(range
, characterW
, 2, 2);
3104 test_range_text(range
, "ab");
3106 test_range_move(range
, characterW
, -2, -2);
3107 test_range_moveend(range
, characterW
, 2, 2);
3108 test_range_text(range
, "t ");
3110 test_range_move(range
, wordW
, 3, 3);
3111 test_range_move(range
, wordW
, -2, -2);
3112 test_range_moveend(range
, characterW
, 2, 2);
3113 test_range_text(range
, "ab");
3115 test_range_move(range
, characterW
, -6, -5);
3116 test_range_moveend(range
, characterW
, -1, 0);
3117 test_range_moveend(range
, characterW
, -6, 0);
3118 test_range_move(range
, characterW
, 2, 2);
3119 test_range_moveend(range
, characterW
, 2, 2);
3120 test_range_text(range
, "st");
3121 test_range_moveend(range
, characterW
, -6, -4);
3122 test_range_moveend(range
, characterW
, 2, 2);
3124 IHTMLTxtRange_Release(range
);
3126 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3127 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3129 test_range_move(range
, wordW
, 2, 2);
3130 test_range_moveend(range
, characterW
, 2, 2);
3131 test_range_text(range
, "12");
3133 test_range_move(range
, characterW
, 15, 14);
3134 test_range_move(range
, characterW
, -2, -2);
3135 test_range_moveend(range
, characterW
, 3, 2);
3136 test_range_text(range
, "t");
3137 test_range_moveend(range
, characterW
, -1, -1);
3138 test_range_text(range
, "t");
3139 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
3140 test_range_move(range
, characterW
, -2, -2);
3141 test_range_moveend(range
, characterW
, 2, 2);
3142 test_range_text(range
, "s ");
3143 test_range_move(range
, characterW
, 100, 7);
3144 test_range_move(range
, wordW
, 1, 0);
3145 test_range_move(range
, characterW
, -2, -2);
3146 test_range_moveend(range
, characterW
, 3, 2);
3147 test_range_text(range
, "t");
3149 IHTMLTxtRange_Release(range
);
3151 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3152 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3154 test_range_collapse(range
, TRUE
);
3155 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3156 test_range_put_text(range
, "word");
3157 test_range_text(body_range
, "wordabc 123\r\nit's text");
3158 test_range_text(range
, NULL
);
3159 test_range_moveend(range
, characterW
, 3, 3);
3160 test_range_text(range
, "abc");
3161 test_range_movestart(range
, characterW
, -2, -2);
3162 test_range_text(range
, "rdabc");
3163 test_range_movestart(range
, characterW
, 3, 3);
3164 test_range_text(range
, "bc");
3165 test_range_movestart(range
, characterW
, 4, 4);
3166 test_range_text(range
, NULL
);
3167 test_range_movestart(range
, characterW
, -3, -3);
3168 test_range_text(range
, "c 1");
3169 test_range_movestart(range
, characterW
, -7, -6);
3170 test_range_text(range
, "wordabc 1");
3171 test_range_movestart(range
, characterW
, 100, 22);
3172 test_range_text(range
, NULL
);
3174 IHTMLTxtRange_Release(range
);
3175 IHTMLTxtRange_Release(body_range
);
3177 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
3178 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
3180 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
3181 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
3182 IHTMLSelectionObject_Release(selection
);
3184 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
3185 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
3186 IDispatch_Release(disp_range
);
3188 test_range_text(range
, NULL
);
3189 test_range_moveend(range
, characterW
, 3, 3);
3190 test_range_text(range
, "wor");
3191 test_range_parent(range
, ET_BODY
);
3192 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3193 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3194 test_range_move(range
, characterW
, 3, 3);
3195 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
3196 test_range_moveend(range
, characterW
, -4, -4);
3197 test_range_put_text(range
, "abc def ");
3198 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
3199 test_range_move(range
, wordW
, 1, 1);
3200 test_range_movestart(range
, characterW
, -1, -1);
3201 test_range_text(range
, " ");
3202 test_range_move(range
, wordW
, 1, 1);
3203 test_range_moveend(range
, characterW
, 3, 3);
3204 test_range_text(range
, "def");
3205 test_range_put_text(range
, "xyz");
3206 test_range_moveend(range
, characterW
, 1, 1);
3207 test_range_move(range
, wordW
, 1, 1);
3208 test_range_moveend(range
, characterW
, 2, 2);
3209 test_range_text(range
, "ab");
3211 IHTMLTxtRange_Release(range
);
3214 static void test_txtrange2(IHTMLDocument2
*doc
)
3216 IHTMLTxtRange
*range
;
3218 range
= test_create_body_range(doc
);
3220 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3221 test_range_move(range
, characterW
, 5, 5);
3222 test_range_moveend(range
, characterW
, 1, 1);
3223 test_range_text(range
, "2");
3224 test_range_move(range
, characterW
, -3, -3);
3225 test_range_moveend(range
, characterW
, 3, 3);
3226 test_range_text(range
, "c\r\n\r\n1");
3227 test_range_collapse(range
, VARIANT_FALSE
);
3228 test_range_moveend(range
, characterW
, 4, 4);
3229 test_range_text(range
, "23");
3230 test_range_moveend(range
, characterW
, 1, 1);
3231 test_range_text(range
, "23\r\n\r\n\r\nd");
3232 test_range_moveend(range
, characterW
, -1, -1);
3233 test_range_text(range
, "23");
3234 test_range_moveend(range
, characterW
, -1, -1);
3235 test_range_text(range
, "23");
3236 test_range_moveend(range
, characterW
, -2, -2);
3237 test_range_text(range
, "2");
3239 IHTMLTxtRange_Release(range
);
3242 static void test_compatmode(IHTMLDocument2
*doc
)
3244 IHTMLDocument5
*doc5
;
3248 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3249 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
3253 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
3254 IHTMLDocument5_Release(doc5
);
3255 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
3256 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
3257 SysFreeString(mode
);
3260 static void test_location(IHTMLDocument2
*doc
)
3262 IHTMLLocation
*location
, *location2
;
3263 IHTMLWindow2
*window
;
3268 hres
= IHTMLDocument2_get_location(doc
, &location
);
3269 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3271 hres
= IHTMLDocument2_get_location(doc
, &location2
);
3272 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3274 ok(location
== location2
, "location != location2\n");
3275 IHTMLLocation_Release(location2
);
3277 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3278 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3280 hres
= IHTMLWindow2_get_location(window
, &location2
);
3281 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3282 ok(location
== location2
, "location != location2\n");
3283 IHTMLLocation_Release(location2
);
3285 test_ifaces((IUnknown
*)location
, location_iids
);
3286 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
3288 hres
= IHTMLLocation_get_pathname(location
, &str
);
3289 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
3290 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
3292 hres
= IHTMLLocation_get_href(location
, NULL
);
3293 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
3295 hres
= IHTMLLocation_get_href(location
, &str
);
3296 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
3297 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
3299 ref
= IHTMLLocation_Release(location
);
3300 ok(!ref
, "location chould be destroyed here\n");
3303 static void test_navigator(IHTMLDocument2
*doc
)
3305 IHTMLWindow2
*window
;
3306 IOmNavigator
*navigator
, *navigator2
;
3313 static const WCHAR v40
[] = {'4','.','0'};
3315 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3316 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
3318 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
3319 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3320 ok(navigator
!= NULL
, "navigator == NULL\n");
3321 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
3323 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
3324 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3325 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
3327 IHTMLWindow2_Release(window
);
3328 IOmNavigator_Release(navigator2
);
3330 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
3331 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
3332 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3333 SysFreeString(bstr
);
3336 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
3337 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
3338 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3339 SysFreeString(bstr
);
3342 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
3343 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
3345 ok(!strcmp_wa(bstr
, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3347 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3349 SysFreeString(bstr
);
3352 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3353 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3354 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
3355 SysFreeString(bstr
);
3357 hres
= IOmNavigator_toString(navigator
, NULL
);
3358 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
3361 hres
= IOmNavigator_toString(navigator
, &bstr
);
3362 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
3363 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
3364 SysFreeString(bstr
);
3367 hres
= ObtainUserAgentString(0, buf
, &size
);
3368 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
3371 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
3372 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
3373 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
3374 SysFreeString(bstr
);
3376 if(!strncmp(buf
, "Mozilla/", 8)) {
3378 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3379 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3380 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
3381 SysFreeString(bstr
);
3383 skip("nonstandard user agent\n");
3386 ref
= IOmNavigator_Release(navigator
);
3387 ok(!ref
, "navigator should be destroyed here\n");
3390 static void test_screen(IHTMLWindow2
*window
)
3392 IHTMLScreen
*screen
, *screen2
;
3393 IDispatchEx
*dispex
;
3399 hres
= IHTMLWindow2_get_screen(window
, &screen
);
3400 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3401 ok(screen
!= NULL
, "screen == NULL\n");
3404 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
3405 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3406 ok(screen2
!= NULL
, "screen == NULL\n");
3407 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
3408 IHTMLScreen_Release(screen2
);
3410 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
3411 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
3412 if(SUCCEEDED(hres
)) {
3413 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
3414 IDispatchEx_Release(dispex
);
3417 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
3419 exl
= GetDeviceCaps(hdc
, HORZRES
);
3421 hres
= IHTMLScreen_get_width(screen
, &l
);
3422 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3423 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
3425 exl
= GetDeviceCaps(hdc
, VERTRES
);
3427 hres
= IHTMLScreen_get_height(screen
, &l
);
3428 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3429 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3431 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
3433 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
3434 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3435 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3439 IHTMLScreen_Release(screen
);
3442 static void test_current_style(IHTMLCurrentStyle
*current_style
)
3448 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
, "[object]");
3449 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
3451 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
3452 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3453 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", wine_dbgstr_w(str
));
3456 hres
= IHTMLCurrentStyle_get_position(current_style
, &str
);
3457 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3458 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3461 hres
= IHTMLCurrentStyle_get_fontFamily(current_style
, &str
);
3462 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3465 hres
= IHTMLCurrentStyle_get_fontStyle(current_style
, &str
);
3466 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
3467 ok(!strcmp_wa(str
, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str
));
3470 hres
= IHTMLCurrentStyle_get_backgroundImage(current_style
, &str
);
3471 ok(hres
== S_OK
, "get_backgroundImage failed: %08x\n", hres
);
3472 ok(!strcmp_wa(str
, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str
));
3475 hres
= IHTMLCurrentStyle_get_fontVariant(current_style
, &str
);
3476 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3477 ok(!strcmp_wa(str
, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str
));
3480 hres
= IHTMLCurrentStyle_get_borderTopStyle(current_style
, &str
);
3481 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
3482 ok(!strcmp_wa(str
, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str
));
3485 hres
= IHTMLCurrentStyle_get_borderRightStyle(current_style
, &str
);
3486 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
3487 ok(!strcmp_wa(str
, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str
));
3490 hres
= IHTMLCurrentStyle_get_borderBottomStyle(current_style
, &str
);
3491 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
3492 ok(!strcmp_wa(str
, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str
));
3495 hres
= IHTMLCurrentStyle_get_borderLeftStyle(current_style
, &str
);
3496 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
3497 ok(!strcmp_wa(str
, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str
));
3500 hres
= IHTMLCurrentStyle_get_textAlign(current_style
, &str
);
3501 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
3502 ok(!strcmp_wa(str
, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str
));
3505 hres
= IHTMLCurrentStyle_get_textDecoration(current_style
, &str
);
3506 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3507 ok(!strcmp_wa(str
, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str
));
3510 hres
= IHTMLCurrentStyle_get_cursor(current_style
, &str
);
3511 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
3512 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
3515 hres
= IHTMLCurrentStyle_get_backgroundRepeat(current_style
, &str
);
3516 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
3517 ok(!strcmp_wa(str
, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str
));
3520 hres
= IHTMLCurrentStyle_get_borderColor(current_style
, &str
);
3521 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
3524 hres
= IHTMLCurrentStyle_get_borderStyle(current_style
, &str
);
3525 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
3528 hres
= IHTMLCurrentStyle_get_visibility(current_style
, &str
);
3529 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3532 hres
= IHTMLCurrentStyle_get_overflow(current_style
, &str
);
3533 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
3536 hres
= IHTMLCurrentStyle_get_borderWidth(current_style
, &str
);
3537 ok(hres
== S_OK
, "get_borderWidth failed: %08x\n", hres
);
3540 hres
= IHTMLCurrentStyle_get_margin(current_style
, &str
);
3541 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3544 hres
= IHTMLCurrentStyle_get_fontWeight(current_style
, &v
);
3545 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3546 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3547 ok( V_I4(&v
) == 400, "expect 400 got (%d)\n", V_I4(&v
));
3550 hres
= IHTMLCurrentStyle_get_fontSize(current_style
, &v
);
3551 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3552 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3555 hres
= IHTMLCurrentStyle_get_left(current_style
, &v
);
3556 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3557 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3560 hres
= IHTMLCurrentStyle_get_top(current_style
, &v
);
3561 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3562 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3565 hres
= IHTMLCurrentStyle_get_width(current_style
, &v
);
3566 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3567 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3570 hres
= IHTMLCurrentStyle_get_height(current_style
, &v
);
3571 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3572 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3575 hres
= IHTMLCurrentStyle_get_paddingLeft(current_style
, &v
);
3576 ok(hres
== S_OK
, "get_paddingLeft failed: %08x\n", hres
);
3577 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3580 hres
= IHTMLCurrentStyle_get_zIndex(current_style
, &v
);
3581 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
3582 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3583 ok( V_I4(&v
) == 1, "expect 1 got (%d)\n", V_I4(&v
));
3586 hres
= IHTMLCurrentStyle_get_verticalAlign(current_style
, &v
);
3587 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
3588 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3589 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3592 hres
= IHTMLCurrentStyle_get_marginRight(current_style
, &v
);
3593 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3594 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3597 hres
= IHTMLCurrentStyle_get_marginLeft(current_style
, &v
);
3598 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3599 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3602 hres
= IHTMLCurrentStyle_get_borderLeftWidth(current_style
, &v
);
3603 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
3604 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3608 hres
= IHTMLCurrentStyle_get_borderRightWidth(current_style
, &v
);
3609 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
3610 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3613 hres
= IHTMLCurrentStyle_get_borderBottomWidth(current_style
, &v
);
3614 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
3615 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3618 hres
= IHTMLCurrentStyle_get_borderTopWidth(current_style
, &v
);
3619 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
3620 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3623 hres
= IHTMLCurrentStyle_get_color(current_style
, &v
);
3624 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3625 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3628 hres
= IHTMLCurrentStyle_get_backgroundColor(current_style
, &v
);
3629 ok(hres
== S_OK
, "get_backgroundColor failed: %08x\n", hres
);
3630 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3633 hres
= IHTMLCurrentStyle_get_borderLeftColor(current_style
, &v
);
3634 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
3635 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3638 hres
= IHTMLCurrentStyle_get_borderTopColor(current_style
, &v
);
3639 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
3640 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3643 hres
= IHTMLCurrentStyle_get_borderRightColor(current_style
, &v
);
3644 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
3645 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3648 hres
= IHTMLCurrentStyle_get_borderBottomColor(current_style
, &v
);
3649 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
3650 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3653 hres
= IHTMLCurrentStyle_get_paddingTop(current_style
, &v
);
3654 ok(hres
== S_OK
, "get_paddingTop failed: %08x\n", hres
);
3655 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3658 hres
= IHTMLCurrentStyle_get_paddingRight(current_style
, &v
);
3659 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3660 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3663 hres
= IHTMLCurrentStyle_get_paddingBottom(current_style
, &v
);
3664 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3665 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3668 hres
= IHTMLCurrentStyle_get_letterSpacing(current_style
, &v
);
3669 ok(hres
== S_OK
, "get_letterSpacing failed: %08x\n", hres
);
3670 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3673 hres
= IHTMLCurrentStyle_get_marginTop(current_style
, &v
);
3674 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3675 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3678 hres
= IHTMLCurrentStyle_get_marginBottom(current_style
, &v
);
3679 ok(hres
== S_OK
, "get_marginBottom failed: %08x\n", hres
);
3680 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3683 hres
= IHTMLCurrentStyle_get_right(current_style
, &v
);
3684 ok(hres
== S_OK
, "get_Right failed: %08x\n", hres
);
3685 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3688 hres
= IHTMLCurrentStyle_get_bottom(current_style
, &v
);
3689 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3690 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3693 hres
= IHTMLCurrentStyle_get_lineHeight(current_style
, &v
);
3694 ok(hres
== S_OK
, "get_lineHeight failed: %08x\n", hres
);
3695 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3698 hres
= IHTMLCurrentStyle_get_textIndent(current_style
, &v
);
3699 ok(hres
== S_OK
, "get_textIndent failed: %08x\n", hres
);
3700 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3704 static void test_style2(IHTMLStyle2
*style2
)
3710 str
= (void*)0xdeadbeef;
3711 hres
= IHTMLStyle2_get_position(style2
, &str
);
3712 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3713 ok(!str
, "str != NULL\n");
3715 str
= a2bstr("absolute");
3716 hres
= IHTMLStyle2_put_position(style2
, str
);
3717 ok(hres
== S_OK
, "put_position failed: %08x\n", hres
);
3721 hres
= IHTMLStyle2_get_position(style2
, &str
);
3722 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3723 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3727 V_VT(&v
) = VT_EMPTY
;
3728 hres
= IHTMLStyle2_get_right(style2
, &v
);
3729 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3730 ok(V_VT(&v
) == VT_BSTR
, "V_VT(right)=%d\n", V_VT(&v
));
3731 ok(!V_BSTR(&v
), "V_BSTR(right) != NULL\n");
3735 V_BSTR(&v
) = a2bstr("3px");
3736 hres
= IHTMLStyle2_put_right(style2
, v
);
3737 ok(hres
== S_OK
, "put_right failed: %08x\n", hres
);
3740 V_VT(&v
) = VT_EMPTY
;
3741 hres
= IHTMLStyle2_get_right(style2
, &v
);
3742 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3743 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3744 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3748 static void test_style3(IHTMLStyle3
*style3
)
3753 str
= (void*)0xdeadbeef;
3754 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3755 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3756 ok(!str
, "str != NULL\n");
3758 str
= a2bstr("break-word");
3759 hres
= IHTMLStyle3_put_wordWrap(style3
, str
);
3760 ok(hres
== S_OK
, "put_wordWrap failed: %08x\n", hres
);
3764 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3765 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3766 ok(!strcmp_wa(str
, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str
));
3770 static void test_style4(IHTMLStyle4
*style4
)
3776 hres
= IHTMLStyle4_get_minHeight(style4
, &vdefault
);
3777 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3780 V_BSTR(&v
) = a2bstr("10px");
3781 hres
= IHTMLStyle4_put_minHeight(style4
, v
);
3782 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3785 hres
= IHTMLStyle4_get_minHeight(style4
, &v
);
3786 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3787 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3788 ok( !strcmp_wa(V_BSTR(&v
), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
3790 hres
= IHTMLStyle4_put_minHeight(style4
, vdefault
);
3791 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3792 VariantClear(&vdefault
);
3795 static void test_default_style(IHTMLStyle
*style
)
3797 IHTMLStyle2
*style2
;
3798 IHTMLStyle3
*style3
;
3799 IHTMLStyle4
*style4
;
3805 BSTR sOverflowDefault
;
3809 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
3810 test_ifaces((IUnknown
*)style
, style_iids
);
3812 test_style_csstext(style
, NULL
);
3814 hres
= IHTMLStyle_get_position(style
, &str
);
3815 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3816 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
3819 hres
= IHTMLStyle_get_marginRight(style
, &v
);
3820 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3821 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginRight) = %d\n", V_VT(&v
));
3822 ok(!V_BSTR(&v
), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3825 hres
= IHTMLStyle_get_marginLeft(style
, &v
);
3826 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3827 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginLeft) = %d\n", V_VT(&v
));
3828 ok(!V_BSTR(&v
), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3830 str
= (void*)0xdeadbeef;
3831 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
3832 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3833 ok(!str
, "fontFamily = %s\n", wine_dbgstr_w(str
));
3835 str
= (void*)0xdeadbeef;
3836 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3837 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3838 ok(!str
, "fontWeight = %s\n", wine_dbgstr_w(str
));
3840 hres
= IHTMLStyle_get_fontWeight(style
, &sDefault
);
3841 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3843 str
= a2bstr("test");
3844 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3845 ok(hres
== E_INVALIDARG
, "put_fontWeight failed: %08x\n", hres
);
3848 str
= a2bstr("bold");
3849 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3850 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3853 str
= a2bstr("bolder");
3854 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3855 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3858 str
= a2bstr("lighter");
3859 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3860 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3863 str
= a2bstr("100");
3864 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3865 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3868 str
= a2bstr("200");
3869 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3870 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3873 str
= a2bstr("300");
3874 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3875 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3878 str
= a2bstr("400");
3879 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3880 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3883 str
= a2bstr("500");
3884 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3885 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3888 str
= a2bstr("600");
3889 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3890 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3893 str
= a2bstr("700");
3894 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3895 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3898 str
= a2bstr("800");
3899 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3900 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3903 str
= a2bstr("900");
3904 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3905 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3908 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3909 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3910 ok(!strcmp_wa(str
, "900"), "str != style900\n");
3913 hres
= IHTMLStyle_put_fontWeight(style
, sDefault
);
3914 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3915 SysFreeString(sDefault
);
3918 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
3919 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
3921 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
3922 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3924 str
= a2bstr("test");
3925 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3926 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
3929 str
= a2bstr("small-caps");
3930 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3931 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3934 str
= a2bstr("normal");
3935 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3936 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3939 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
3940 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3941 SysFreeString(sDefault
);
3943 str
= (void*)0xdeadbeef;
3944 hres
= IHTMLStyle_get_display(style
, &str
);
3945 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3946 ok(!str
, "display = %s\n", wine_dbgstr_w(str
));
3948 str
= (void*)0xdeadbeef;
3949 hres
= IHTMLStyle_get_visibility(style
, &str
);
3950 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3951 ok(!str
, "visibility = %s\n", wine_dbgstr_w(str
));
3954 hres
= IHTMLStyle_get_fontSize(style
, &v
);
3955 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3956 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
3957 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3960 hres
= IHTMLStyle_get_color(style
, &v
);
3961 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3962 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
3963 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3966 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3967 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3968 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3970 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_TRUE
);
3971 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3972 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3974 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3975 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3976 ok(b
== VARIANT_TRUE
, "textDecorationUnderline = %x\n", b
);
3978 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_FALSE
);
3979 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3982 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3983 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3984 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3986 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_TRUE
);
3987 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3988 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3990 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3991 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3992 ok(b
== VARIANT_TRUE
, "textDecorationLineThrough = %x\n", b
);
3994 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_FALSE
);
3995 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3998 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3999 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
4000 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
4002 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_TRUE
);
4003 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
4004 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
4006 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
4007 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
4008 ok(b
== VARIANT_TRUE
, "textDecorationNone = %x\n", b
);
4010 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_FALSE
);
4011 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
4014 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
4015 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
4016 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
4018 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_TRUE
);
4019 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
4020 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
4022 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
4023 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
4024 ok(b
== VARIANT_TRUE
, "textDecorationOverline = %x\n", b
);
4026 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_FALSE
);
4027 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
4030 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
4031 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
4032 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
4034 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_TRUE
);
4035 ok(hres
== S_OK
, "put_textDecorationBlink failed: %08x\n", hres
);
4036 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
4038 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
4039 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
4040 ok(b
== VARIANT_TRUE
, "textDecorationBlink = %x\n", b
);
4042 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_FALSE
);
4043 ok(hres
== S_OK
, "textDecorationBlink failed: %08x\n", hres
);
4045 hres
= IHTMLStyle_get_textDecoration(style
, &sDefault
);
4046 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
4048 str
= a2bstr("invalid");
4049 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4050 ok(hres
== E_INVALIDARG
, "put_textDecoration failed: %08x\n", hres
);
4053 str
= a2bstr("none");
4054 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4055 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4058 str
= a2bstr("underline");
4059 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4060 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4063 str
= a2bstr("overline");
4064 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4065 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4068 str
= a2bstr("line-through");
4069 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4070 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4073 str
= a2bstr("blink");
4074 hres
= IHTMLStyle_put_textDecoration(style
, str
);
4075 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4078 hres
= IHTMLStyle_get_textDecoration(style
, &str
);
4079 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
4080 ok(!strcmp_wa(str
, "blink"), "str != blink\n");
4083 hres
= IHTMLStyle_put_textDecoration(style
, sDefault
);
4084 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
4085 SysFreeString(sDefault
);
4087 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
4088 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
4090 hres
= IHTMLStyle_get_posWidth(style
, &f
);
4091 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
4092 ok(f
== 0.0f
, "f = %f\n", f
);
4094 V_VT(&v
) = VT_EMPTY
;
4095 hres
= IHTMLStyle_get_width(style
, &v
);
4096 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4097 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4098 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
4100 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
4101 ok(hres
== S_OK
, "put_posWidth failed: %08x\n", hres
);
4103 hres
= IHTMLStyle_get_posWidth(style
, &f
);
4104 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
4106 f
== 2.2f
, /* IE8 */
4110 V_BSTR(&v
) = a2bstr("auto");
4111 hres
= IHTMLStyle_put_width(style
, v
);
4112 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4115 V_VT(&v
) = VT_EMPTY
;
4116 hres
= IHTMLStyle_get_width(style
, &v
);
4117 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4118 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4119 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4124 hres
= IHTMLStyle_put_width(style
, v
);
4125 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4127 V_VT(&v
) = VT_EMPTY
;
4128 hres
= IHTMLStyle_get_width(style
, &v
);
4129 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4130 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4131 ok(!strcmp_wa(V_BSTR(&v
), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4135 str
= (void*)0xdeadbeef;
4136 hres
= IHTMLStyle_get_margin(style
, &str
);
4137 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4138 ok(!str
, "margin = %s\n", wine_dbgstr_w(str
));
4141 hres
= IHTMLStyle_put_margin(style
, str
);
4142 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4145 hres
= IHTMLStyle_get_margin(style
, &str
);
4146 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4147 ok(!strcmp_wa(str
, "1px"), "margin = %s\n", wine_dbgstr_w(str
));
4149 hres
= IHTMLStyle_put_margin(style
, NULL
);
4150 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4152 str
= (void*)0xdeadbeef;
4153 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4154 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4155 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4156 ok(!V_BSTR(&v
), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4159 V_BSTR(&v
) = a2bstr("6px");
4160 hres
= IHTMLStyle_put_marginTop(style
, v
);
4161 SysFreeString(V_BSTR(&v
));
4162 ok(hres
== S_OK
, "put_marginTop failed: %08x\n", hres
);
4164 str
= (void*)0xdeadbeef;
4165 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4166 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4167 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4168 ok(!strcmp_wa(V_BSTR(&v
), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4171 hres
= IHTMLStyle_get_border(style
, &str
);
4172 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
4173 ok(!str
|| !*str
, "str is not empty\n");
4176 str
= a2bstr("1px");
4177 hres
= IHTMLStyle_put_border(style
, str
);
4178 ok(hres
== S_OK
, "put_border failed: %08x\n", hres
);
4181 V_VT(&v
) = VT_EMPTY
;
4182 hres
= IHTMLStyle_get_left(style
, &v
);
4183 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4184 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4185 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4189 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
4190 ok(hres
== E_POINTER
, "get_posLeft failed: %08x\n", hres
);
4193 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4194 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4195 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4197 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
4198 ok(hres
== S_OK
, "put_posLeft failed: %08x\n", hres
);
4200 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4201 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4203 f
== 4.9f
, /* IE8 */
4204 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4206 /* Ensure left is updated correctly. */
4207 V_VT(&v
) = VT_EMPTY
;
4208 hres
= IHTMLStyle_get_left(style
, &v
);
4209 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4210 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4211 ok(!strcmp_wa(V_BSTR(&v
), "4px") ||
4212 !strcmp_wa(V_BSTR(&v
), "4.9px"), /* IE8 */
4213 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4218 V_BSTR(&v
) = a2bstr("3px");
4219 hres
= IHTMLStyle_put_left(style
, v
);
4220 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4223 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4224 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4225 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4227 V_VT(&v
) = VT_EMPTY
;
4228 hres
= IHTMLStyle_get_left(style
, &v
);
4229 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4230 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4231 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4235 hres
= IHTMLStyle_put_left(style
, v
);
4236 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4238 V_VT(&v
) = VT_EMPTY
;
4239 hres
= IHTMLStyle_get_left(style
, &v
);
4240 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4241 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4242 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4245 V_VT(&v
) = VT_EMPTY
;
4246 hres
= IHTMLStyle_get_top(style
, &v
);
4247 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4248 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4249 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4253 hres
= IHTMLStyle_get_posTop(style
, NULL
);
4254 ok(hres
== E_POINTER
, "get_posTop failed: %08x\n", hres
);
4257 hres
= IHTMLStyle_get_posTop(style
, &f
);
4258 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4259 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4261 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
4262 ok(hres
== S_OK
, "put_posTop failed: %08x\n", hres
);
4264 hres
= IHTMLStyle_get_posTop(style
, &f
);
4265 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4267 f
== 4.9f
, /* IE8 */
4268 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4271 V_BSTR(&v
) = a2bstr("3px");
4272 hres
= IHTMLStyle_put_top(style
, v
);
4273 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4276 V_VT(&v
) = VT_EMPTY
;
4277 hres
= IHTMLStyle_get_top(style
, &v
);
4278 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4279 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4280 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4283 hres
= IHTMLStyle_get_posTop(style
, &f
);
4284 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4285 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4288 hres
= IHTMLStyle_put_top(style
, v
);
4289 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4291 V_VT(&v
) = VT_EMPTY
;
4292 hres
= IHTMLStyle_get_top(style
, &v
);
4293 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4294 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4295 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4298 /* Test posHeight */
4299 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
4300 ok(hres
== E_POINTER
, "get_posHeight failed: %08x\n", hres
);
4302 V_VT(&v
) = VT_EMPTY
;
4303 hres
= IHTMLStyle_get_height(style
, &v
);
4304 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4305 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4306 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4310 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4311 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4312 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4314 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
4315 ok(hres
== S_OK
, "put_posHeight failed: %08x\n", hres
);
4317 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4318 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4320 f
== 4.9f
, /* IE8 */
4321 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4324 V_BSTR(&v
) = a2bstr("64px");
4325 hres
= IHTMLStyle_put_height(style
, v
);
4326 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
4329 V_VT(&v
) = VT_EMPTY
;
4330 hres
= IHTMLStyle_get_height(style
, &v
);
4331 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4332 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4333 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4336 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4337 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4338 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
4340 str
= (void*)0xdeadbeef;
4341 hres
= IHTMLStyle_get_cursor(style
, &str
);
4342 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4343 ok(!str
, "get_cursor != NULL\n");
4346 str
= a2bstr("default");
4347 hres
= IHTMLStyle_put_cursor(style
, str
);
4348 ok(hres
== S_OK
, "put_cursor failed: %08x\n", hres
);
4352 hres
= IHTMLStyle_get_cursor(style
, &str
);
4353 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4354 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
4357 V_VT(&v
) = VT_EMPTY
;
4358 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4359 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
4360 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4361 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4365 V_BSTR(&v
) = a2bstr("middle");
4366 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
4367 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
4370 V_VT(&v
) = VT_EMPTY
;
4371 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4372 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4373 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4374 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4377 str
= (void*)0xdeadbeef;
4378 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4379 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4380 ok(!str
, "textAlign != NULL\n");
4382 str
= a2bstr("center");
4383 hres
= IHTMLStyle_put_textAlign(style
, str
);
4384 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
4388 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4389 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4390 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4393 str
= (void*)0xdeadbeef;
4394 hres
= IHTMLStyle_get_filter(style
, &str
);
4395 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
4396 ok(!str
, "filter != NULL\n");
4398 str
= a2bstr("alpha(opacity=100)");
4399 hres
= IHTMLStyle_put_filter(style
, str
);
4400 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
4403 V_VT(&v
) = VT_EMPTY
;
4404 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4405 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4406 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4407 ok(!V_I4(&v
), "V_I4(v) != 0\n");
4411 V_BSTR(&v
) = a2bstr("1");
4412 hres
= IHTMLStyle_put_zIndex(style
, v
);
4413 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
4416 V_VT(&v
) = VT_EMPTY
;
4417 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4418 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4419 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4420 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
4424 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
4425 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
4427 str
= a2bstr("test");
4428 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4429 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
4432 str
= a2bstr("italic");
4433 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4434 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4437 str
= a2bstr("oblique");
4438 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4439 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4442 str
= a2bstr("normal");
4443 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4444 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4447 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
4448 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4449 SysFreeString(sDefault
);
4452 hres
= IHTMLStyle_get_overflow(style
, NULL
);
4453 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
4455 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
4456 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4458 str
= a2bstr("test");
4459 hres
= IHTMLStyle_put_overflow(style
, str
);
4460 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
4463 str
= a2bstr("visible");
4464 hres
= IHTMLStyle_put_overflow(style
, str
);
4465 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4468 str
= a2bstr("scroll");
4469 hres
= IHTMLStyle_put_overflow(style
, str
);
4470 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4473 str
= a2bstr("hidden");
4474 hres
= IHTMLStyle_put_overflow(style
, str
);
4475 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4478 str
= a2bstr("auto");
4479 hres
= IHTMLStyle_put_overflow(style
, str
);
4480 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4483 hres
= IHTMLStyle_get_overflow(style
, &str
);
4484 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4485 ok(!strcmp_wa(str
, "auto"), "str=%s\n", wine_dbgstr_w(str
));
4489 hres
= IHTMLStyle_put_overflow(style
, str
);
4490 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4493 hres
= IHTMLStyle_get_overflow(style
, &str
);
4494 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4495 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4498 /* restore overflow default */
4499 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
4500 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4501 SysFreeString(sOverflowDefault
);
4503 /* Attribute Tests*/
4504 hres
= IHTMLStyle_getAttribute(style
, NULL
, 1, &v
);
4505 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4507 str
= a2bstr("position");
4508 hres
= IHTMLStyle_getAttribute(style
, str
, 1, NULL
);
4509 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4511 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4512 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4513 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4516 hres
= IHTMLStyle_setAttribute(style
, NULL
, v
, 1);
4517 ok(hres
== E_INVALIDARG
, "setAttribute failed: %08x\n", hres
);
4520 V_BSTR(&v
) = a2bstr("absolute");
4521 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4522 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4525 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4526 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4527 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4528 ok(!strcmp_wa(V_BSTR(&v
), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4533 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4534 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4539 str
= a2bstr("borderLeftStyle");
4540 test_border_styles(style
, str
);
4543 str
= a2bstr("borderbottomstyle");
4544 test_border_styles(style
, str
);
4547 str
= a2bstr("borderrightstyle");
4548 test_border_styles(style
, str
);
4551 str
= a2bstr("bordertopstyle");
4552 test_border_styles(style
, str
);
4555 hres
= IHTMLStyle_get_borderStyle(style
, &sDefault
);
4556 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4558 str
= a2bstr("none dotted dashed solid");
4559 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4560 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4563 str
= a2bstr("none dotted dashed solid");
4564 hres
= IHTMLStyle_get_borderStyle(style
, &str
);
4565 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4566 ok(!strcmp_wa(str
, "none dotted dashed solid"),
4567 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4570 str
= a2bstr("double groove ridge inset");
4571 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4572 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4575 str
= a2bstr("window-inset outset ridge inset");
4576 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4577 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4580 str
= a2bstr("window-inset");
4581 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4582 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4585 str
= a2bstr("none none none none none");
4586 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4587 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4590 str
= a2bstr("invalid none none none");
4591 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4592 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4595 str
= a2bstr("none invalid none none");
4596 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4597 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4600 hres
= IHTMLStyle_put_borderStyle(style
, sDefault
);
4601 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4602 SysFreeString(sDefault
);
4604 /* backgoundColor */
4605 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4606 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4607 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4608 ok(!V_BSTR(&v
), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4612 hres
= IHTMLStyle_get_paddingLeft(style
, &vDefault
);
4613 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4616 V_BSTR(&v
) = a2bstr("10");
4617 hres
= IHTMLStyle_put_paddingLeft(style
, v
);
4618 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4621 hres
= IHTMLStyle_get_paddingLeft(style
, &v
);
4622 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4623 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4625 hres
= IHTMLStyle_put_paddingLeft(style
, vDefault
);
4626 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4628 /* BackgroundRepeat */
4629 hres
= IHTMLStyle_get_backgroundRepeat(style
, &sDefault
);
4630 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4632 str
= a2bstr("invalid");
4633 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4634 ok(hres
== E_INVALIDARG
, "put_backgroundRepeat failed: %08x\n", hres
);
4637 str
= a2bstr("repeat");
4638 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4639 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4642 str
= a2bstr("no-repeat");
4643 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4644 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4647 str
= a2bstr("repeat-x");
4648 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4649 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4652 str
= a2bstr("repeat-y");
4653 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4654 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4657 hres
= IHTMLStyle_get_backgroundRepeat(style
, &str
);
4658 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4659 ok(!strcmp_wa(str
, "repeat-y"), "str=%s\n", wine_dbgstr_w(str
));
4662 hres
= IHTMLStyle_put_backgroundRepeat(style
, sDefault
);
4663 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4664 SysFreeString(sDefault
);
4667 hres
= IHTMLStyle_get_borderColor(style
, &sDefault
);
4668 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4670 str
= a2bstr("red green red blue");
4671 hres
= IHTMLStyle_put_borderColor(style
, str
);
4672 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4675 hres
= IHTMLStyle_get_borderColor(style
, &str
);
4676 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4677 ok(!strcmp_wa(str
, "red green red blue"), "str=%s\n", wine_dbgstr_w(str
));
4680 hres
= IHTMLStyle_put_borderColor(style
, sDefault
);
4681 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4682 SysFreeString(sDefault
);
4685 hres
= IHTMLStyle_get_borderRight(style
, &sDefault
);
4686 ok(hres
== S_OK
, "get_borderRight failed: %08x\n", hres
);
4688 str
= a2bstr("thick dotted red");
4689 hres
= IHTMLStyle_put_borderRight(style
, str
);
4690 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4693 /* IHTMLStyle_get_borderRight appears to have a bug where
4694 it returns the first letter of the color. So we check
4695 each style individually.
4698 hres
= IHTMLStyle_get_borderRightColor(style
, &v
);
4699 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
4700 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4704 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4705 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
4706 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4709 hres
= IHTMLStyle_get_borderRightStyle(style
, &str
);
4710 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
4711 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4714 hres
= IHTMLStyle_put_borderRight(style
, sDefault
);
4715 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4716 SysFreeString(sDefault
);
4719 hres
= IHTMLStyle_get_borderTop(style
, &sDefault
);
4720 ok(hres
== S_OK
, "get_borderTop failed: %08x\n", hres
);
4722 str
= a2bstr("thick dotted red");
4723 hres
= IHTMLStyle_put_borderTop(style
, str
);
4724 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4727 /* IHTMLStyle_get_borderTop appears to have a bug where
4728 it returns the first letter of the color. So we check
4729 each style individually.
4732 hres
= IHTMLStyle_get_borderTopColor(style
, &v
);
4733 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
4734 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4738 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4739 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
4740 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4743 hres
= IHTMLStyle_get_borderTopStyle(style
, &str
);
4744 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
4745 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4748 hres
= IHTMLStyle_put_borderTop(style
, sDefault
);
4749 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4750 SysFreeString(sDefault
);
4753 hres
= IHTMLStyle_get_borderBottom(style
, &sDefault
);
4754 ok(hres
== S_OK
, "get_borderBottom failed: %08x\n", hres
);
4756 str
= a2bstr("thick dotted red");
4757 hres
= IHTMLStyle_put_borderBottom(style
, str
);
4758 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4761 /* IHTMLStyle_get_borderBottom appears to have a bug where
4762 it returns the first letter of the color. So we check
4763 each style individually.
4766 hres
= IHTMLStyle_get_borderBottomColor(style
, &v
);
4767 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
4768 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4772 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4773 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
4774 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4777 hres
= IHTMLStyle_get_borderBottomStyle(style
, &str
);
4778 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
4779 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4782 hres
= IHTMLStyle_put_borderBottom(style
, sDefault
);
4783 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4784 SysFreeString(sDefault
);
4787 hres
= IHTMLStyle_get_borderLeft(style
, &sDefault
);
4788 ok(hres
== S_OK
, "get_borderLeft failed: %08x\n", hres
);
4790 str
= a2bstr("thick dotted red");
4791 hres
= IHTMLStyle_put_borderLeft(style
, str
);
4792 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4795 /* IHTMLStyle_get_borderLeft appears to have a bug where
4796 it returns the first letter of the color. So we check
4797 each style individually.
4800 hres
= IHTMLStyle_get_borderLeftColor(style
, &v
);
4801 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
4802 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4806 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4807 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
4808 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4811 hres
= IHTMLStyle_get_borderLeftStyle(style
, &str
);
4812 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
4813 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4816 hres
= IHTMLStyle_put_borderLeft(style
, sDefault
);
4817 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4818 SysFreeString(sDefault
);
4820 /* backgroundPositionX */
4821 hres
= IHTMLStyle_get_backgroundPositionX(style
, &vDefault
);
4822 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4825 V_BSTR(&v
) = a2bstr("10px");
4826 hres
= IHTMLStyle_put_backgroundPositionX(style
, v
);
4827 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4830 hres
= IHTMLStyle_get_backgroundPositionX(style
, &v
);
4831 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4832 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4835 hres
= IHTMLStyle_put_backgroundPositionX(style
, vDefault
);
4836 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4837 VariantClear(&vDefault
);
4839 /* backgroundPositionY */
4840 hres
= IHTMLStyle_get_backgroundPositionY(style
, &vDefault
);
4841 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4844 V_BSTR(&v
) = a2bstr("10px");
4845 hres
= IHTMLStyle_put_backgroundPositionY(style
, v
);
4846 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4849 hres
= IHTMLStyle_get_backgroundPositionY(style
, &v
);
4850 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4851 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4854 hres
= IHTMLStyle_put_backgroundPositionY(style
, vDefault
);
4855 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4856 VariantClear(&vDefault
);
4858 /* borderTopWidth */
4859 hres
= IHTMLStyle_get_borderTopWidth(style
, &vDefault
);
4860 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4863 V_BSTR(&v
) = a2bstr("10px");
4864 hres
= IHTMLStyle_put_borderTopWidth(style
, v
);
4865 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4868 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4869 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4870 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4873 hres
= IHTMLStyle_put_borderTopWidth(style
, vDefault
);
4874 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4875 VariantClear(&vDefault
);
4877 /* borderRightWidth */
4878 hres
= IHTMLStyle_get_borderRightWidth(style
, &vDefault
);
4879 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4882 V_BSTR(&v
) = a2bstr("10");
4883 hres
= IHTMLStyle_put_borderRightWidth(style
, v
);
4884 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4887 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4888 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4889 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4892 hres
= IHTMLStyle_put_borderRightWidth(style
, vDefault
);
4893 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4894 VariantClear(&vDefault
);
4896 /* borderBottomWidth */
4897 hres
= IHTMLStyle_get_borderBottomWidth(style
, &vDefault
);
4898 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4901 V_BSTR(&v
) = a2bstr("10");
4902 hres
= IHTMLStyle_put_borderBottomWidth(style
, v
);
4903 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4906 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4907 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4908 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4911 hres
= IHTMLStyle_put_borderBottomWidth(style
, vDefault
);
4912 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4913 VariantClear(&vDefault
);
4915 /* borderLeftWidth */
4916 hres
= IHTMLStyle_get_borderLeftWidth(style
, &vDefault
);
4917 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4920 V_BSTR(&v
) = a2bstr("10");
4921 hres
= IHTMLStyle_put_borderLeftWidth(style
, v
);
4922 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4925 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4926 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4927 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4930 hres
= IHTMLStyle_put_borderLeftWidth(style
, vDefault
);
4931 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4932 VariantClear(&vDefault
);
4935 hres
= IHTMLStyle_get_wordSpacing(style
, &vDefault
);
4936 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4939 V_BSTR(&v
) = a2bstr("10");
4940 hres
= IHTMLStyle_put_wordSpacing(style
, v
);
4941 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4944 hres
= IHTMLStyle_get_wordSpacing(style
, &v
);
4945 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4946 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4947 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4950 hres
= IHTMLStyle_put_wordSpacing(style
, vDefault
);
4951 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4952 VariantClear(&vDefault
);
4955 hres
= IHTMLStyle_get_letterSpacing(style
, &vDefault
);
4956 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4959 V_BSTR(&v
) = a2bstr("11");
4960 hres
= IHTMLStyle_put_letterSpacing(style
, v
);
4961 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4964 hres
= IHTMLStyle_get_letterSpacing(style
, &v
);
4965 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4966 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4967 ok(!strcmp_wa(V_BSTR(&v
), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4970 hres
= IHTMLStyle_put_letterSpacing(style
, vDefault
);
4971 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4972 VariantClear(&vDefault
);
4974 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
4975 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
4976 if(SUCCEEDED(hres
)) {
4977 test_style2(style2
);
4978 IHTMLStyle2_Release(style2
);
4981 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle3
, (void**)&style3
);
4982 ok(hres
== S_OK
, "Could not get IHTMLStyle3 iface: %08x\n", hres
);
4983 if(SUCCEEDED(hres
)) {
4984 test_style3(style3
);
4985 IHTMLStyle3_Release(style3
);
4988 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle4
, (void**)&style4
);
4989 ok(hres
== S_OK
, "Could not get IHTMLStyle4 iface: %08x\n", hres
);
4990 if(SUCCEEDED(hres
)) {
4991 test_style4(style4
);
4992 IHTMLStyle4_Release(style4
);
4996 static void test_set_csstext(IHTMLStyle
*style
)
5001 test_style_set_csstext(style
, "background-color: black;");
5003 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
5004 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
5005 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
5006 ok(!strcmp_wa(V_BSTR(&v
), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
5010 static void test_default_selection(IHTMLDocument2
*doc
)
5012 IHTMLSelectionObject
*selection
;
5013 IHTMLTxtRange
*range
;
5018 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5019 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5021 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5022 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5023 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
5026 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
5027 IHTMLSelectionObject_Release(selection
);
5028 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
5030 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
5031 IDispatch_Release(disp
);
5032 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
5034 test_range_text(range
, NULL
);
5035 IHTMLTxtRange_Release(range
);
5038 static void test_doc_elem(IHTMLDocument2
*doc
)
5040 IHTMLDocument2
*doc_node
, *owner_doc
;
5042 IHTMLDocument3
*doc3
;
5045 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5046 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
5048 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
5049 IHTMLDocument3_Release(doc3
);
5050 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
5052 test_node_name((IUnknown
*)elem
, "HTML");
5053 test_elem_tag((IUnknown
*)elem
, "HTML");
5055 doc_node
= get_doc_node(doc
);
5056 owner_doc
= get_owner_doc((IUnknown
*)elem
);
5057 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
5058 IHTMLDocument2_Release(owner_doc
);
5060 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
5061 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5062 IHTMLDocument2_Release(doc_node
);
5064 test_elem_client_rect((IUnknown
*)elem
);
5066 IHTMLElement_Release(elem
);
5069 static void test_default_body(IHTMLBodyElement
*body
)
5076 bstr
= (void*)0xdeadbeef;
5077 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
5078 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
5079 ok(bstr
== NULL
, "bstr != NULL\n");
5081 l
= elem_get_scroll_height((IUnknown
*)body
);
5082 ok(l
!= -1, "scrollHeight == -1\n");
5083 l
= elem_get_scroll_width((IUnknown
*)body
);
5084 ok(l
!= -1, "scrollWidth == -1\n");
5085 l
= elem_get_scroll_top((IUnknown
*)body
);
5086 ok(!l
, "scrollTop = %d\n", l
);
5087 elem_get_scroll_left((IUnknown
*)body
);
5089 /* get_text tests */
5090 hres
= IHTMLBodyElement_get_text(body
, &v
);
5091 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5092 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5093 ok(bstr
== NULL
, "bstr != NULL\n");
5095 /* get_text - Invalid Text */
5097 V_BSTR(&v
) = a2bstr("Invalid");
5098 hres
= IHTMLBodyElement_put_text(body
, v
);
5099 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5103 hres
= IHTMLBodyElement_get_text(body
, &v
);
5104 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5105 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5106 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
5109 /* get_text - Valid Text */
5111 V_BSTR(&v
) = a2bstr("#FF0000");
5112 hres
= IHTMLBodyElement_put_text(body
, v
);
5113 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5117 hres
= IHTMLBodyElement_get_text(body
, &v
);
5118 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5119 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5120 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
5124 static void test_body_funs(IHTMLBodyElement
*body
)
5126 VARIANT vbg
, vDefaultbg
;
5129 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5130 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5131 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5132 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5134 V_VT(&vbg
) = VT_BSTR
;
5135 V_BSTR(&vbg
) = a2bstr("red");
5136 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5137 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5140 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5141 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5142 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
5143 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5146 /* Restore Originial */
5147 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5148 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5149 VariantClear(&vDefaultbg
);
5152 static void test_window(IHTMLDocument2
*doc
)
5154 IHTMLWindow2
*window
, *window2
, *self
;
5155 IHTMLDocument2
*doc2
= NULL
;
5161 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5162 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5163 test_ifaces((IUnknown
*)window
, window_iids
);
5164 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5166 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5167 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5168 ok(doc2
!= NULL
, "doc2 == NULL\n");
5170 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5171 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5173 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5174 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5176 unk
= (void*)0xdeadbeef;
5177 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5178 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5179 ok(!unk
, "unk = %p\n", unk
);
5181 IHTMLDocument_Release(doc2
);
5183 hres
= IHTMLWindow2_get_window(window
, &window2
);
5184 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5185 ok(window2
!= NULL
, "window2 == NULL\n");
5187 hres
= IHTMLWindow2_get_self(window
, &self
);
5188 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5189 ok(window2
!= NULL
, "self == NULL\n");
5191 ok(self
== window2
, "self != window2\n");
5193 IHTMLWindow2_Release(window2
);
5194 IHTMLWindow2_Release(self
);
5197 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5198 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5199 ok(disp
== (void*)window
, "disp != window\n");
5200 IDispatch_Release(disp
);
5202 hres
= IHTMLWindow2_toString(window
, NULL
);
5203 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5206 hres
= IHTMLWindow2_toString(window
, &str
);
5207 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5208 ok(!strcmp_wa(str
, "[object]"), "toString returned %s\n", wine_dbgstr_w(str
));
5211 test_window_name(window
, NULL
);
5212 set_window_name(window
, "test");
5213 test_window_length(window
, 0);
5214 test_screen(window
);
5216 IHTMLWindow2_Release(window
);
5219 static void test_defaults(IHTMLDocument2
*doc
)
5221 IHTMLStyleSheetsCollection
*stylesheetcol
;
5222 IHTMLCurrentStyle
*cstyle
;
5223 IHTMLBodyElement
*body
;
5224 IHTMLElement2
*elem2
;
5229 IHTMLElementCollection
*collection
;
5231 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5232 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5234 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5235 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5237 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5238 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5241 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5242 IHTMLElementCollection_Release(collection
);
5245 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5246 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5248 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5249 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5252 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5253 IHTMLElementCollection_Release(collection
);
5256 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5257 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5259 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5260 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5263 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5264 IHTMLElementCollection_Release(collection
);
5267 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5268 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5270 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5271 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5274 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5275 IHTMLElementCollection_Release(collection
);
5278 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5279 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5281 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5282 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5285 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5286 IHTMLElementCollection_Release(collection
);
5289 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5290 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5291 test_default_body(body
);
5292 test_body_funs(body
);
5293 IHTMLBodyElement_Release(body
);
5295 hres
= IHTMLElement_get_style(elem
, &style
);
5296 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5298 test_default_style(style
);
5300 test_compatmode(doc
);
5302 test_navigator(doc
);
5304 elem2
= get_elem2_iface((IUnknown
*)elem
);
5305 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5306 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5307 if(SUCCEEDED(hres
)) {
5308 test_current_style(cstyle
);
5309 IHTMLCurrentStyle_Release(cstyle
);
5311 IHTMLElement2_Release(elem2
);
5313 IHTMLElement_Release(elem
);
5315 test_set_csstext(style
);
5316 IHTMLStyle_Release(style
);
5318 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5319 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5322 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5323 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5324 ok(l
== 0, "length = %d\n", l
);
5326 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5328 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5329 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5331 test_default_selection(doc
);
5332 test_doc_title(doc
, "");
5335 static void test_tr_elem(IHTMLElement
*elem
)
5337 IHTMLElementCollection
*col
;
5341 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
5343 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
5344 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
5349 hres
= IHTMLTableRow_get_cells(row
, &col
);
5350 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
5351 ok(col
!= NULL
, "get_cells returned NULL\n");
5353 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
5354 IHTMLElementCollection_Release(col
);
5356 IHTMLTable_Release(row
);
5359 static void test_table_elem(IHTMLElement
*elem
)
5361 IHTMLElementCollection
*col
;
5366 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
5367 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
5369 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
5370 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
5375 hres
= IHTMLTable_get_rows(table
, &col
);
5376 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5377 ok(col
!= NULL
, "get_ros returned NULL\n");
5379 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
5380 IHTMLElementCollection_Release(col
);
5382 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5384 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
5385 test_elem_tag((IUnknown
*)node
, "TABLE");
5386 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5387 IHTMLDOMNode_Release(node
);
5389 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
5390 test_elem_tag((IUnknown
*)node
, "TABLE");
5391 test_elem_all((IUnknown
*)node
, NULL
, 0);
5392 IHTMLDOMNode_Release(node
);
5394 IHTMLTable_Release(table
);
5397 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
5407 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
5408 SafeArrayAccessData(sa
, (void**)&var
);
5409 V_VT(var
) = VT_BSTR
;
5410 V_BSTR(var
) = str
= a2bstr(text
);
5411 SafeArrayUnaccessData(sa
);
5414 hres
= IHTMLDocument2_writeln(doc
, sa
);
5416 hres
= IHTMLDocument2_write(doc
, sa
);
5417 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
5420 SafeArrayDestroy(sa
);
5423 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
5425 IHTMLDocument2
*window_doc
, *elem_doc
;
5426 IHTMLFrameElement3
*frame_elem3
;
5427 IHTMLWindow2
*content_window
;
5430 content_window
= get_frame_content_window(frame_elem
);
5431 window_doc
= get_window_doc(content_window
);
5432 IHTMLWindow2_Release(content_window
);
5434 elem_doc
= get_elem_doc(frame_elem
);
5435 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
5438 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
5439 if(SUCCEEDED(hres
)) {
5440 IDispatch
*disp
= NULL
;
5442 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
5443 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
5444 ok(disp
!= NULL
, "contentDocument == NULL\n");
5445 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
5447 IDispatch_Release(disp
);
5448 IHTMLFrameElement3_Release(frame_elem3
);
5450 win_skip("IHTMLFrameElement3 not supported\n");
5454 IHTMLDocument2_Release(elem_doc
);
5455 IHTMLDocument2_Release(window_doc
);
5458 static void test_iframe_elem(IHTMLElement
*elem
)
5460 IHTMLDocument2
*content_doc
, *owner_doc
;
5461 IHTMLElementCollection
*col
;
5462 IHTMLWindow2
*content_window
;
5468 static const elem_type_t all_types
[] = {
5476 test_frame_doc((IUnknown
*)elem
, TRUE
);
5478 content_window
= get_frame_content_window((IUnknown
*)elem
);
5479 test_window_length(content_window
, 0);
5481 content_doc
= get_window_doc(content_window
);
5482 IHTMLWindow2_Release(content_window
);
5484 str
= a2bstr("text/html");
5485 V_VT(&errv
) = VT_ERROR
;
5487 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5489 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5490 ok(disp
!= NULL
, "disp == NULL\n");
5491 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5492 IDispatch_Release(disp
);
5494 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head><body><br /></body>");
5495 doc_write(content_doc
, TRUE
, "</html>");
5497 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5498 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5499 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5500 IHTMLElementCollection_Release(col
);
5502 hres
= IHTMLDocument2_close(content_doc
);
5503 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5505 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5506 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5508 IHTMLDocument2_Release(content_doc
);
5511 static void test_stylesheet(IDispatch
*disp
)
5513 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5514 IHTMLStyleSheet
*stylesheet
;
5517 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5518 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5520 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5521 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5522 ok(col
!= NULL
, "col == NULL\n");
5524 IHTMLStyleSheetRulesCollection_Release(col
);
5525 IHTMLStyleSheet_Release(stylesheet
);
5528 static void test_stylesheets(IHTMLDocument2
*doc
)
5530 IHTMLStyleSheetsCollection
*col
= NULL
;
5535 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5536 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5537 ok(col
!= NULL
, "col == NULL\n");
5539 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5540 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5541 ok(len
== 1, "len=%d\n", len
);
5547 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5548 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5549 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5550 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5551 test_stylesheet(V_DISPATCH(&res
));
5558 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5559 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5560 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5561 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5564 IHTMLStyleSheetsCollection_Release(col
);
5567 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
5569 IDispatchEx
*dispex
;
5571 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
5579 static const WCHAR w0
[] = {'0',0};
5580 static const WCHAR w100
[] = {'1','0','0',0};
5582 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
5583 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
5585 bstr
= SysAllocString(w0
);
5586 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5587 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5588 SysFreeString(bstr
);
5591 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
5592 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
5593 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
5594 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
5595 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
5596 type
= get_node_type((IUnknown
*)node
);
5597 ok(type
== 3, "type=%d\n", type
);
5598 IHTMLDOMNode_Release(node
);
5601 bstr
= SysAllocString(w100
);
5602 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5603 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
5604 SysFreeString(bstr
);
5606 IDispatchEx_Release(dispex
);
5611 static void test_elems(IHTMLDocument2
*doc
)
5613 IHTMLElementCollection
*col
;
5614 IHTMLDOMChildrenCollection
*child_col
;
5615 IHTMLElement
*elem
, *elem2
, *elem3
;
5616 IHTMLDOMNode
*node
, *node2
;
5617 IHTMLWindow2
*window
;
5621 IHTMLElementCollection
*collection
;
5622 IHTMLDocument3
*doc3
;
5625 static const elem_type_t all_types
[] = {
5651 static const elem_type_t item_types
[] = {
5657 hres
= IHTMLDocument2_get_all(doc
, &col
);
5658 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5659 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5660 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
5661 IHTMLElementCollection_Release(col
);
5663 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5664 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5667 static const elem_type_t images_types
[] = {ET_IMG
};
5668 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5670 IHTMLElementCollection_Release(collection
);
5673 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5674 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5677 static const elem_type_t images_types
[] = {ET_A
};
5678 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5680 IHTMLElementCollection_Release(collection
);
5683 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5684 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5687 static const elem_type_t anchor_types
[] = {ET_A
};
5688 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
5690 IHTMLElementCollection_Release(collection
);
5693 elem
= get_doc_elem(doc
);
5694 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
5695 IHTMLElement_Release(elem
);
5697 get_elem_by_id(doc
, "xxx", FALSE
);
5698 elem
= get_doc_elem_by_id(doc
, "xxx");
5699 ok(!elem
, "elem != NULL\n");
5701 elem
= get_doc_elem_by_id(doc
, "s");
5702 ok(elem
!= NULL
, "elem == NULL\n");
5704 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
5705 test_elem_attr(elem
, "xxx", NULL
);
5706 test_elem_attr(elem
, "id", "s");
5707 test_elem_class((IUnknown
*)elem
, NULL
);
5708 test_elem_set_class((IUnknown
*)elem
, "cl");
5709 test_elem_set_class((IUnknown
*)elem
, NULL
);
5710 test_elem_tabindex((IUnknown
*)elem
, 0);
5711 test_elem_set_tabindex((IUnknown
*)elem
, 1);
5712 test_elem_filters((IUnknown
*)elem
);
5714 node
= test_node_get_parent((IUnknown
*)elem
);
5715 ok(node
!= NULL
, "node == NULL\n");
5716 test_node_name((IUnknown
*)node
, "BODY");
5717 node2
= test_node_get_parent((IUnknown
*)node
);
5718 IHTMLDOMNode_Release(node
);
5719 ok(node2
!= NULL
, "node == NULL\n");
5720 test_node_name((IUnknown
*)node2
, "HTML");
5721 node
= test_node_get_parent((IUnknown
*)node2
);
5722 IHTMLDOMNode_Release(node2
);
5723 ok(node
!= NULL
, "node == NULL\n");
5726 test_node_name((IUnknown
*)node
, "#document");
5727 type
= get_node_type((IUnknown
*)node
);
5728 ok(type
== 9, "type=%d, expected 9\n", type
);
5729 node2
= test_node_get_parent((IUnknown
*)node
);
5730 IHTMLDOMNode_Release(node
);
5731 ok(node2
== NULL
, "node != NULL\n");
5734 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5735 ok(elem2
!= NULL
, "elem2 == NULL\n");
5736 test_node_name((IUnknown
*)elem2
, "BODY");
5737 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
5738 IHTMLElement_Release(elem2
);
5739 ok(elem3
!= NULL
, "elem3 == NULL\n");
5740 test_node_name((IUnknown
*)elem3
, "HTML");
5741 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
5742 IHTMLElement_Release(elem3
);
5743 ok(elem2
== NULL
, "elem2 != NULL\n");
5745 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
5746 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
5747 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
5749 test_elem_innertext(elem
, "opt1opt2");
5751 IHTMLElement_Release(elem
);
5754 elem
= get_elem_by_id(doc
, "s", TRUE
);
5756 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
5757 IHTMLDocument2
*doc_node
, *elem_doc
;
5759 test_select_elem(select
);
5761 test_elem_title((IUnknown
*)select
, NULL
);
5762 test_elem_set_title((IUnknown
*)select
, "Title");
5763 test_elem_title((IUnknown
*)select
, "Title");
5764 test_elem_offset((IUnknown
*)select
);
5766 node
= get_first_child((IUnknown
*)select
);
5767 ok(node
!= NULL
, "node == NULL\n");
5769 test_elem_type((IUnknown
*)node
, ET_OPTION
);
5770 IHTMLDOMNode_Release(node
);
5773 type
= get_node_type((IUnknown
*)select
);
5774 ok(type
== 1, "type=%d\n", type
);
5776 IHTMLSelectElement_Release(select
);
5778 elem_doc
= get_elem_doc((IUnknown
*)elem
);
5780 doc_node
= get_doc_node(doc
);
5781 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
5782 IHTMLDocument2_Release(doc_node
);
5783 IHTMLDocument2_Release(elem_doc
);
5785 IHTMLElement_Release(elem
);
5788 elem
= get_elem_by_id(doc
, "sc", TRUE
);
5790 IHTMLScriptElement
*script
;
5793 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
5794 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
5800 hres
= IHTMLScriptElement_put_type (script
, NULL
);
5801 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5802 hres
= IHTMLScriptElement_get_type(script
, &type
);
5803 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5804 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
5806 hres
= IHTMLScriptElement_put_type (script
, a2bstr ("text/javascript"));
5807 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5808 hres
= IHTMLScriptElement_get_type(script
, &type
);
5809 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5810 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
5812 SysFreeString(type
);
5815 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
5816 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5818 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
5819 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
5820 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
5822 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
5823 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5826 IHTMLScriptElement_Release(script
);
5829 elem
= get_elem_by_id(doc
, "in", TRUE
);
5831 IHTMLInputElement
*input
;
5833 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
5834 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
5836 test_elem_id((IUnknown
*)elem
, "in");
5837 test_elem_put_id((IUnknown
*)elem
, "newin");
5838 test_input_get_disabled(input
, VARIANT_FALSE
);
5839 test_input_set_disabled(input
, VARIANT_TRUE
);
5840 test_input_set_disabled(input
, VARIANT_FALSE
);
5841 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
5842 test_input_get_disabled(input
, VARIANT_TRUE
);
5843 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
5844 test_input_get_disabled(input
, VARIANT_FALSE
);
5845 test_elem_client_size((IUnknown
*)elem
);
5846 test_input_type(input
, "text");
5848 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5849 test_node_put_value_str((IUnknown
*)elem
, "test");
5850 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5851 test_input_value((IUnknown
*)elem
, NULL
);
5852 test_input_put_value((IUnknown
*)elem
, "test");
5853 test_input_value((IUnknown
*)elem
, NULL
);
5854 test_elem_class((IUnknown
*)elem
, "testclass");
5855 test_elem_tabindex((IUnknown
*)elem
, 2);
5856 test_elem_set_tabindex((IUnknown
*)elem
, 3);
5857 test_elem_title((IUnknown
*)elem
, "test title");
5859 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
5860 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
5861 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
5863 test_input_get_checked(input
, VARIANT_FALSE
);
5864 test_input_set_checked(input
, VARIANT_TRUE
);
5865 test_input_set_checked(input
, VARIANT_FALSE
);
5867 test_input_name(input
, NULL
);
5868 test_input_set_name(input
, "test");
5870 test_input_src(input
, NULL
);
5871 test_input_set_src(input
, "about:blank");
5873 IHTMLInputElement_Release(input
);
5874 IHTMLElement_Release(elem
);
5877 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5879 test_img_src((IUnknown
*)elem
, "");
5880 test_img_set_src((IUnknown
*)elem
, "about:blank");
5881 test_img_alt((IUnknown
*)elem
, NULL
);
5882 test_img_set_alt((IUnknown
*)elem
, "alt test");
5883 test_img_name((IUnknown
*)elem
, "WineImg");
5884 IHTMLElement_Release(elem
);
5887 elem
= get_doc_elem_by_id(doc
, "tbl");
5888 ok(elem
!= NULL
, "elem == NULL\n");
5890 test_table_elem(elem
);
5891 IHTMLElement_Release(elem
);
5894 elem
= get_doc_elem_by_id(doc
, "row2");
5895 ok(elem
!= NULL
, "elem == NULL\n");
5898 IHTMLElement_Release(elem
);
5901 elem
= get_doc_elem_by_id(doc
, "ifr");
5902 ok(elem
!= NULL
, "elem == NULL\n");
5904 test_iframe_elem(elem
);
5905 IHTMLElement_Release(elem
);
5908 elem
= get_elem_by_id(doc
, "a", TRUE
);
5910 test_anchor_href((IUnknown
*)elem
, "http://test/");
5911 IHTMLElement_Release(elem
);
5914 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5915 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5917 node
= get_first_child((IUnknown
*)elem
);
5918 ok(node
!= NULL
, "node == NULL\n");
5920 test_ifaces((IUnknown
*)node
, text_iids
);
5921 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5923 node2
= get_first_child((IUnknown
*)node
);
5924 ok(!node2
, "node2 != NULL\n");
5926 type
= get_node_type((IUnknown
*)node
);
5927 ok(type
== 3, "type=%d\n", type
);
5929 test_node_get_value_str((IUnknown
*)node
, "text test");
5930 test_node_put_value_str((IUnknown
*)elem
, "test text");
5931 test_node_get_value_str((IUnknown
*)node
, "text test");
5933 IHTMLDOMNode_Release(node
);
5936 child_col
= get_child_nodes((IUnknown
*)elem
);
5937 ok(child_col
!= NULL
, "child_coll == NULL\n");
5941 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
5943 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
5944 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5945 ok(length
, "length=0\n");
5948 node
= get_child_item(child_col
, 0);
5949 ok(node
!= NULL
, "node == NULL\n");
5951 type
= get_node_type((IUnknown
*)node
);
5952 ok(type
== 3, "type=%d\n", type
);
5953 node2
= node_get_next((IUnknown
*)node
);
5954 IHTMLDOMNode_Release(node
);
5957 node
= get_child_item(child_col
, 1);
5958 ok(node
!= NULL
, "node == NULL\n");
5960 type
= get_node_type((IUnknown
*)node
);
5961 ok(type
== 8, "type=%d\n", type
);
5963 test_elem_id((IUnknown
*)node
, NULL
);
5964 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
5965 IHTMLDOMNode_Release(node2
);
5966 IHTMLDOMNode_Release(node
);
5969 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
5970 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5972 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
5973 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5975 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
5976 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5978 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
5979 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5981 test_child_col_disp(child_col
);
5983 IHTMLDOMChildrenCollection_Release(child_col
);
5986 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5987 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
5988 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5990 IHTMLElement_Release(elem
);
5992 elem
= get_doc_elem_by_id(doc
, "frm");
5993 ok(elem
!= NULL
, "elem == NULL\n");
5995 test_form_length((IUnknown
*)elem
, 0);
5996 IHTMLElement_Release(elem
);
5999 test_stylesheets(doc
);
6000 test_create_option_elem(doc
);
6001 test_create_img_elem(doc
);
6003 elem
= get_doc_elem_by_id(doc
, "tbl");
6004 ok(elem
!= NULL
, "elem = NULL\n");
6005 test_elem_set_innertext(elem
, "inner text");
6006 IHTMLElement_Release(elem
);
6008 test_doc_title(doc
, "test");
6009 test_doc_set_title(doc
, "test title");
6010 test_doc_title(doc
, "test title");
6013 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6014 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6017 IDispatchEx
*dispex
;
6018 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
6019 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
6023 BSTR str
= a2bstr("Testing");
6024 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
6025 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6026 ok(pid
!= -1, "pid == -1\n");
6028 IDispatchEx_Release(dispex
);
6031 IDispatch_Release(disp
);
6033 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6034 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
6036 str
= a2bstr("img");
6037 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
6038 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
6042 static const elem_type_t img_types
[] = { ET_IMG
};
6044 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
6045 IHTMLElementCollection_Release(col
);
6048 elem
= get_doc_elem_by_id(doc
, "y");
6049 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
6050 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
6051 test_elem_set_innerhtml((IUnknown
*)elem
, "");
6052 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
6053 node
= node_get_next((IUnknown
*)elem
);
6054 ok(!node
, "node = %p\n", node
);
6056 elem2
= get_doc_elem_by_id(doc
, "x");
6057 test_elem_tag((IUnknown
*)elem2
, "A");
6058 node
= node_get_next((IUnknown
*)elem2
);
6059 IHTMLDOMNode_Release(node
);
6060 IHTMLElement_Release(elem2
);
6061 IHTMLElement_Release(elem
);
6063 IHTMLDocument3_Release(doc3
);
6065 elem
= get_elem_by_id(doc
, "s", TRUE
);
6067 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
6069 test_select_put_length((IUnknown
*)elem
, 3);
6070 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
6071 test_select_put_length((IUnknown
*)elem
, 1);
6072 test_elem_all((IUnknown
*)elem
, select_types
, 1);
6073 IHTMLElement_Release(elem
);
6076 window
= get_doc_window(doc
);
6077 test_window_name(window
, NULL
);
6078 set_window_name(window
, "test name");
6079 test_window_length(window
, 1);
6080 IHTMLWindow2_Release(window
);
6083 static void test_elems2(IHTMLDocument2
*doc
)
6085 IHTMLElement
*elem
, *elem2
, *div
;
6087 static const elem_type_t outer_types
[] = {
6092 div
= get_doc_elem_by_id(doc
, "divid");
6094 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
6095 elem2
= get_doc_elem_by_id(doc
, "innerid");
6096 ok(elem2
!= NULL
, "elem2 == NULL\n");
6097 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6098 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
6099 IHTMLElement_Release(elem2
);
6101 elem2
= get_doc_elem_by_id(doc
, "aid");
6102 ok(elem2
!= NULL
, "elem2 == NULL\n");
6103 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
6104 test_elem_all((IUnknown
*)div
, outer_types
, 1);
6105 IHTMLElement_Release(elem2
);
6107 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
6108 elem
= get_elem_by_id(doc
, "ta", TRUE
);
6110 test_textarea_value((IUnknown
*)elem
, NULL
);
6111 test_textarea_put_value((IUnknown
*)elem
, "test");
6112 IHTMLElement_Release(elem
);
6115 IHTMLElement_Release(div
);
6118 static void test_create_elems(IHTMLDocument2
*doc
)
6120 IHTMLElement
*elem
, *body
, *elem2
;
6121 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
6122 IHTMLDocument5
*doc5
;
6129 static const elem_type_t types1
[] = { ET_TESTG
};
6131 elem
= test_create_elem(doc
, "TEST");
6132 test_elem_tag((IUnknown
*)elem
, "TEST");
6133 type
= get_node_type((IUnknown
*)elem
);
6134 ok(type
== 1, "type=%d\n", type
);
6135 test_ifaces((IUnknown
*)elem
, elem_iids
);
6136 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
6138 hres
= IHTMLDocument2_get_body(doc
, &body
);
6139 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
6140 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6142 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
6143 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
6144 elem2
= get_elem_iface((IUnknown
*)node
);
6145 IHTMLElement_Release(elem2
);
6147 hres
= IHTMLElement_get_all(body
, &disp
);
6148 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6149 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
6150 IDispatch_Release(disp
);
6152 test_node_remove_child((IUnknown
*)body
, node
);
6154 hres
= IHTMLElement_get_all(body
, &disp
);
6155 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6156 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
6157 IDispatch_Release(disp
);
6158 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6160 IHTMLElement_Release(elem
);
6161 IHTMLDOMNode_Release(node
);
6163 node
= test_create_text(doc
, "test");
6164 test_ifaces((IUnknown
*)node
, text_iids
);
6165 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
6166 test_text_length((IUnknown
*)node
, 4);
6168 V_VT(&var
) = VT_NULL
;
6169 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6170 IHTMLDOMNode_Release(node
);
6172 node
= test_create_text(doc
, "insert ");
6174 V_VT(&var
) = VT_DISPATCH
;
6175 V_DISPATCH(&var
) = (IDispatch
*)node2
;
6176 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6177 IHTMLDOMNode_Release(node
);
6178 IHTMLDOMNode_Release(node2
);
6179 IHTMLDOMNode_Release(node3
);
6181 test_elem_innertext(body
, "insert test");
6182 test_elem_innerhtml((IUnknown
*)body
, "insert test");
6184 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
6187 str
= a2bstr("testing");
6188 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
6190 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
6193 type
= get_node_type((IUnknown
*)comment
);
6194 ok(type
== 8, "type=%d, expected 8\n", type
);
6196 test_node_get_value_str((IUnknown
*)comment
, "testing");
6197 test_elem_title((IUnknown
*)comment
, NULL
);
6198 test_elem_set_title((IUnknown
*)comment
, "comment title");
6199 test_elem_title((IUnknown
*)comment
, "comment title");
6200 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
6201 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
6203 IHTMLDOMNode_Release(comment
);
6206 IHTMLDocument5_Release(doc5
);
6209 IHTMLElement_Release(body
);
6212 static void test_null_write(IHTMLDocument2
*doc
)
6216 doc_write(doc
, FALSE
, NULL
);
6217 doc_write(doc
, TRUE
, NULL
);
6219 hres
= IHTMLDocument2_write(doc
, NULL
);
6221 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
6223 hres
= IHTMLDocument2_writeln(doc
, NULL
);
6225 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
6228 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
6230 IOleCommandTarget
*cmdtrg
;
6233 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
6234 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
6236 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
6237 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
6239 IOleCommandTarget_Release(cmdtrg
);
6242 static void test_indent(IHTMLDocument2
*doc
)
6244 IHTMLElementCollection
*col
;
6245 IHTMLTxtRange
*range
;
6248 static const elem_type_t all_types
[] = {
6257 static const elem_type_t indent_types
[] = {
6268 hres
= IHTMLDocument2_get_all(doc
, &col
);
6269 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6270 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6271 IHTMLElementCollection_Release(col
);
6273 range
= test_create_body_range(doc
);
6274 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
6275 IHTMLTxtRange_Release(range
);
6277 hres
= IHTMLDocument2_get_all(doc
, &col
);
6278 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6279 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
6280 IHTMLElementCollection_Release(col
);
6283 static void test_cond_comment(IHTMLDocument2
*doc
)
6285 IHTMLElementCollection
*col
;
6288 static const elem_type_t all_types
[] = {
6296 hres
= IHTMLDocument2_get_all(doc
, &col
);
6297 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6298 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6299 IHTMLElementCollection_Release(col
);
6302 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6304 IHTMLWindow2
*frame2
, *parent
, *top
;
6305 IHTMLDocument2
*parent_doc
, *top_doc
;
6306 IHTMLWindow4
*frame
;
6307 IHTMLFrameBase
*frame_elem
;
6310 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6311 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6315 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6316 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6317 IHTMLWindow4_Release(frame
);
6321 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6322 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6323 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6324 IHTMLElement_Release(frame_elem
);
6326 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6327 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6331 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6332 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6334 IHTMLWindow2_Release(frame2
);
6338 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6339 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6340 IHTMLWindow2_Release(parent
);
6342 IHTMLWindow2_Release(frame2
);
6346 test_doc_title(parent_doc
, "frameset test");
6347 IHTMLDocument2_Release(parent_doc
);
6350 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6351 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6352 IHTMLWindow2_Release(frame2
);
6356 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6357 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6358 IHTMLWindow2_Release(top
);
6362 test_doc_title(top_doc
, "frameset test");
6363 IHTMLDocument2_Release(top_doc
);
6366 static void test_frameset(IHTMLDocument2
*doc
)
6368 IHTMLWindow2
*window
;
6369 IHTMLFramesCollection2
*frames
;
6371 IHTMLFrameBase
*fbase
;
6373 VARIANT index_var
, result_var
;
6377 window
= get_doc_window(doc
);
6379 /* test using IHTMLFramesCollection object */
6381 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6382 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6383 IHTMLWindow2_Release(window
);
6387 /* test result length */
6388 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6389 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6390 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6392 /* test first frame */
6393 V_VT(&index_var
) = VT_I4
;
6394 V_I4(&index_var
) = 0;
6395 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6396 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6397 if(SUCCEEDED(hres
)) {
6398 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6399 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6401 VariantClear(&result_var
);
6403 /* test second frame */
6404 V_I4(&index_var
) = 1;
6405 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6406 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6407 if(SUCCEEDED(hres
)) {
6408 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6409 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6411 VariantClear(&result_var
);
6413 /* fail on next frame */
6414 V_I4(&index_var
) = 3;
6415 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6416 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6417 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6418 VariantClear(&result_var
);
6420 /* string argument (element id lookup) */
6421 V_VT(&index_var
) = VT_BSTR
;
6422 V_BSTR(&index_var
) = a2bstr("fr1");
6423 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6424 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6425 if(SUCCEEDED(hres
)) {
6426 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6427 test_frame(V_DISPATCH(&result_var
), "fr1");
6429 VariantClear(&result_var
);
6430 VariantClear(&index_var
);
6432 /* invalid argument */
6433 V_VT(&index_var
) = VT_BOOL
;
6434 V_BOOL(&index_var
) = VARIANT_TRUE
;
6435 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6436 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6437 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6438 VariantClear(&result_var
);
6440 IHTMLFramesCollection2_Release(frames
);
6442 /* test using IHTMLWindow2 inheritance */
6444 /* test result length */
6445 hres
= IHTMLWindow2_get_length(window
, &length
);
6446 ok(hres
== S_OK
, "IHTMLWindow2_get_length failed: 0x%08x\n", hres
);
6447 ok(length
== 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length
);
6449 /* test first frame */
6450 V_VT(&index_var
) = VT_I4
;
6451 V_I4(&index_var
) = 0;
6452 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6453 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6454 if(SUCCEEDED(hres
)) {
6455 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6456 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6458 VariantClear(&result_var
);
6460 /* test second frame */
6461 V_I4(&index_var
) = 1;
6462 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6463 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6464 if(SUCCEEDED(hres
)) {
6465 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6466 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6468 VariantClear(&result_var
);
6470 /* fail on next frame */
6471 V_I4(&index_var
) = 3;
6472 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6473 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLWindow2_item should have"
6474 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6475 VariantClear(&result_var
);
6477 /* string argument (element id lookup) */
6478 V_VT(&index_var
) = VT_BSTR
;
6479 V_BSTR(&index_var
) = a2bstr("fr2");
6480 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6481 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6482 if(SUCCEEDED(hres
)) {
6483 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6484 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6486 VariantClear(&result_var
);
6487 VariantClear(&index_var
);
6489 /* invalid argument */
6490 V_VT(&index_var
) = VT_BOOL
;
6491 V_BOOL(&index_var
) = VARIANT_TRUE
;
6492 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6493 ok(hres
== E_INVALIDARG
, "IHTMLWindow2_item should have"
6494 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6495 VariantClear(&result_var
);
6497 /* getElementById with node name attributes */
6498 elem
= get_doc_elem_by_id(doc
, "nm1");
6499 test_elem_id((IUnknown
*)elem
, "fr1");
6501 /* get/put scrolling */
6502 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6503 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6505 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6506 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6507 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6511 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6512 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6515 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6516 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6517 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6520 str
= a2bstr("junk");
6521 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6522 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6523 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6526 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6527 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6528 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6532 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6533 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6534 ok(!strcmp_wa(str
, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str
));
6537 IHTMLFrameBase_Release(fbase
);
6538 IHTMLElement_Release(elem
);
6540 /* get_name with no name attr */
6541 elem
= get_doc_elem_by_id(doc
, "fr3");
6542 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6543 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6545 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6546 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6547 ok(str
== NULL
, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str
));
6550 IHTMLFrameBase_Release(fbase
);
6551 IHTMLElement_Release(elem
);
6554 static IHTMLDocument2
*notif_doc
;
6555 static BOOL doc_complete
;
6557 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
6558 REFIID riid
, void**ppv
)
6560 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
6565 ok(0, "unexpected call\n");
6566 return E_NOINTERFACE
;
6569 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
6574 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
6579 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
6581 if(dispID
== DISPID_READYSTATE
){
6585 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
6586 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
6588 if(!strcmp_wa(state
, "complete"))
6589 doc_complete
= TRUE
;
6591 SysFreeString(state
);
6597 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
6599 ok(0, "unexpected call\n");
6603 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
6604 PropertyNotifySink_QueryInterface
,
6605 PropertyNotifySink_AddRef
,
6606 PropertyNotifySink_Release
,
6607 PropertyNotifySink_OnChanged
,
6608 PropertyNotifySink_OnRequestEdit
6611 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
6613 static IHTMLDocument2
*create_doc_with_string(const char *str
)
6615 IPersistStreamInit
*init
;
6617 IHTMLDocument2
*doc
;
6621 notif_doc
= doc
= create_document();
6625 doc_complete
= FALSE
;
6627 mem
= GlobalAlloc(0, len
);
6628 memcpy(mem
, str
, len
);
6629 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
6631 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
6633 IPersistStreamInit_Load(init
, stream
);
6634 IPersistStreamInit_Release(init
);
6635 IStream_Release(stream
);
6640 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
6642 IConnectionPointContainer
*container
;
6643 IConnectionPoint
*cp
;
6647 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
6648 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
6650 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
6651 IConnectionPointContainer_Release(container
);
6652 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
6654 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
6655 IConnectionPoint_Release(cp
);
6656 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
6659 typedef void (*domtest_t
)(IHTMLDocument2
*);
6661 static void run_domtest(const char *str
, domtest_t test
)
6663 IHTMLDocument2
*doc
;
6667 doc
= create_doc_with_string(str
);
6671 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
6673 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
6674 TranslateMessage(&msg
);
6675 DispatchMessage(&msg
);
6680 ref
= IHTMLDocument2_Release(doc
);
6682 ref
== 1, /* Vista */
6690 run_domtest(doc_str1
, test_doc_elem
);
6691 run_domtest(doc_str1
, test_get_set_attr
);
6692 run_domtest(range_test_str
, test_txtrange
);
6693 run_domtest(range_test2_str
, test_txtrange2
);
6694 if (winetest_interactive
|| ! is_ie_hardened()) {
6695 run_domtest(elem_test_str
, test_elems
);
6697 skip("IE running in Enhanced Security Configuration\n");
6699 run_domtest(elem_test2_str
, test_elems2
);
6700 run_domtest(doc_blank
, test_create_elems
);
6701 run_domtest(doc_blank
, test_defaults
);
6702 run_domtest(doc_blank
, test_null_write
);
6703 run_domtest(indent_test_str
, test_indent
);
6704 run_domtest(cond_comment_str
, test_cond_comment
);
6705 run_domtest(frameset_str
, test_frameset
);