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_select_iface(u) _get_select_iface(__LINE__,u)
677 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
679 IHTMLSelectElement
*select
;
682 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
683 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
687 #define get_form_iface(u) _get_form_iface(__LINE__,u)
688 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
690 IHTMLFormElement
*form
;
693 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
694 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
698 #define get_text_iface(u) _get_text_iface(__LINE__,u)
699 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
701 IHTMLDOMTextNode
*text
;
704 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
705 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
709 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
710 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
712 IHTMLCommentElement
*comment
;
715 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
716 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
720 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
721 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
723 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
727 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
728 IHTMLDOMNode_Release(node
);
729 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
730 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
735 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
736 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
738 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
739 IDispatch
*disp
= (void*)0xdeadbeef;
740 IHTMLDocument2
*doc
= NULL
;
743 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
744 IHTMLDOMNode2_Release(node
);
745 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
748 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
749 IDispatch_Release(disp
);
750 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
756 #define get_doc_window(d) _get_doc_window(__LINE__,d)
757 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
759 IHTMLWindow2
*window
;
763 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
764 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
765 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
770 #define clone_node(n,d) _clone_node(__LINE__,n,d)
771 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
773 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
774 IHTMLDOMNode
*ret
= NULL
;
777 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
778 IHTMLDOMNode_Release(node
);
779 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
780 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
786 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
787 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
789 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
793 hres
= IHTMLElement_get_tagName(elem
, &tag
);
794 IHTMLElement_Release(elem
);
795 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
796 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
801 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
802 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
804 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
805 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
807 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
808 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
811 #define get_node_type(n) _get_node_type(__LINE__,n)
812 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
814 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
818 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
819 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
821 IHTMLDOMNode_Release(node
);
826 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
827 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
829 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
830 IHTMLDOMChildrenCollection
*col
= NULL
;
834 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
835 IHTMLDOMNode_Release(node
);
836 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
840 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
841 IDispatch_Release(disp
);
842 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
847 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
848 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
850 IHTMLDOMNode
*node
= NULL
;
854 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
855 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
857 node
= _get_node_iface(line
, (IUnknown
*)disp
);
858 IDispatch_Release(disp
);
863 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
864 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
873 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
875 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
878 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
879 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
881 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
884 VariantClear(&value
);
887 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
888 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
890 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
894 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
895 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
897 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
898 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
900 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
901 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
903 IHTMLElement_Release(elem
);
906 #define get_doc_node(d) _get_doc_node(__LINE__,d)
907 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
909 IHTMLWindow2
*window
;
913 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
914 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
916 hres
= IHTMLWindow2_get_document(window
, &ret
);
917 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
918 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
923 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
924 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
929 hres
= IHTMLWindow2_get_name(window
, &name
);
930 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
932 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
934 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
937 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
938 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
944 hres
= IHTMLWindow2_put_name(window
, str
);
946 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
948 _test_window_name(line
, window
, name
);
951 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
952 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
957 hres
= IHTMLWindow2_get_length(window
, &length
);
958 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
959 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
962 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
963 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
965 IHTMLFrameBase2
*base2
;
966 IHTMLWindow2
*window
;
969 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
970 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
973 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
974 IHTMLFrameBase2_Release(base2
);
975 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
976 ok(window
!= NULL
, "contentWindow = NULL\n");
981 static void test_get_set_attr(IHTMLDocument2
*doc
)
984 IHTMLDocument3
*doc3
;
989 /* grab an element to test with */
990 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
991 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
993 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
994 IHTMLDocument3_Release(doc3
);
995 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
997 /* get a non-present attribute */
998 bstr
= a2bstr("notAnAttribute");
999 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1000 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1001 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1003 SysFreeString(bstr
);
1005 /* get a present attribute */
1006 bstr
= a2bstr("scrollHeight");
1007 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1008 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1009 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1011 SysFreeString(bstr
);
1013 /* create a new BSTR attribute */
1014 bstr
= a2bstr("newAttribute");
1016 V_VT(&val
) = VT_BSTR
;
1017 V_BSTR(&val
) = a2bstr("the value");
1018 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1019 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1022 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1023 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1024 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1025 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
)));
1028 /* overwrite the attribute with a BOOL */
1029 V_VT(&val
) = VT_BOOL
;
1030 V_BOOL(&val
) = VARIANT_TRUE
;
1031 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1032 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1035 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1036 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1037 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1038 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1041 SysFreeString(bstr
);
1043 /* case-insensitive */
1044 bstr
= a2bstr("newattribute");
1045 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1046 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1047 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1048 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1050 SysFreeString(bstr
);
1052 IHTMLElement_Release(elem
);
1055 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1056 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1059 IHTMLDocument3
*doc3
;
1062 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1063 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1064 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1065 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1066 IHTMLDocument3_Release(doc3
);
1071 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1072 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1074 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1078 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1079 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1080 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1083 _test_disp_value(line
, unk
, exhref
);
1086 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1087 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1092 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1093 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1094 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1095 SysFreeString(bstr
);
1098 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1099 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1104 bstr
= a2bstr(text
);
1105 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1106 SysFreeString(bstr
);
1107 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1109 _test_option_text(line
, option
, text
);
1112 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1113 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1118 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1119 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1120 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1121 SysFreeString(bstr
);
1124 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1125 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1130 bstr
= a2bstr(value
);
1131 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1132 SysFreeString(bstr
);
1133 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1135 _test_option_value(line
, option
, value
);
1138 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1139 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1141 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1145 text
= a2bstr(extext
);
1146 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1147 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1148 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1150 IHTMLCommentElement_Release(comment
);
1151 SysFreeString(text
);
1154 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1155 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1156 const char *txt
, const char *val
)
1158 IHTMLOptionElementFactory
*factory
;
1159 IHTMLOptionElement
*option
;
1160 IHTMLWindow2
*window
;
1161 VARIANT text
, value
, empty
;
1164 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1165 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1167 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1168 IHTMLWindow2_Release(window
);
1169 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1171 V_VT(&text
) = VT_BSTR
;
1172 V_BSTR(&text
) = a2bstr(txt
);
1173 V_VT(&value
) = VT_BSTR
;
1174 V_BSTR(&value
) = a2bstr(val
);
1175 V_VT(&empty
) = VT_EMPTY
;
1177 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1178 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1180 IHTMLOptionElementFactory_Release(factory
);
1181 VariantClear(&text
);
1182 VariantClear(&value
);
1184 _test_option_text(line
, option
, txt
);
1185 _test_option_value(line
, option
, val
);
1190 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1191 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1196 hres
= IHTMLImgElement_get_width(img
, &found
);
1197 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1198 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1201 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1202 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const long width
)
1206 hres
= IHTMLImgElement_put_width(img
, width
);
1207 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1209 _test_img_width(line
, img
, width
);
1212 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1213 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1218 hres
= IHTMLImgElement_get_height(img
, &found
);
1219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1220 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1223 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1224 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const long height
)
1228 hres
= IHTMLImgElement_put_height(img
, height
);
1229 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1231 _test_img_height(line
, img
, height
);
1234 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1235 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1236 LONG wdth
, LONG hght
)
1238 IHTMLImageElementFactory
*factory
;
1239 IHTMLImgElement
*img
;
1240 IHTMLWindow2
*window
;
1241 VARIANT width
, height
;
1245 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1248 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1249 IHTMLWindow2_Release(window
);
1250 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1252 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1253 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1256 snprintf(buf
, 16, "%d", wdth
);
1257 V_VT(&width
) = VT_BSTR
;
1258 V_BSTR(&width
) = a2bstr(buf
);
1260 V_VT(&width
) = VT_EMPTY
;
1265 snprintf(buf
, 16, "%d", hght
);
1266 V_VT(&height
) = VT_BSTR
;
1267 V_BSTR(&height
) = a2bstr(buf
);
1269 V_VT(&height
) = VT_EMPTY
;
1273 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1274 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1276 IHTMLImageElementFactory_Release(factory
);
1277 VariantClear(&width
);
1278 VariantClear(&height
);
1280 if(SUCCEEDED(hres
)) {
1281 _test_img_width(line
, img
, wdth
);
1282 _test_img_height(line
, img
, hght
);
1289 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1290 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1292 LONG len
= 0xdeadbeef;
1295 hres
= IHTMLSelectElement_get_length(select
, &len
);
1296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1297 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1300 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1301 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1303 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1306 hres
= IHTMLSelectElement_put_length(select
, length
);
1307 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1308 _test_select_length(line
, select
, length
);
1309 IHTMLSelectElement_Release(select
);
1312 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1313 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1315 LONG idx
= 0xdeadbeef;
1318 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1320 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1323 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1324 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1328 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1329 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1330 _test_select_selidx(line
, select
, index
);
1333 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1334 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1339 hres
= IHTMLSelectElement_get_value(select
, &val
);
1340 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1342 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1344 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1347 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1348 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1354 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1355 SysFreeString(bstr
);
1356 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1359 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1360 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1365 hres
= IHTMLSelectElement_get_type(select
, &type
);
1366 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1367 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1370 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1371 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1376 hres
= IHTMLTxtRange_get_text(range
, &text
);
1377 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1380 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1381 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1383 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1386 SysFreeString(text
);
1390 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1391 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1395 hres
= IHTMLTxtRange_collapse(range
, b
);
1396 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1397 _test_range_text(line
, range
, NULL
);
1400 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1401 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1402 VARIANT_BOOL exb
, const char *extext
)
1404 VARIANT_BOOL b
= 0xe0e0;
1407 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1408 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1409 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1410 _test_range_text(line
, range
, extext
);
1413 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1414 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1416 LONG c
= 0xdeadbeef;
1419 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1420 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1421 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1422 _test_range_text(line
, range
, NULL
);
1425 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1426 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1427 LPWSTR unit
, LONG cnt
, LONG excnt
)
1429 LONG c
= 0xdeadbeef;
1432 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1433 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1434 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1437 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1438 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1440 LONG c
= 0xdeadbeef;
1443 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1444 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1445 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1448 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1449 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1452 BSTR bstr
= a2bstr(text
);
1454 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1455 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1456 SysFreeString(bstr
);
1457 _test_range_text(line
, range
, NULL
);
1460 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1461 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1467 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1468 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1469 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1472 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1473 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1479 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1480 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1481 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1484 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1485 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1486 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1489 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1490 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1494 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1495 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1500 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1501 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1503 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1505 IHTMLElement_Release(elem
);
1508 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1509 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1510 const elem_type_t
*elem_types
, LONG exlen
)
1512 IHTMLElementCollection
*col
;
1515 VARIANT name
, index
;
1516 IDispatch
*disp
, *disp2
;
1519 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1520 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1522 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1524 hres
= IHTMLElementCollection_get_length(col
, &len
);
1525 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1526 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1531 V_VT(&index
) = VT_EMPTY
;
1533 for(i
=0; i
<len
; i
++) {
1534 V_VT(&name
) = VT_I4
;
1536 disp
= (void*)0xdeadbeef;
1537 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1538 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1539 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1540 if(FAILED(hres
) || !disp
)
1543 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1546 V_VT(&name
) = VT_UINT
;
1548 disp2
= (void*)0xdeadbeef;
1549 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1550 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1551 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1553 IDispatch_Release(disp2
);
1556 IDispatch_Release(disp
);
1559 V_VT(&name
) = VT_I4
;
1561 disp
= (void*)0xdeadbeef;
1562 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1563 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1564 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1566 V_VT(&name
) = VT_I4
;
1568 disp
= (void*)0xdeadbeef;
1569 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1570 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1571 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1573 IHTMLElementCollection_Release(col
);
1576 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1577 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1579 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1583 hres
= IHTMLElement_get_all(elem
, &disp
);
1584 IHTMLElement_Release(elem
);
1585 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1587 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1588 IDispatch_Release(disp
);
1591 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1592 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1594 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1595 IHTMLElementCollection
*col
= NULL
;
1596 elem_type_t
*types
= NULL
;
1601 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1602 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1604 IHTMLElement2_Release(elem
);
1605 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1606 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1609 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1610 for(i
=0; i
<exlen
; i
++)
1614 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1616 HeapFree(GetProcessHeap(), 0, types
);
1619 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1620 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1625 hres
= IHTMLElement_get_innerText(elem
, &text
);
1626 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1627 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1628 wine_dbgstr_w(text
), extext
);
1629 SysFreeString(text
);
1632 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1633 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1635 IHTMLDOMChildrenCollection
*col
;
1640 hres
= IHTMLElement_put_innerText(elem
, str
);
1641 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1644 _test_elem_innertext(line
, elem
, text
);
1647 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1648 ok(col
!= NULL
, "col == NULL\n");
1650 LONG length
= 0, type
;
1653 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1654 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1655 ok(length
== 1, "length = %d\n", length
);
1657 node
= _get_child_item(line
, col
, 0);
1658 ok(node
!= NULL
, "node == NULL\n");
1660 type
= _get_node_type(line
, (IUnknown
*)node
);
1661 ok(type
== 3, "type=%d\n", type
);
1662 IHTMLDOMNode_Release(node
);
1665 IHTMLDOMChildrenCollection_Release(col
);
1670 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1671 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1673 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1677 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
1678 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
1680 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
1682 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
1684 IHTMLElement_Release(elem
);
1685 SysFreeString(html
);
1688 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1689 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1691 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1695 html
= a2bstr(inner_html
);
1696 hres
= IHTMLElement_put_innerHTML(elem
, html
);
1697 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
1699 IHTMLElement_Release(elem
);
1700 SysFreeString(html
);
1703 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1704 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1706 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1710 html
= a2bstr(outer_html
);
1711 hres
= IHTMLElement_put_outerHTML(elem
, html
);
1712 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
1714 IHTMLElement_Release(elem
);
1715 SysFreeString(html
);
1718 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1719 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1721 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1725 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
1726 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
1727 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
1729 IHTMLElement_Release(elem
);
1730 SysFreeString(html
);
1733 #define get_first_child(n) _get_first_child(__LINE__,n)
1734 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1736 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1737 IHTMLDOMNode
*child
= NULL
;
1740 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1741 IHTMLDOMNode_Release(node
);
1742 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1747 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1748 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1750 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1751 VARIANT_BOOL b
= 0xdead;
1754 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1755 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1756 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1758 IHTMLDOMNode_Release(node
);
1761 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1762 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1764 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1765 IHTMLDOMNode
*parent
;
1768 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1769 IHTMLDOMNode_Release(node
);
1770 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1775 #define node_get_next(u) _node_get_next(__LINE__,u)
1776 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
1778 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1782 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
1783 IHTMLDOMNode_Release(node
);
1784 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
1789 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1790 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1792 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1793 IHTMLElement
*parent
;
1796 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1797 IHTMLElement_Release(elem
);
1798 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1803 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1804 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1806 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1807 VARIANT_BOOL disabled
= 100;
1811 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1812 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1813 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1814 IHTMLElement3_Release(elem3
);
1817 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1818 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1820 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1824 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1825 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1827 IHTMLElement3_Release(elem3
);
1828 _test_elem3_get_disabled(line
, unk
, b
);
1831 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1832 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1834 VARIANT_BOOL disabled
= 100;
1837 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1838 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1839 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1841 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1844 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1845 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
1847 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
1851 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
1852 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1853 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
1854 IHTMLDOMTextNode_Release(text
);
1857 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1858 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1862 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1863 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1865 _test_select_get_disabled(line
, select
, b
);
1868 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1869 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1871 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1872 IHTMLTextContainer
*txtcont
;
1873 LONG l
= -1, l2
= -1;
1876 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1877 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1878 IHTMLElement2_Release(elem
);
1880 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1881 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1883 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1884 IHTMLTextContainer_Release(txtcont
);
1885 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
1886 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
1891 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1892 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1894 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1895 IHTMLTextContainer
*txtcont
;
1896 LONG l
= -1, l2
= -1;
1899 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1900 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1901 IHTMLElement2_Release(elem
);
1903 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1904 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1906 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1907 IHTMLTextContainer_Release(txtcont
);
1908 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
1909 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
1914 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1915 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1917 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1918 IHTMLTextContainer
*txtcont
;
1919 LONG l
= -1, l2
= -1;
1922 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1923 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1924 IHTMLElement2_Release(elem
);
1926 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1927 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1929 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1930 IHTMLTextContainer_Release(txtcont
);
1931 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
1932 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
1937 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1938 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
1940 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1941 IHTMLTextContainer
*txtcont
;
1942 LONG l
= -1, l2
= -1;
1945 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
1946 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
1948 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
1949 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1950 IHTMLElement2_Release(elem
);
1952 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1953 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1955 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
1956 IHTMLTextContainer_Release(txtcont
);
1957 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
1958 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
1961 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1962 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
1964 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1968 hres
= IHTMLImgElement_get_src(img
, &src
);
1969 IHTMLImgElement_Release(img
);
1970 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
1971 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
1975 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1976 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
1978 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1983 hres
= IHTMLImgElement_put_src(img
, tmp
);
1984 IHTMLImgElement_Release(img
);
1986 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
1988 _test_img_src(line
, unk
, src
);
1991 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1992 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
1994 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1998 hres
= IHTMLImgElement_get_alt(img
, &alt
);
1999 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2001 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2003 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2007 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2008 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2010 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2015 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2016 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2019 _test_img_alt(line
, unk
, alt
);
2022 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2023 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2025 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2029 hres
= IHTMLImgElement_get_name(img
, &sName
);
2030 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2031 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2032 IHTMLImgElement_Release(img
);
2033 SysFreeString(sName
);
2036 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2037 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
2042 hres
= IHTMLInputElement_get_type(input
, &type
);
2043 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2044 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2045 SysFreeString(type
);
2048 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2049 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
2051 BSTR name
= (BSTR
)0xdeadbeef;
2054 hres
= IHTMLInputElement_get_name(input
, &name
);
2055 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2057 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
2059 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
2060 SysFreeString(name
);
2063 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2064 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
2066 BSTR tmp
= a2bstr(name
);
2069 hres
= IHTMLInputElement_put_name(input
, tmp
);
2070 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
2073 _test_input_name(line
, input
, name
);
2076 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2077 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2079 VARIANT_BOOL disabled
= 100;
2082 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
2083 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2084 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2086 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
2089 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2090 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2094 hres
= IHTMLInputElement_put_disabled(input
, b
);
2095 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2097 _test_input_get_disabled(line
, input
, b
);
2100 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2101 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2103 VARIANT_BOOL checked
= 100;
2106 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
2107 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2108 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2111 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2112 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2116 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2117 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2119 _test_input_get_defaultchecked(line
, input
, b
);
2122 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2123 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2125 VARIANT_BOOL checked
= 100;
2128 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2129 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2130 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2133 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2134 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2138 hres
= IHTMLInputElement_put_checked(input
, b
);
2139 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2141 _test_input_get_checked(line
, input
, b
);
2144 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2145 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2147 IHTMLInputElement
*input
;
2151 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2152 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2156 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2157 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2159 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2161 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
2162 SysFreeString(bstr
);
2163 IHTMLInputElement_Release(input
);
2166 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2167 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2169 IHTMLInputElement
*input
;
2173 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2174 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2179 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2180 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2181 SysFreeString(bstr
);
2182 IHTMLInputElement_Release(input
);
2185 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2186 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2191 hres
= IHTMLInputElement_get_src(input
, &src
);
2192 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2194 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2196 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2200 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2201 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2207 hres
= IHTMLInputElement_put_src(input
, tmp
);
2209 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2211 _test_input_src(line
, input
, src
);
2214 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2215 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2217 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2218 BSTR
class = (void*)0xdeadbeef;
2221 hres
= IHTMLElement_get_className(elem
, &class);
2222 IHTMLElement_Release(elem
);
2223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2225 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2227 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2228 SysFreeString(class);
2231 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2232 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2234 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2238 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2239 IHTMLElement2_Release(elem2
);
2240 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2241 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2244 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2245 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2247 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2250 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2251 IHTMLElement2_Release(elem2
);
2252 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2254 _test_elem_tabindex(line
, unk
, index
);
2257 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2258 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2260 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2262 IHTMLFiltersCollection
*filters
;
2264 hres
= IHTMLElement_get_filters(elem
, &filters
);
2265 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2266 "get_filters failed: %08x\n", hres
);
2270 IDispatchEx
*dispex
;
2272 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2273 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2274 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2276 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2277 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2278 "Could not get IDispatchEx interface: %08x\n", hres
);
2279 if(SUCCEEDED(hres
)) {
2280 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2281 IDispatchEx_Release(dispex
);
2284 IHTMLFiltersCollection_Release(filters
);
2287 IHTMLElement_Release(elem
);
2290 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2291 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2293 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2297 tmp
= class ? a2bstr(class) : NULL
;
2298 hres
= IHTMLElement_put_className(elem
, tmp
);
2299 IHTMLElement_Release(elem
);
2300 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
2303 _test_elem_class(line
, unk
, class);
2306 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2307 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
2309 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2310 BSTR id
= (void*)0xdeadbeef;
2313 hres
= IHTMLElement_get_id(elem
, &id
);
2314 IHTMLElement_Release(elem
);
2315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
2318 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
2320 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
2325 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2326 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
2328 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2329 BSTR tmp
= a2bstr(new_id
);
2332 hres
= IHTMLElement_put_id(elem
, tmp
);
2333 IHTMLElement_Release(elem
);
2335 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
2337 _test_elem_id(line
, unk
, new_id
);
2340 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2341 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
2343 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2347 hres
= IHTMLElement_get_title(elem
, &title
);
2348 IHTMLElement_Release(elem
);
2349 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2351 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2353 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
2355 SysFreeString(title
);
2358 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2359 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
2361 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2365 tmp
= a2bstr(title
);
2366 hres
= IHTMLElement_put_title(elem
, tmp
);
2367 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2369 IHTMLElement_Release(elem
);
2373 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2374 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
2376 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2380 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
2381 IHTMLDOMNode_Release(node
);
2382 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2385 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
2386 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2388 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
2394 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2395 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
2397 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2401 V_VT(&var
) = VT_BSTR
;
2402 V_BSTR(&var
) = a2bstr(val
);
2404 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
2405 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2406 IHTMLDOMNode_Release(node
);
2410 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2411 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
2413 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2417 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
2418 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
2419 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
2420 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
2422 IHTMLElement2_Release(elem
);
2425 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2426 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
2428 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2432 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
2433 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
2434 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
2436 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
2437 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
2438 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
2440 IHTMLElement2_Release(elem
);
2443 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2444 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
2446 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
2447 LONG len
= 0xdeadbeef;
2450 hres
= IHTMLFormElement_get_length(form
, &len
);
2451 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2452 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
2454 IHTMLFormElement_Release(form
);
2457 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2458 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
2460 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2461 IHTMLDocument2
*doc
;
2466 hres
= IHTMLElement_get_document(elem
, &disp
);
2467 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2468 ok(disp
!= NULL
, "disp == NULL\n");
2470 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
2471 IDispatch_Release(disp
);
2472 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
2477 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2478 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
2480 IHTMLDocument2
*doc
;
2484 hres
= IHTMLWindow2_get_document(window
, &doc
);
2485 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2486 ok(doc
!= NULL
, "disp == NULL\n");
2491 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2492 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
2494 IHTMLElement
*elem
= NULL
;
2499 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
2500 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2501 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
2506 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2507 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
2509 IHTMLDocument3
*doc3
;
2510 IHTMLDOMNode
*node
= NULL
;
2514 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2515 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
2518 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
2519 IHTMLDocument3_Release(doc3
);
2520 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2521 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
2526 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2527 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
2529 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2530 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
2531 IHTMLDOMNode
*new_child
= NULL
;
2534 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
2535 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
2536 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2537 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2539 IHTMLDOMNode_Release(node
);
2540 IHTMLDOMNode_Release(child
);
2545 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2546 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
2548 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2549 IHTMLDOMNode
*new_child
= NULL
;
2552 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
2553 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
2554 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2555 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2557 IHTMLDOMNode_Release(node
);
2562 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2563 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
2565 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2566 IHTMLDOMNode
*new_node
= NULL
;
2569 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
2570 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
2571 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
2572 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2574 IHTMLDOMNode_Release(node
);
2575 IHTMLDOMNode_Release(new_node
);
2578 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2579 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
2584 hres
= IHTMLDocument2_get_title(doc
, &title
);
2585 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2586 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2587 SysFreeString(title
);
2590 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2591 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
2596 tmp
= a2bstr(title
);
2597 hres
= IHTMLDocument2_put_title(doc
, tmp
);
2598 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2602 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2603 static void _test_border_styles(unsigned line
, IHTMLStyle
*pStyle
, BSTR Name
)
2608 hres
= IHTMLStyle_GetIDsOfNames(pStyle
, &IID_NULL
, &Name
, 1,
2609 LOCALE_USER_DEFAULT
, &dispid
);
2610 ok_(__FILE__
,line
) (hres
== S_OK
, "GetIDsOfNames: %08x\n", hres
);
2613 DISPPARAMS params
= {NULL
,NULL
,0,0};
2614 DISPID dispidNamed
= DISPID_PROPERTYPUT
;
2619 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2620 DISPATCH_PROPERTYGET
, ¶ms
, &vDefault
, NULL
, NULL
);
2621 ok_(__FILE__
,line
) (hres
== S_OK
, "get_default. ret: %08x\n", hres
);
2624 params
.cNamedArgs
= 1;
2625 params
.rgdispidNamedArgs
= &dispidNamed
;
2626 V_VT(&arg
) = VT_BSTR
;
2627 V_BSTR(&arg
) = a2bstr("none");
2628 params
.rgvarg
= &arg
;
2629 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2630 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2631 ok_(__FILE__
,line
) (hres
== S_OK
, "none. ret: %08x\n", hres
);
2634 V_VT(&arg
) = VT_BSTR
;
2635 V_BSTR(&arg
) = a2bstr("dotted");
2636 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2637 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2638 ok_(__FILE__
,line
) (hres
== S_OK
, "dotted. ret: %08x\n", hres
);
2641 V_VT(&arg
) = VT_BSTR
;
2642 V_BSTR(&arg
) = a2bstr("dashed");
2643 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2644 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2645 ok_(__FILE__
,line
) (hres
== S_OK
, "dashed. ret: %08x\n", hres
);
2648 V_VT(&arg
) = VT_BSTR
;
2649 V_BSTR(&arg
) = a2bstr("solid");
2650 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2651 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2652 ok_(__FILE__
,line
) (hres
== S_OK
, "solid. ret: %08x\n", hres
);
2655 V_VT(&arg
) = VT_BSTR
;
2656 V_BSTR(&arg
) = a2bstr("double");
2657 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2658 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2659 ok_(__FILE__
,line
) (hres
== S_OK
, "double. ret: %08x\n", hres
);
2662 V_VT(&arg
) = VT_BSTR
;
2663 V_BSTR(&arg
) = a2bstr("groove");
2664 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2665 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2666 ok_(__FILE__
,line
) (hres
== S_OK
, "groove. ret: %08x\n", hres
);
2669 V_VT(&arg
) = VT_BSTR
;
2670 V_BSTR(&arg
) = a2bstr("ridge");
2671 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2672 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2673 ok_(__FILE__
,line
) (hres
== S_OK
, "ridge. ret: %08x\n", hres
);
2676 V_VT(&arg
) = VT_BSTR
;
2677 V_BSTR(&arg
) = a2bstr("inset");
2678 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2679 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2680 ok_(__FILE__
,line
) (hres
== S_OK
, "inset. ret: %08x\n", hres
);
2683 V_VT(&arg
) = VT_BSTR
;
2684 V_BSTR(&arg
) = a2bstr("outset");
2685 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2686 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2687 ok_(__FILE__
,line
) (hres
== S_OK
, "outset. ret: %08x\n", hres
);
2690 V_VT(&arg
) = VT_BSTR
;
2691 V_BSTR(&arg
) = a2bstr("invalid");
2692 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2693 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2694 ok_(__FILE__
,line
) (FAILED(hres
), "invalid value passed.\n");
2697 params
.rgvarg
= &vDefault
;
2698 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2699 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2700 ok_(__FILE__
,line
) (hres
== S_OK
, "default. ret: %08x\n", hres
);
2704 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2705 static void _test_style_csstext(unsigned line
, IHTMLStyle
*style
, const char *extext
)
2707 BSTR text
= (void*)0xdeadbeef;
2710 hres
= IHTMLStyle_get_cssText(style
, &text
);
2711 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
2713 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "cssText = %s\n", wine_dbgstr_w(text
));
2715 ok_(__FILE__
,line
)(!text
, "cssText = %s\n", wine_dbgstr_w(text
));
2717 SysFreeString(text
);
2720 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2721 static void _test_style_set_csstext(unsigned line
, IHTMLStyle
*style
, const char *text
)
2727 hres
= IHTMLStyle_put_cssText(style
, tmp
);
2728 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
2732 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
2733 const elem_type_t
*elem_types
, LONG len
)
2736 VARIANT name
, index
;
2740 V_VT(&index
) = VT_EMPTY
;
2741 V_VT(&name
) = VT_BSTR
;
2742 V_BSTR(&name
) = a2bstr(n
);
2744 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2745 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2747 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
2748 IDispatch_Release(disp
);
2749 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
2753 V_VT(&index
) = VT_I4
;
2755 for(i
=0; i
<len
; i
++) {
2757 disp
= (void*)0xdeadbeef;
2758 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2759 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2760 ok(disp
!= NULL
, "disp == NULL\n");
2761 if(FAILED(hres
) || !disp
)
2764 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
2766 IDispatch_Release(disp
);
2770 disp
= (void*)0xdeadbeef;
2771 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2772 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2773 ok(disp
== NULL
, "disp != NULL\n");
2776 disp
= (void*)0xdeadbeef;
2777 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2778 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2779 ok(disp
== NULL
, "disp != NULL\n");
2782 SysFreeString(V_BSTR(&name
));
2785 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
2787 IHTMLElementCollection
*col
;
2789 IDispatch
*disp
= (void*)0xdeadbeef;
2790 VARIANT name
, index
;
2793 hres
= IHTMLDocument2_get_all(doc
, &col
);
2794 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2795 ok(col
!= NULL
, "col == NULL\n");
2796 if(FAILED(hres
) || !col
)
2799 V_VT(&index
) = VT_EMPTY
;
2800 V_VT(&name
) = VT_BSTR
;
2801 V_BSTR(&name
) = a2bstr(id
);
2803 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2804 IHTMLElementCollection_Release(col
);
2805 SysFreeString(V_BSTR(&name
));
2806 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2807 if(!expect_success
) {
2808 ok(disp
== NULL
, "disp != NULL\n");
2812 ok(disp
!= NULL
, "disp == NULL\n");
2816 elem
= get_elem_iface((IUnknown
*)disp
);
2817 IDispatch_Release(disp
);
2822 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
2824 IHTMLDocument3
*doc3
;
2829 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2830 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
2833 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
2835 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
2837 IHTMLDocument3_Release(doc3
);
2842 static void test_select_elem(IHTMLSelectElement
*select
)
2847 test_select_type(select
, "select-one");
2848 test_select_length(select
, 2);
2849 test_select_selidx(select
, 0);
2850 test_select_put_selidx(select
, 1);
2852 test_select_set_value(select
, "val1");
2853 test_select_value(select
, "val1");
2855 test_select_get_disabled(select
, VARIANT_FALSE
);
2856 test_select_set_disabled(select
, VARIANT_TRUE
);
2857 test_select_set_disabled(select
, VARIANT_FALSE
);
2860 hres
= IHTMLSelectElement_get_options(select
, &disp
);
2861 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
2862 ok(disp
!= NULL
, "options == NULL\n");
2863 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
2864 IDispatch_Release(disp
);
2867 static void test_create_option_elem(IHTMLDocument2
*doc
)
2869 IHTMLOptionElement
*option
;
2871 option
= create_option_elem(doc
, "test text", "test value");
2873 test_option_put_text(option
, "new text");
2874 test_option_put_value(option
, "new value");
2876 IHTMLOptionElement_Release(option
);
2879 static void test_create_img_elem(IHTMLDocument2
*doc
)
2881 IHTMLImgElement
*img
;
2883 img
= create_img_elem(doc
, 10, 15);
2886 test_img_put_width(img
, 5);
2887 test_img_put_height(img
, 20);
2889 IHTMLImgElement_Release(img
);
2893 img
= create_img_elem(doc
, -1, -1);
2896 test_img_put_width(img
, 5);
2897 test_img_put_height(img
, 20);
2899 IHTMLImgElement_Release(img
);
2903 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
2905 IHTMLBodyElement
*body
;
2906 IHTMLTxtRange
*range
;
2910 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2911 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2913 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
2914 IHTMLElement_Release(elem
);
2916 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
2917 IHTMLBodyElement_Release(body
);
2918 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
2923 static void test_txtrange(IHTMLDocument2
*doc
)
2925 IHTMLTxtRange
*body_range
, *range
, *range2
;
2926 IHTMLSelectionObject
*selection
;
2927 IDispatch
*disp_range
;
2930 body_range
= test_create_body_range(doc
);
2932 test_range_text(body_range
, "test abc 123\r\nit's text");
2934 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2935 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2937 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
2938 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2939 test_range_isequal(range
, range2
, VARIANT_TRUE
);
2941 test_range_text(range
, "test abc 123\r\nit's text");
2942 test_range_text(body_range
, "test abc 123\r\nit's text");
2944 test_range_collapse(range
, TRUE
);
2945 test_range_isequal(range
, range2
, VARIANT_FALSE
);
2946 test_range_inrange(range
, range2
, VARIANT_FALSE
);
2947 test_range_inrange(range2
, range
, VARIANT_TRUE
);
2948 IHTMLTxtRange_Release(range2
);
2950 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2951 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
2952 test_range_move(range
, characterW
, 2, 2);
2953 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2955 test_range_collapse(range
, FALSE
);
2956 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
2958 test_range_collapse(range
, FALSE
);
2959 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2960 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
2961 test_range_move(range
, characterW
, 2, 2);
2962 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2963 test_range_moveend(range
, characterW
, -5, -5);
2964 test_range_text(range
, NULL
);
2965 test_range_moveend(range
, characterW
, 3, 3);
2966 test_range_text(range
, "c 1");
2967 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
2968 test_range_collapse(range
, TRUE
);
2969 test_range_move(range
, characterW
, 4, 4);
2970 test_range_moveend(range
, characterW
, 1, 1);
2971 test_range_text(range
, " ");
2972 test_range_move(range
, wordW
, 1, 1);
2973 test_range_moveend(range
, characterW
, 2, 2);
2974 test_range_text(range
, "ab");
2976 IHTMLTxtRange_Release(range
);
2978 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2979 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2981 test_range_text(range
, "test abc 123\r\nit's text");
2982 test_range_move(range
, characterW
, 3, 3);
2983 test_range_moveend(range
, characterW
, 1, 1);
2984 test_range_text(range
, "t");
2985 test_range_moveend(range
, characterW
, 3, 3);
2986 test_range_text(range
, "t ab");
2987 test_range_moveend(range
, characterW
, -2, -2);
2988 test_range_text(range
, "t ");
2989 test_range_move(range
, characterW
, 6, 6);
2990 test_range_moveend(range
, characterW
, 3, 3);
2991 test_range_text(range
, "123");
2992 test_range_moveend(range
, characterW
, 2, 2);
2993 test_range_text(range
, "123\r\ni");
2995 IHTMLTxtRange_Release(range
);
2997 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2998 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3000 test_range_move(range
, wordW
, 1, 1);
3001 test_range_moveend(range
, characterW
, 2, 2);
3002 test_range_text(range
, "ab");
3004 test_range_move(range
, characterW
, -2, -2);
3005 test_range_moveend(range
, characterW
, 2, 2);
3006 test_range_text(range
, "t ");
3008 test_range_move(range
, wordW
, 3, 3);
3009 test_range_move(range
, wordW
, -2, -2);
3010 test_range_moveend(range
, characterW
, 2, 2);
3011 test_range_text(range
, "ab");
3013 test_range_move(range
, characterW
, -6, -5);
3014 test_range_moveend(range
, characterW
, -1, 0);
3015 test_range_moveend(range
, characterW
, -6, 0);
3016 test_range_move(range
, characterW
, 2, 2);
3017 test_range_moveend(range
, characterW
, 2, 2);
3018 test_range_text(range
, "st");
3019 test_range_moveend(range
, characterW
, -6, -4);
3020 test_range_moveend(range
, characterW
, 2, 2);
3022 IHTMLTxtRange_Release(range
);
3024 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3025 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3027 test_range_move(range
, wordW
, 2, 2);
3028 test_range_moveend(range
, characterW
, 2, 2);
3029 test_range_text(range
, "12");
3031 test_range_move(range
, characterW
, 15, 14);
3032 test_range_move(range
, characterW
, -2, -2);
3033 test_range_moveend(range
, characterW
, 3, 2);
3034 test_range_text(range
, "t");
3035 test_range_moveend(range
, characterW
, -1, -1);
3036 test_range_text(range
, "t");
3037 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
3038 test_range_move(range
, characterW
, -2, -2);
3039 test_range_moveend(range
, characterW
, 2, 2);
3040 test_range_text(range
, "s ");
3041 test_range_move(range
, characterW
, 100, 7);
3042 test_range_move(range
, wordW
, 1, 0);
3043 test_range_move(range
, characterW
, -2, -2);
3044 test_range_moveend(range
, characterW
, 3, 2);
3045 test_range_text(range
, "t");
3047 IHTMLTxtRange_Release(range
);
3049 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
3050 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
3052 test_range_collapse(range
, TRUE
);
3053 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
3054 test_range_put_text(range
, "word");
3055 test_range_text(body_range
, "wordabc 123\r\nit's text");
3056 test_range_text(range
, NULL
);
3057 test_range_moveend(range
, characterW
, 3, 3);
3058 test_range_text(range
, "abc");
3059 test_range_movestart(range
, characterW
, -2, -2);
3060 test_range_text(range
, "rdabc");
3061 test_range_movestart(range
, characterW
, 3, 3);
3062 test_range_text(range
, "bc");
3063 test_range_movestart(range
, characterW
, 4, 4);
3064 test_range_text(range
, NULL
);
3065 test_range_movestart(range
, characterW
, -3, -3);
3066 test_range_text(range
, "c 1");
3067 test_range_movestart(range
, characterW
, -7, -6);
3068 test_range_text(range
, "wordabc 1");
3069 test_range_movestart(range
, characterW
, 100, 22);
3070 test_range_text(range
, NULL
);
3072 IHTMLTxtRange_Release(range
);
3073 IHTMLTxtRange_Release(body_range
);
3075 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
3076 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
3078 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
3079 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
3080 IHTMLSelectionObject_Release(selection
);
3082 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
3083 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
3084 IDispatch_Release(disp_range
);
3086 test_range_text(range
, NULL
);
3087 test_range_moveend(range
, characterW
, 3, 3);
3088 test_range_text(range
, "wor");
3089 test_range_parent(range
, ET_BODY
);
3090 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3091 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
3092 test_range_move(range
, characterW
, 3, 3);
3093 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
3094 test_range_moveend(range
, characterW
, -4, -4);
3095 test_range_put_text(range
, "abc def ");
3096 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
3097 test_range_move(range
, wordW
, 1, 1);
3098 test_range_movestart(range
, characterW
, -1, -1);
3099 test_range_text(range
, " ");
3100 test_range_move(range
, wordW
, 1, 1);
3101 test_range_moveend(range
, characterW
, 3, 3);
3102 test_range_text(range
, "def");
3103 test_range_put_text(range
, "xyz");
3104 test_range_moveend(range
, characterW
, 1, 1);
3105 test_range_move(range
, wordW
, 1, 1);
3106 test_range_moveend(range
, characterW
, 2, 2);
3107 test_range_text(range
, "ab");
3109 IHTMLTxtRange_Release(range
);
3112 static void test_txtrange2(IHTMLDocument2
*doc
)
3114 IHTMLTxtRange
*range
;
3116 range
= test_create_body_range(doc
);
3118 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3119 test_range_move(range
, characterW
, 5, 5);
3120 test_range_moveend(range
, characterW
, 1, 1);
3121 test_range_text(range
, "2");
3122 test_range_move(range
, characterW
, -3, -3);
3123 test_range_moveend(range
, characterW
, 3, 3);
3124 test_range_text(range
, "c\r\n\r\n1");
3125 test_range_collapse(range
, VARIANT_FALSE
);
3126 test_range_moveend(range
, characterW
, 4, 4);
3127 test_range_text(range
, "23");
3128 test_range_moveend(range
, characterW
, 1, 1);
3129 test_range_text(range
, "23\r\n\r\n\r\nd");
3130 test_range_moveend(range
, characterW
, -1, -1);
3131 test_range_text(range
, "23");
3132 test_range_moveend(range
, characterW
, -1, -1);
3133 test_range_text(range
, "23");
3134 test_range_moveend(range
, characterW
, -2, -2);
3135 test_range_text(range
, "2");
3137 IHTMLTxtRange_Release(range
);
3140 static void test_compatmode(IHTMLDocument2
*doc
)
3142 IHTMLDocument5
*doc5
;
3146 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3147 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
3151 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
3152 IHTMLDocument5_Release(doc5
);
3153 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
3154 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
3155 SysFreeString(mode
);
3158 static void test_location(IHTMLDocument2
*doc
)
3160 IHTMLLocation
*location
, *location2
;
3161 IHTMLWindow2
*window
;
3166 hres
= IHTMLDocument2_get_location(doc
, &location
);
3167 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3169 hres
= IHTMLDocument2_get_location(doc
, &location2
);
3170 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3172 ok(location
== location2
, "location != location2\n");
3173 IHTMLLocation_Release(location2
);
3175 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3176 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3178 hres
= IHTMLWindow2_get_location(window
, &location2
);
3179 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3180 ok(location
== location2
, "location != location2\n");
3181 IHTMLLocation_Release(location2
);
3183 test_ifaces((IUnknown
*)location
, location_iids
);
3184 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
3186 hres
= IHTMLLocation_get_pathname(location
, &str
);
3187 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
3188 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
3190 hres
= IHTMLLocation_get_href(location
, NULL
);
3191 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
3193 hres
= IHTMLLocation_get_href(location
, &str
);
3194 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
3195 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
3197 ref
= IHTMLLocation_Release(location
);
3198 ok(!ref
, "location chould be destroyed here\n");
3201 static void test_navigator(IHTMLDocument2
*doc
)
3203 IHTMLWindow2
*window
;
3204 IOmNavigator
*navigator
, *navigator2
;
3211 static const WCHAR v40
[] = {'4','.','0'};
3213 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3214 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
3216 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
3217 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3218 ok(navigator
!= NULL
, "navigator == NULL\n");
3219 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
3221 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
3222 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3223 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
3225 IHTMLWindow2_Release(window
);
3226 IOmNavigator_Release(navigator2
);
3228 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
3229 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
3230 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3231 SysFreeString(bstr
);
3234 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
3235 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
3236 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3237 SysFreeString(bstr
);
3240 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
3241 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
3243 ok(!strcmp_wa(bstr
, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3245 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3247 SysFreeString(bstr
);
3250 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3251 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3252 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
3253 SysFreeString(bstr
);
3255 hres
= IOmNavigator_toString(navigator
, NULL
);
3256 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
3259 hres
= IOmNavigator_toString(navigator
, &bstr
);
3260 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
3261 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
3262 SysFreeString(bstr
);
3265 hres
= ObtainUserAgentString(0, buf
, &size
);
3266 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
3269 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
3270 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
3271 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
3272 SysFreeString(bstr
);
3274 if(!strncmp(buf
, "Mozilla/", 8)) {
3276 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3277 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3278 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
3279 SysFreeString(bstr
);
3281 skip("nonstandard user agent\n");
3284 ref
= IOmNavigator_Release(navigator
);
3285 ok(!ref
, "navigator should be destroyed here\n");
3288 static void test_screen(IHTMLWindow2
*window
)
3290 IHTMLScreen
*screen
, *screen2
;
3291 IDispatchEx
*dispex
;
3297 hres
= IHTMLWindow2_get_screen(window
, &screen
);
3298 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3299 ok(screen
!= NULL
, "screen == NULL\n");
3302 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
3303 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3304 ok(screen2
!= NULL
, "screen == NULL\n");
3305 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
3306 IHTMLScreen_Release(screen2
);
3308 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
3309 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
3310 if(SUCCEEDED(hres
)) {
3311 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
3312 IDispatchEx_Release(dispex
);
3315 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
3317 exl
= GetDeviceCaps(hdc
, HORZRES
);
3319 hres
= IHTMLScreen_get_width(screen
, &l
);
3320 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3321 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
3323 exl
= GetDeviceCaps(hdc
, VERTRES
);
3325 hres
= IHTMLScreen_get_height(screen
, &l
);
3326 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3327 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3329 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
3331 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
3332 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3333 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3337 IHTMLScreen_Release(screen
);
3340 static void test_current_style(IHTMLCurrentStyle
*current_style
)
3346 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
, "[object]");
3347 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
3349 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
3350 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3351 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", wine_dbgstr_w(str
));
3354 hres
= IHTMLCurrentStyle_get_position(current_style
, &str
);
3355 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3356 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3359 hres
= IHTMLCurrentStyle_get_fontFamily(current_style
, &str
);
3360 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3363 hres
= IHTMLCurrentStyle_get_fontStyle(current_style
, &str
);
3364 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
3365 ok(!strcmp_wa(str
, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str
));
3368 hres
= IHTMLCurrentStyle_get_backgroundImage(current_style
, &str
);
3369 ok(hres
== S_OK
, "get_backgroundImage failed: %08x\n", hres
);
3370 ok(!strcmp_wa(str
, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str
));
3373 hres
= IHTMLCurrentStyle_get_fontVariant(current_style
, &str
);
3374 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3375 ok(!strcmp_wa(str
, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str
));
3378 hres
= IHTMLCurrentStyle_get_borderTopStyle(current_style
, &str
);
3379 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
3380 ok(!strcmp_wa(str
, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str
));
3383 hres
= IHTMLCurrentStyle_get_borderRightStyle(current_style
, &str
);
3384 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
3385 ok(!strcmp_wa(str
, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str
));
3388 hres
= IHTMLCurrentStyle_get_borderBottomStyle(current_style
, &str
);
3389 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
3390 ok(!strcmp_wa(str
, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str
));
3393 hres
= IHTMLCurrentStyle_get_borderLeftStyle(current_style
, &str
);
3394 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
3395 ok(!strcmp_wa(str
, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str
));
3398 hres
= IHTMLCurrentStyle_get_textAlign(current_style
, &str
);
3399 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
3400 ok(!strcmp_wa(str
, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str
));
3403 hres
= IHTMLCurrentStyle_get_textDecoration(current_style
, &str
);
3404 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3405 ok(!strcmp_wa(str
, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str
));
3408 hres
= IHTMLCurrentStyle_get_cursor(current_style
, &str
);
3409 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
3410 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
3413 hres
= IHTMLCurrentStyle_get_backgroundRepeat(current_style
, &str
);
3414 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
3415 ok(!strcmp_wa(str
, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str
));
3418 hres
= IHTMLCurrentStyle_get_borderColor(current_style
, &str
);
3419 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
3422 hres
= IHTMLCurrentStyle_get_borderStyle(current_style
, &str
);
3423 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
3426 hres
= IHTMLCurrentStyle_get_visibility(current_style
, &str
);
3427 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3430 hres
= IHTMLCurrentStyle_get_overflow(current_style
, &str
);
3431 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
3434 hres
= IHTMLCurrentStyle_get_borderWidth(current_style
, &str
);
3435 ok(hres
== S_OK
, "get_borderWidth failed: %08x\n", hres
);
3438 hres
= IHTMLCurrentStyle_get_margin(current_style
, &str
);
3439 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3442 hres
= IHTMLCurrentStyle_get_fontWeight(current_style
, &v
);
3443 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3444 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3445 ok( V_I4(&v
) == 400, "expect 400 got (%d)\n", V_I4(&v
));
3448 hres
= IHTMLCurrentStyle_get_fontSize(current_style
, &v
);
3449 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3450 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3453 hres
= IHTMLCurrentStyle_get_left(current_style
, &v
);
3454 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3455 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3458 hres
= IHTMLCurrentStyle_get_top(current_style
, &v
);
3459 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3460 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3463 hres
= IHTMLCurrentStyle_get_width(current_style
, &v
);
3464 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3465 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3468 hres
= IHTMLCurrentStyle_get_height(current_style
, &v
);
3469 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3470 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3473 hres
= IHTMLCurrentStyle_get_paddingLeft(current_style
, &v
);
3474 ok(hres
== S_OK
, "get_paddingLeft failed: %08x\n", hres
);
3475 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3478 hres
= IHTMLCurrentStyle_get_zIndex(current_style
, &v
);
3479 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
3480 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3481 ok( V_I4(&v
) == 1, "expect 1 got (%d)\n", V_I4(&v
));
3484 hres
= IHTMLCurrentStyle_get_verticalAlign(current_style
, &v
);
3485 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
3486 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3487 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3490 hres
= IHTMLCurrentStyle_get_marginRight(current_style
, &v
);
3491 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3492 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3495 hres
= IHTMLCurrentStyle_get_marginLeft(current_style
, &v
);
3496 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3497 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3500 hres
= IHTMLCurrentStyle_get_borderLeftWidth(current_style
, &v
);
3501 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
3502 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3506 hres
= IHTMLCurrentStyle_get_borderRightWidth(current_style
, &v
);
3507 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
3508 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3511 hres
= IHTMLCurrentStyle_get_borderBottomWidth(current_style
, &v
);
3512 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
3513 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3516 hres
= IHTMLCurrentStyle_get_borderTopWidth(current_style
, &v
);
3517 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
3518 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3521 hres
= IHTMLCurrentStyle_get_color(current_style
, &v
);
3522 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3523 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3526 hres
= IHTMLCurrentStyle_get_backgroundColor(current_style
, &v
);
3527 ok(hres
== S_OK
, "get_backgroundColor failed: %08x\n", hres
);
3528 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3531 hres
= IHTMLCurrentStyle_get_borderLeftColor(current_style
, &v
);
3532 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
3533 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3536 hres
= IHTMLCurrentStyle_get_borderTopColor(current_style
, &v
);
3537 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
3538 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3541 hres
= IHTMLCurrentStyle_get_borderRightColor(current_style
, &v
);
3542 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
3543 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3546 hres
= IHTMLCurrentStyle_get_borderBottomColor(current_style
, &v
);
3547 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
3548 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3551 hres
= IHTMLCurrentStyle_get_paddingTop(current_style
, &v
);
3552 ok(hres
== S_OK
, "get_paddingTop failed: %08x\n", hres
);
3553 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3556 hres
= IHTMLCurrentStyle_get_paddingRight(current_style
, &v
);
3557 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3558 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3561 hres
= IHTMLCurrentStyle_get_paddingBottom(current_style
, &v
);
3562 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3563 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3566 hres
= IHTMLCurrentStyle_get_letterSpacing(current_style
, &v
);
3567 ok(hres
== S_OK
, "get_letterSpacing failed: %08x\n", hres
);
3568 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3571 hres
= IHTMLCurrentStyle_get_marginTop(current_style
, &v
);
3572 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3573 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3576 hres
= IHTMLCurrentStyle_get_marginBottom(current_style
, &v
);
3577 ok(hres
== S_OK
, "get_marginBottom failed: %08x\n", hres
);
3578 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3581 hres
= IHTMLCurrentStyle_get_right(current_style
, &v
);
3582 ok(hres
== S_OK
, "get_Right failed: %08x\n", hres
);
3583 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3586 hres
= IHTMLCurrentStyle_get_bottom(current_style
, &v
);
3587 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3588 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3591 hres
= IHTMLCurrentStyle_get_lineHeight(current_style
, &v
);
3592 ok(hres
== S_OK
, "get_lineHeight failed: %08x\n", hres
);
3593 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3596 hres
= IHTMLCurrentStyle_get_textIndent(current_style
, &v
);
3597 ok(hres
== S_OK
, "get_textIndent failed: %08x\n", hres
);
3598 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3602 static void test_style2(IHTMLStyle2
*style2
)
3608 str
= (void*)0xdeadbeef;
3609 hres
= IHTMLStyle2_get_position(style2
, &str
);
3610 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3611 ok(!str
, "str != NULL\n");
3613 str
= a2bstr("absolute");
3614 hres
= IHTMLStyle2_put_position(style2
, str
);
3615 ok(hres
== S_OK
, "put_position failed: %08x\n", hres
);
3619 hres
= IHTMLStyle2_get_position(style2
, &str
);
3620 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3621 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3625 V_VT(&v
) = VT_EMPTY
;
3626 hres
= IHTMLStyle2_get_right(style2
, &v
);
3627 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3628 ok(V_VT(&v
) == VT_BSTR
, "V_VT(right)=%d\n", V_VT(&v
));
3629 ok(!V_BSTR(&v
), "V_BSTR(right) != NULL\n");
3633 V_BSTR(&v
) = a2bstr("3px");
3634 hres
= IHTMLStyle2_put_right(style2
, v
);
3635 ok(hres
== S_OK
, "put_right failed: %08x\n", hres
);
3638 V_VT(&v
) = VT_EMPTY
;
3639 hres
= IHTMLStyle2_get_right(style2
, &v
);
3640 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3641 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3642 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3646 static void test_style3(IHTMLStyle3
*style3
)
3651 str
= (void*)0xdeadbeef;
3652 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3653 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3654 ok(!str
, "str != NULL\n");
3656 str
= a2bstr("break-word");
3657 hres
= IHTMLStyle3_put_wordWrap(style3
, str
);
3658 ok(hres
== S_OK
, "put_wordWrap failed: %08x\n", hres
);
3662 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3663 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3664 ok(!strcmp_wa(str
, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str
));
3668 static void test_style4(IHTMLStyle4
*style4
)
3674 hres
= IHTMLStyle4_get_minHeight(style4
, &vdefault
);
3675 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3678 V_BSTR(&v
) = a2bstr("10px");
3679 hres
= IHTMLStyle4_put_minHeight(style4
, v
);
3680 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3683 hres
= IHTMLStyle4_get_minHeight(style4
, &v
);
3684 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3685 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3686 ok( !strcmp_wa(V_BSTR(&v
), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
3688 hres
= IHTMLStyle4_put_minHeight(style4
, vdefault
);
3689 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3690 VariantClear(&vdefault
);
3693 static void test_default_style(IHTMLStyle
*style
)
3695 IHTMLStyle2
*style2
;
3696 IHTMLStyle3
*style3
;
3697 IHTMLStyle4
*style4
;
3703 BSTR sOverflowDefault
;
3707 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
3708 test_ifaces((IUnknown
*)style
, style_iids
);
3710 test_style_csstext(style
, NULL
);
3712 hres
= IHTMLStyle_get_position(style
, &str
);
3713 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3714 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
3717 hres
= IHTMLStyle_get_marginRight(style
, &v
);
3718 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3719 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginRight) = %d\n", V_VT(&v
));
3720 ok(!V_BSTR(&v
), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3723 hres
= IHTMLStyle_get_marginLeft(style
, &v
);
3724 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3725 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginLeft) = %d\n", V_VT(&v
));
3726 ok(!V_BSTR(&v
), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3728 str
= (void*)0xdeadbeef;
3729 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
3730 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3731 ok(!str
, "fontFamily = %s\n", wine_dbgstr_w(str
));
3733 str
= (void*)0xdeadbeef;
3734 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3735 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3736 ok(!str
, "fontWeight = %s\n", wine_dbgstr_w(str
));
3738 hres
= IHTMLStyle_get_fontWeight(style
, &sDefault
);
3739 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3741 str
= a2bstr("test");
3742 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3743 ok(hres
== E_INVALIDARG
, "put_fontWeight failed: %08x\n", hres
);
3746 str
= a2bstr("bold");
3747 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3748 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3751 str
= a2bstr("bolder");
3752 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3753 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3756 str
= a2bstr("lighter");
3757 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3758 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3761 str
= a2bstr("100");
3762 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3763 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3766 str
= a2bstr("200");
3767 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3768 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3771 str
= a2bstr("300");
3772 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3773 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3776 str
= a2bstr("400");
3777 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3778 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3781 str
= a2bstr("500");
3782 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3783 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3786 str
= a2bstr("600");
3787 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3788 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3791 str
= a2bstr("700");
3792 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3793 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3796 str
= a2bstr("800");
3797 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3798 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3801 str
= a2bstr("900");
3802 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3803 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3806 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3807 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3808 ok(!strcmp_wa(str
, "900"), "str != style900\n");
3811 hres
= IHTMLStyle_put_fontWeight(style
, sDefault
);
3812 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3813 SysFreeString(sDefault
);
3816 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
3817 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
3819 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
3820 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3822 str
= a2bstr("test");
3823 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3824 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
3827 str
= a2bstr("small-caps");
3828 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3829 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3832 str
= a2bstr("normal");
3833 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3834 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3837 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
3838 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3839 SysFreeString(sDefault
);
3841 str
= (void*)0xdeadbeef;
3842 hres
= IHTMLStyle_get_display(style
, &str
);
3843 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3844 ok(!str
, "display = %s\n", wine_dbgstr_w(str
));
3846 str
= (void*)0xdeadbeef;
3847 hres
= IHTMLStyle_get_visibility(style
, &str
);
3848 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3849 ok(!str
, "visibility = %s\n", wine_dbgstr_w(str
));
3852 hres
= IHTMLStyle_get_fontSize(style
, &v
);
3853 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3854 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
3855 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3858 hres
= IHTMLStyle_get_color(style
, &v
);
3859 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3860 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
3861 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3864 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3865 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3866 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3868 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_TRUE
);
3869 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3870 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3872 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3873 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3874 ok(b
== VARIANT_TRUE
, "textDecorationUnderline = %x\n", b
);
3876 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_FALSE
);
3877 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3880 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3881 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3882 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3884 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_TRUE
);
3885 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3886 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3888 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3889 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3890 ok(b
== VARIANT_TRUE
, "textDecorationLineThrough = %x\n", b
);
3892 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_FALSE
);
3893 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3896 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3897 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3898 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3900 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_TRUE
);
3901 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3902 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3904 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3905 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3906 ok(b
== VARIANT_TRUE
, "textDecorationNone = %x\n", b
);
3908 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_FALSE
);
3909 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3912 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3913 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3914 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3916 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_TRUE
);
3917 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3918 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3920 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3921 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3922 ok(b
== VARIANT_TRUE
, "textDecorationOverline = %x\n", b
);
3924 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_FALSE
);
3925 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3928 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3929 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3930 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3932 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_TRUE
);
3933 ok(hres
== S_OK
, "put_textDecorationBlink failed: %08x\n", hres
);
3934 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3936 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3937 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3938 ok(b
== VARIANT_TRUE
, "textDecorationBlink = %x\n", b
);
3940 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_FALSE
);
3941 ok(hres
== S_OK
, "textDecorationBlink failed: %08x\n", hres
);
3943 hres
= IHTMLStyle_get_textDecoration(style
, &sDefault
);
3944 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3946 str
= a2bstr("invalid");
3947 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3948 ok(hres
== E_INVALIDARG
, "put_textDecoration failed: %08x\n", hres
);
3951 str
= a2bstr("none");
3952 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3953 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3956 str
= a2bstr("underline");
3957 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3958 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3961 str
= a2bstr("overline");
3962 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3963 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3966 str
= a2bstr("line-through");
3967 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3968 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3971 str
= a2bstr("blink");
3972 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3973 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3976 hres
= IHTMLStyle_get_textDecoration(style
, &str
);
3977 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3978 ok(!strcmp_wa(str
, "blink"), "str != blink\n");
3981 hres
= IHTMLStyle_put_textDecoration(style
, sDefault
);
3982 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3983 SysFreeString(sDefault
);
3985 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
3986 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
3988 hres
= IHTMLStyle_get_posWidth(style
, &f
);
3989 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
3990 ok(f
== 0.0f
, "f = %f\n", f
);
3992 V_VT(&v
) = VT_EMPTY
;
3993 hres
= IHTMLStyle_get_width(style
, &v
);
3994 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3995 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3996 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
3998 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
3999 ok(hres
== S_OK
, "put_posWidth failed: %08x\n", hres
);
4001 hres
= IHTMLStyle_get_posWidth(style
, &f
);
4002 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
4004 f
== 2.2f
, /* IE8 */
4008 V_BSTR(&v
) = a2bstr("auto");
4009 hres
= IHTMLStyle_put_width(style
, v
);
4010 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4013 V_VT(&v
) = VT_EMPTY
;
4014 hres
= IHTMLStyle_get_width(style
, &v
);
4015 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4016 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4017 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4022 hres
= IHTMLStyle_put_width(style
, v
);
4023 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
4025 V_VT(&v
) = VT_EMPTY
;
4026 hres
= IHTMLStyle_get_width(style
, &v
);
4027 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
4028 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4029 ok(!strcmp_wa(V_BSTR(&v
), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4033 str
= (void*)0xdeadbeef;
4034 hres
= IHTMLStyle_get_margin(style
, &str
);
4035 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4036 ok(!str
, "margin = %s\n", wine_dbgstr_w(str
));
4039 hres
= IHTMLStyle_put_margin(style
, str
);
4040 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4043 hres
= IHTMLStyle_get_margin(style
, &str
);
4044 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
4045 ok(!strcmp_wa(str
, "1px"), "margin = %s\n", wine_dbgstr_w(str
));
4047 hres
= IHTMLStyle_put_margin(style
, NULL
);
4048 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
4050 str
= (void*)0xdeadbeef;
4051 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4052 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4053 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4054 ok(!V_BSTR(&v
), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4057 V_BSTR(&v
) = a2bstr("6px");
4058 hres
= IHTMLStyle_put_marginTop(style
, v
);
4059 SysFreeString(V_BSTR(&v
));
4060 ok(hres
== S_OK
, "put_marginTop failed: %08x\n", hres
);
4062 str
= (void*)0xdeadbeef;
4063 hres
= IHTMLStyle_get_marginTop(style
, &v
);
4064 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
4065 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
4066 ok(!strcmp_wa(V_BSTR(&v
), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4069 hres
= IHTMLStyle_get_border(style
, &str
);
4070 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
4071 ok(!str
|| !*str
, "str is not empty\n");
4074 str
= a2bstr("1px");
4075 hres
= IHTMLStyle_put_border(style
, str
);
4076 ok(hres
== S_OK
, "put_border failed: %08x\n", hres
);
4079 V_VT(&v
) = VT_EMPTY
;
4080 hres
= IHTMLStyle_get_left(style
, &v
);
4081 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4082 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4083 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4087 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
4088 ok(hres
== E_POINTER
, "get_posLeft failed: %08x\n", hres
);
4091 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4092 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4093 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4095 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
4096 ok(hres
== S_OK
, "put_posLeft failed: %08x\n", hres
);
4098 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4099 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4101 f
== 4.9f
, /* IE8 */
4102 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4104 /* Ensure left is updated correctly. */
4105 V_VT(&v
) = VT_EMPTY
;
4106 hres
= IHTMLStyle_get_left(style
, &v
);
4107 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4108 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4109 ok(!strcmp_wa(V_BSTR(&v
), "4px") ||
4110 !strcmp_wa(V_BSTR(&v
), "4.9px"), /* IE8 */
4111 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4116 V_BSTR(&v
) = a2bstr("3px");
4117 hres
= IHTMLStyle_put_left(style
, v
);
4118 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4121 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4122 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4123 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4125 V_VT(&v
) = VT_EMPTY
;
4126 hres
= IHTMLStyle_get_left(style
, &v
);
4127 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4128 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4129 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4133 hres
= IHTMLStyle_put_left(style
, v
);
4134 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4136 V_VT(&v
) = VT_EMPTY
;
4137 hres
= IHTMLStyle_get_left(style
, &v
);
4138 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4139 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4140 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4143 V_VT(&v
) = VT_EMPTY
;
4144 hres
= IHTMLStyle_get_top(style
, &v
);
4145 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4146 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4147 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4151 hres
= IHTMLStyle_get_posTop(style
, NULL
);
4152 ok(hres
== E_POINTER
, "get_posTop failed: %08x\n", hres
);
4155 hres
= IHTMLStyle_get_posTop(style
, &f
);
4156 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4157 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4159 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
4160 ok(hres
== S_OK
, "put_posTop failed: %08x\n", hres
);
4162 hres
= IHTMLStyle_get_posTop(style
, &f
);
4163 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4165 f
== 4.9f
, /* IE8 */
4166 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4169 V_BSTR(&v
) = a2bstr("3px");
4170 hres
= IHTMLStyle_put_top(style
, v
);
4171 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4174 V_VT(&v
) = VT_EMPTY
;
4175 hres
= IHTMLStyle_get_top(style
, &v
);
4176 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4177 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4178 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4181 hres
= IHTMLStyle_get_posTop(style
, &f
);
4182 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4183 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4186 hres
= IHTMLStyle_put_top(style
, v
);
4187 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4189 V_VT(&v
) = VT_EMPTY
;
4190 hres
= IHTMLStyle_get_top(style
, &v
);
4191 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4192 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4193 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4196 /* Test posHeight */
4197 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
4198 ok(hres
== E_POINTER
, "get_posHeight failed: %08x\n", hres
);
4200 V_VT(&v
) = VT_EMPTY
;
4201 hres
= IHTMLStyle_get_height(style
, &v
);
4202 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4203 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4204 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4208 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4209 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4210 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4212 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
4213 ok(hres
== S_OK
, "put_posHeight failed: %08x\n", hres
);
4215 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4216 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4218 f
== 4.9f
, /* IE8 */
4219 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4222 V_BSTR(&v
) = a2bstr("64px");
4223 hres
= IHTMLStyle_put_height(style
, v
);
4224 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
4227 V_VT(&v
) = VT_EMPTY
;
4228 hres
= IHTMLStyle_get_height(style
, &v
);
4229 ok(hres
== S_OK
, "get_height 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
), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4234 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4235 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4236 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
4238 str
= (void*)0xdeadbeef;
4239 hres
= IHTMLStyle_get_cursor(style
, &str
);
4240 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4241 ok(!str
, "get_cursor != NULL\n");
4244 str
= a2bstr("default");
4245 hres
= IHTMLStyle_put_cursor(style
, str
);
4246 ok(hres
== S_OK
, "put_cursor failed: %08x\n", hres
);
4250 hres
= IHTMLStyle_get_cursor(style
, &str
);
4251 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4252 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
4255 V_VT(&v
) = VT_EMPTY
;
4256 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4257 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
4258 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4259 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4263 V_BSTR(&v
) = a2bstr("middle");
4264 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
4265 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
4268 V_VT(&v
) = VT_EMPTY
;
4269 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4270 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4271 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4272 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4275 str
= (void*)0xdeadbeef;
4276 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4277 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4278 ok(!str
, "textAlign != NULL\n");
4280 str
= a2bstr("center");
4281 hres
= IHTMLStyle_put_textAlign(style
, str
);
4282 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
4286 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4287 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4288 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4291 str
= (void*)0xdeadbeef;
4292 hres
= IHTMLStyle_get_filter(style
, &str
);
4293 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
4294 ok(!str
, "filter != NULL\n");
4296 str
= a2bstr("alpha(opacity=100)");
4297 hres
= IHTMLStyle_put_filter(style
, str
);
4298 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
4301 V_VT(&v
) = VT_EMPTY
;
4302 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4303 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4304 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4305 ok(!V_I4(&v
), "V_I4(v) != 0\n");
4309 V_BSTR(&v
) = a2bstr("1");
4310 hres
= IHTMLStyle_put_zIndex(style
, v
);
4311 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
4314 V_VT(&v
) = VT_EMPTY
;
4315 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4316 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4317 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4318 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
4322 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
4323 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
4325 str
= a2bstr("test");
4326 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4327 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
4330 str
= a2bstr("italic");
4331 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4332 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4335 str
= a2bstr("oblique");
4336 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4337 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4340 str
= a2bstr("normal");
4341 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4342 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4345 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
4346 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4347 SysFreeString(sDefault
);
4350 hres
= IHTMLStyle_get_overflow(style
, NULL
);
4351 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
4353 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
4354 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4356 str
= a2bstr("test");
4357 hres
= IHTMLStyle_put_overflow(style
, str
);
4358 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
4361 str
= a2bstr("visible");
4362 hres
= IHTMLStyle_put_overflow(style
, str
);
4363 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4366 str
= a2bstr("scroll");
4367 hres
= IHTMLStyle_put_overflow(style
, str
);
4368 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4371 str
= a2bstr("hidden");
4372 hres
= IHTMLStyle_put_overflow(style
, str
);
4373 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4376 str
= a2bstr("auto");
4377 hres
= IHTMLStyle_put_overflow(style
, str
);
4378 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4381 hres
= IHTMLStyle_get_overflow(style
, &str
);
4382 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4383 ok(!strcmp_wa(str
, "auto"), "str=%s\n", wine_dbgstr_w(str
));
4387 hres
= IHTMLStyle_put_overflow(style
, str
);
4388 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4391 hres
= IHTMLStyle_get_overflow(style
, &str
);
4392 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4393 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4396 /* restore overflow default */
4397 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
4398 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4399 SysFreeString(sOverflowDefault
);
4401 /* Attribute Tests*/
4402 hres
= IHTMLStyle_getAttribute(style
, NULL
, 1, &v
);
4403 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4405 str
= a2bstr("position");
4406 hres
= IHTMLStyle_getAttribute(style
, str
, 1, NULL
);
4407 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4409 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4410 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4411 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4414 hres
= IHTMLStyle_setAttribute(style
, NULL
, v
, 1);
4415 ok(hres
== E_INVALIDARG
, "setAttribute failed: %08x\n", hres
);
4418 V_BSTR(&v
) = a2bstr("absolute");
4419 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4420 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4423 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4424 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4425 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4426 ok(!strcmp_wa(V_BSTR(&v
), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4431 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4432 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4437 str
= a2bstr("borderLeftStyle");
4438 test_border_styles(style
, str
);
4441 str
= a2bstr("borderbottomstyle");
4442 test_border_styles(style
, str
);
4445 str
= a2bstr("borderrightstyle");
4446 test_border_styles(style
, str
);
4449 str
= a2bstr("bordertopstyle");
4450 test_border_styles(style
, str
);
4453 hres
= IHTMLStyle_get_borderStyle(style
, &sDefault
);
4454 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4456 str
= a2bstr("none dotted dashed solid");
4457 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4458 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4461 str
= a2bstr("none dotted dashed solid");
4462 hres
= IHTMLStyle_get_borderStyle(style
, &str
);
4463 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4464 ok(!strcmp_wa(str
, "none dotted dashed solid"),
4465 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4468 str
= a2bstr("double groove ridge inset");
4469 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4470 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4473 str
= a2bstr("window-inset outset ridge inset");
4474 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4475 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4478 str
= a2bstr("window-inset");
4479 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4480 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4483 str
= a2bstr("none none none none none");
4484 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4485 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4488 str
= a2bstr("invalid none none none");
4489 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4490 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4493 str
= a2bstr("none invalid none none");
4494 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4495 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4498 hres
= IHTMLStyle_put_borderStyle(style
, sDefault
);
4499 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4500 SysFreeString(sDefault
);
4502 /* backgoundColor */
4503 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4504 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4505 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4506 ok(!V_BSTR(&v
), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4510 hres
= IHTMLStyle_get_paddingLeft(style
, &vDefault
);
4511 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4514 V_BSTR(&v
) = a2bstr("10");
4515 hres
= IHTMLStyle_put_paddingLeft(style
, v
);
4516 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4519 hres
= IHTMLStyle_get_paddingLeft(style
, &v
);
4520 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4521 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4523 hres
= IHTMLStyle_put_paddingLeft(style
, vDefault
);
4524 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4526 /* BackgroundRepeat */
4527 hres
= IHTMLStyle_get_backgroundRepeat(style
, &sDefault
);
4528 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4530 str
= a2bstr("invalid");
4531 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4532 ok(hres
== E_INVALIDARG
, "put_backgroundRepeat failed: %08x\n", hres
);
4535 str
= a2bstr("repeat");
4536 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4537 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4540 str
= a2bstr("no-repeat");
4541 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4542 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4545 str
= a2bstr("repeat-x");
4546 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4547 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4550 str
= a2bstr("repeat-y");
4551 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4552 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4555 hres
= IHTMLStyle_get_backgroundRepeat(style
, &str
);
4556 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4557 ok(!strcmp_wa(str
, "repeat-y"), "str=%s\n", wine_dbgstr_w(str
));
4560 hres
= IHTMLStyle_put_backgroundRepeat(style
, sDefault
);
4561 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4562 SysFreeString(sDefault
);
4565 hres
= IHTMLStyle_get_borderColor(style
, &sDefault
);
4566 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4568 str
= a2bstr("red green red blue");
4569 hres
= IHTMLStyle_put_borderColor(style
, str
);
4570 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4573 hres
= IHTMLStyle_get_borderColor(style
, &str
);
4574 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4575 ok(!strcmp_wa(str
, "red green red blue"), "str=%s\n", wine_dbgstr_w(str
));
4578 hres
= IHTMLStyle_put_borderColor(style
, sDefault
);
4579 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4580 SysFreeString(sDefault
);
4583 hres
= IHTMLStyle_get_borderRight(style
, &sDefault
);
4584 ok(hres
== S_OK
, "get_borderRight failed: %08x\n", hres
);
4586 str
= a2bstr("thick dotted red");
4587 hres
= IHTMLStyle_put_borderRight(style
, str
);
4588 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4591 /* IHTMLStyle_get_borderRight appears to have a bug where
4592 it returns the first letter of the color. So we check
4593 each style individually.
4596 hres
= IHTMLStyle_get_borderRightColor(style
, &v
);
4597 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
4598 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4602 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4603 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
4604 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4607 hres
= IHTMLStyle_get_borderRightStyle(style
, &str
);
4608 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
4609 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4612 hres
= IHTMLStyle_put_borderRight(style
, sDefault
);
4613 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4614 SysFreeString(sDefault
);
4617 hres
= IHTMLStyle_get_borderTop(style
, &sDefault
);
4618 ok(hres
== S_OK
, "get_borderTop failed: %08x\n", hres
);
4620 str
= a2bstr("thick dotted red");
4621 hres
= IHTMLStyle_put_borderTop(style
, str
);
4622 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4625 /* IHTMLStyle_get_borderTop appears to have a bug where
4626 it returns the first letter of the color. So we check
4627 each style individually.
4630 hres
= IHTMLStyle_get_borderTopColor(style
, &v
);
4631 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
4632 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4636 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4637 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
4638 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4641 hres
= IHTMLStyle_get_borderTopStyle(style
, &str
);
4642 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
4643 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4646 hres
= IHTMLStyle_put_borderTop(style
, sDefault
);
4647 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4648 SysFreeString(sDefault
);
4651 hres
= IHTMLStyle_get_borderBottom(style
, &sDefault
);
4652 ok(hres
== S_OK
, "get_borderBottom failed: %08x\n", hres
);
4654 str
= a2bstr("thick dotted red");
4655 hres
= IHTMLStyle_put_borderBottom(style
, str
);
4656 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4659 /* IHTMLStyle_get_borderBottom appears to have a bug where
4660 it returns the first letter of the color. So we check
4661 each style individually.
4664 hres
= IHTMLStyle_get_borderBottomColor(style
, &v
);
4665 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
4666 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4670 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4671 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
4672 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4675 hres
= IHTMLStyle_get_borderBottomStyle(style
, &str
);
4676 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
4677 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4680 hres
= IHTMLStyle_put_borderBottom(style
, sDefault
);
4681 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4682 SysFreeString(sDefault
);
4685 hres
= IHTMLStyle_get_borderLeft(style
, &sDefault
);
4686 ok(hres
== S_OK
, "get_borderLeft failed: %08x\n", hres
);
4688 str
= a2bstr("thick dotted red");
4689 hres
= IHTMLStyle_put_borderLeft(style
, str
);
4690 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4693 /* IHTMLStyle_get_borderLeft 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_borderLeftColor(style
, &v
);
4699 ok(hres
== S_OK
, "get_borderLeftColor 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_borderLeftWidth(style
, &v
);
4705 ok(hres
== S_OK
, "get_borderLeftWidth 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_borderLeftStyle(style
, &str
);
4710 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
4711 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4714 hres
= IHTMLStyle_put_borderLeft(style
, sDefault
);
4715 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4716 SysFreeString(sDefault
);
4718 /* backgroundPositionX */
4719 hres
= IHTMLStyle_get_backgroundPositionX(style
, &vDefault
);
4720 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4723 V_BSTR(&v
) = a2bstr("10px");
4724 hres
= IHTMLStyle_put_backgroundPositionX(style
, v
);
4725 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4728 hres
= IHTMLStyle_get_backgroundPositionX(style
, &v
);
4729 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4730 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4733 hres
= IHTMLStyle_put_backgroundPositionX(style
, vDefault
);
4734 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4735 VariantClear(&vDefault
);
4737 /* backgroundPositionY */
4738 hres
= IHTMLStyle_get_backgroundPositionY(style
, &vDefault
);
4739 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4742 V_BSTR(&v
) = a2bstr("10px");
4743 hres
= IHTMLStyle_put_backgroundPositionY(style
, v
);
4744 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4747 hres
= IHTMLStyle_get_backgroundPositionY(style
, &v
);
4748 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4749 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4752 hres
= IHTMLStyle_put_backgroundPositionY(style
, vDefault
);
4753 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4754 VariantClear(&vDefault
);
4756 /* borderTopWidth */
4757 hres
= IHTMLStyle_get_borderTopWidth(style
, &vDefault
);
4758 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4761 V_BSTR(&v
) = a2bstr("10px");
4762 hres
= IHTMLStyle_put_borderTopWidth(style
, v
);
4763 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4766 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4767 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4768 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4771 hres
= IHTMLStyle_put_borderTopWidth(style
, vDefault
);
4772 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4773 VariantClear(&vDefault
);
4775 /* borderRightWidth */
4776 hres
= IHTMLStyle_get_borderRightWidth(style
, &vDefault
);
4777 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4780 V_BSTR(&v
) = a2bstr("10");
4781 hres
= IHTMLStyle_put_borderRightWidth(style
, v
);
4782 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4785 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4786 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4787 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4790 hres
= IHTMLStyle_put_borderRightWidth(style
, vDefault
);
4791 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4792 VariantClear(&vDefault
);
4794 /* borderBottomWidth */
4795 hres
= IHTMLStyle_get_borderBottomWidth(style
, &vDefault
);
4796 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4799 V_BSTR(&v
) = a2bstr("10");
4800 hres
= IHTMLStyle_put_borderBottomWidth(style
, v
);
4801 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4804 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4805 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4806 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4809 hres
= IHTMLStyle_put_borderBottomWidth(style
, vDefault
);
4810 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4811 VariantClear(&vDefault
);
4813 /* borderLeftWidth */
4814 hres
= IHTMLStyle_get_borderLeftWidth(style
, &vDefault
);
4815 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4818 V_BSTR(&v
) = a2bstr("10");
4819 hres
= IHTMLStyle_put_borderLeftWidth(style
, v
);
4820 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4823 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4824 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4825 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4828 hres
= IHTMLStyle_put_borderLeftWidth(style
, vDefault
);
4829 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4830 VariantClear(&vDefault
);
4833 hres
= IHTMLStyle_get_wordSpacing(style
, &vDefault
);
4834 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4837 V_BSTR(&v
) = a2bstr("10");
4838 hres
= IHTMLStyle_put_wordSpacing(style
, v
);
4839 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4842 hres
= IHTMLStyle_get_wordSpacing(style
, &v
);
4843 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4844 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4845 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4848 hres
= IHTMLStyle_put_wordSpacing(style
, vDefault
);
4849 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4850 VariantClear(&vDefault
);
4853 hres
= IHTMLStyle_get_letterSpacing(style
, &vDefault
);
4854 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4857 V_BSTR(&v
) = a2bstr("11");
4858 hres
= IHTMLStyle_put_letterSpacing(style
, v
);
4859 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4862 hres
= IHTMLStyle_get_letterSpacing(style
, &v
);
4863 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4864 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4865 ok(!strcmp_wa(V_BSTR(&v
), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4868 hres
= IHTMLStyle_put_letterSpacing(style
, vDefault
);
4869 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4870 VariantClear(&vDefault
);
4872 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
4873 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
4874 if(SUCCEEDED(hres
)) {
4875 test_style2(style2
);
4876 IHTMLStyle2_Release(style2
);
4879 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle3
, (void**)&style3
);
4880 ok(hres
== S_OK
, "Could not get IHTMLStyle3 iface: %08x\n", hres
);
4881 if(SUCCEEDED(hres
)) {
4882 test_style3(style3
);
4883 IHTMLStyle3_Release(style3
);
4886 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle4
, (void**)&style4
);
4887 ok(hres
== S_OK
, "Could not get IHTMLStyle4 iface: %08x\n", hres
);
4888 if(SUCCEEDED(hres
)) {
4889 test_style4(style4
);
4890 IHTMLStyle4_Release(style4
);
4894 static void test_set_csstext(IHTMLStyle
*style
)
4899 test_style_set_csstext(style
, "background-color: black;");
4901 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4902 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4903 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4904 ok(!strcmp_wa(V_BSTR(&v
), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4908 static void test_default_selection(IHTMLDocument2
*doc
)
4910 IHTMLSelectionObject
*selection
;
4911 IHTMLTxtRange
*range
;
4916 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4917 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
4919 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
4920 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4921 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
4924 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
4925 IHTMLSelectionObject_Release(selection
);
4926 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
4928 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
4929 IDispatch_Release(disp
);
4930 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
4932 test_range_text(range
, NULL
);
4933 IHTMLTxtRange_Release(range
);
4936 static void test_doc_elem(IHTMLDocument2
*doc
)
4938 IHTMLDocument2
*doc_node
, *owner_doc
;
4940 IHTMLDocument3
*doc3
;
4943 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4944 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
4946 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
4947 IHTMLDocument3_Release(doc3
);
4948 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
4950 test_node_name((IUnknown
*)elem
, "HTML");
4951 test_elem_tag((IUnknown
*)elem
, "HTML");
4953 doc_node
= get_doc_node(doc
);
4954 owner_doc
= get_owner_doc((IUnknown
*)elem
);
4955 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
4956 IHTMLDocument2_Release(owner_doc
);
4958 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
4959 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
4960 IHTMLDocument2_Release(doc_node
);
4962 test_elem_client_rect((IUnknown
*)elem
);
4964 IHTMLElement_Release(elem
);
4967 static void test_default_body(IHTMLBodyElement
*body
)
4974 bstr
= (void*)0xdeadbeef;
4975 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
4976 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
4977 ok(bstr
== NULL
, "bstr != NULL\n");
4979 l
= elem_get_scroll_height((IUnknown
*)body
);
4980 ok(l
!= -1, "scrollHeight == -1\n");
4981 l
= elem_get_scroll_width((IUnknown
*)body
);
4982 ok(l
!= -1, "scrollWidth == -1\n");
4983 l
= elem_get_scroll_top((IUnknown
*)body
);
4984 ok(!l
, "scrollTop = %d\n", l
);
4985 elem_get_scroll_left((IUnknown
*)body
);
4987 /* get_text tests */
4988 hres
= IHTMLBodyElement_get_text(body
, &v
);
4989 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4990 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4991 ok(bstr
== NULL
, "bstr != NULL\n");
4993 /* get_text - Invalid Text */
4995 V_BSTR(&v
) = a2bstr("Invalid");
4996 hres
= IHTMLBodyElement_put_text(body
, v
);
4997 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5001 hres
= IHTMLBodyElement_get_text(body
, &v
);
5002 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5003 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5004 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
5007 /* get_text - Valid Text */
5009 V_BSTR(&v
) = a2bstr("#FF0000");
5010 hres
= IHTMLBodyElement_put_text(body
, v
);
5011 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5015 hres
= IHTMLBodyElement_get_text(body
, &v
);
5016 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5017 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5018 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
5022 static void test_body_funs(IHTMLBodyElement
*body
)
5024 VARIANT vbg
, vDefaultbg
;
5027 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5028 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5029 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5030 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5032 V_VT(&vbg
) = VT_BSTR
;
5033 V_BSTR(&vbg
) = a2bstr("red");
5034 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5035 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5038 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5039 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5040 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
5041 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5044 /* Restore Originial */
5045 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5046 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5047 VariantClear(&vDefaultbg
);
5050 static void test_window(IHTMLDocument2
*doc
)
5052 IHTMLWindow2
*window
, *window2
, *self
;
5053 IHTMLDocument2
*doc2
= NULL
;
5059 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5060 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5061 test_ifaces((IUnknown
*)window
, window_iids
);
5062 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5064 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5065 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5066 ok(doc2
!= NULL
, "doc2 == NULL\n");
5068 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5069 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5071 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5072 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5074 unk
= (void*)0xdeadbeef;
5075 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5076 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5077 ok(!unk
, "unk = %p\n", unk
);
5079 IHTMLDocument_Release(doc2
);
5081 hres
= IHTMLWindow2_get_window(window
, &window2
);
5082 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5083 ok(window2
!= NULL
, "window2 == NULL\n");
5085 hres
= IHTMLWindow2_get_self(window
, &self
);
5086 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5087 ok(window2
!= NULL
, "self == NULL\n");
5089 ok(self
== window2
, "self != window2\n");
5091 IHTMLWindow2_Release(window2
);
5092 IHTMLWindow2_Release(self
);
5095 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5096 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5097 ok(disp
== (void*)window
, "disp != window\n");
5098 IDispatch_Release(disp
);
5100 hres
= IHTMLWindow2_toString(window
, NULL
);
5101 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5104 hres
= IHTMLWindow2_toString(window
, &str
);
5105 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5106 ok(!strcmp_wa(str
, "[object]"), "toString returned %s\n", wine_dbgstr_w(str
));
5109 test_window_name(window
, NULL
);
5110 set_window_name(window
, "test");
5111 test_window_length(window
, 0);
5112 test_screen(window
);
5114 IHTMLWindow2_Release(window
);
5117 static void test_defaults(IHTMLDocument2
*doc
)
5119 IHTMLStyleSheetsCollection
*stylesheetcol
;
5120 IHTMLCurrentStyle
*cstyle
;
5121 IHTMLBodyElement
*body
;
5122 IHTMLElement2
*elem2
;
5127 IHTMLElementCollection
*collection
;
5129 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5130 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5132 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5133 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5135 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5136 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5139 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5140 IHTMLElementCollection_Release(collection
);
5143 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5144 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5146 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5147 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5150 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5151 IHTMLElementCollection_Release(collection
);
5154 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5155 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5157 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5158 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5161 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5162 IHTMLElementCollection_Release(collection
);
5165 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5166 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5168 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5169 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5172 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5173 IHTMLElementCollection_Release(collection
);
5176 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5177 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5179 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5180 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5183 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5184 IHTMLElementCollection_Release(collection
);
5187 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5188 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5189 test_default_body(body
);
5190 test_body_funs(body
);
5191 IHTMLBodyElement_Release(body
);
5193 hres
= IHTMLElement_get_style(elem
, &style
);
5194 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5196 test_default_style(style
);
5198 test_compatmode(doc
);
5200 test_navigator(doc
);
5202 elem2
= get_elem2_iface((IUnknown
*)elem
);
5203 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5204 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5205 if(SUCCEEDED(hres
)) {
5206 test_current_style(cstyle
);
5207 IHTMLCurrentStyle_Release(cstyle
);
5209 IHTMLElement2_Release(elem2
);
5211 IHTMLElement_Release(elem
);
5213 test_set_csstext(style
);
5214 IHTMLStyle_Release(style
);
5216 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5217 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5220 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5221 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5222 ok(l
== 0, "length = %d\n", l
);
5224 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5226 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5227 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5229 test_default_selection(doc
);
5230 test_doc_title(doc
, "");
5233 static void test_tr_elem(IHTMLElement
*elem
)
5235 IHTMLElementCollection
*col
;
5239 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
5241 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
5242 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
5247 hres
= IHTMLTableRow_get_cells(row
, &col
);
5248 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
5249 ok(col
!= NULL
, "get_cells returned NULL\n");
5251 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
5252 IHTMLElementCollection_Release(col
);
5254 IHTMLTable_Release(row
);
5257 static void test_table_elem(IHTMLElement
*elem
)
5259 IHTMLElementCollection
*col
;
5264 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
5265 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
5267 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
5268 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
5273 hres
= IHTMLTable_get_rows(table
, &col
);
5274 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5275 ok(col
!= NULL
, "get_ros returned NULL\n");
5277 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
5278 IHTMLElementCollection_Release(col
);
5280 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5282 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
5283 test_elem_tag((IUnknown
*)node
, "TABLE");
5284 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5285 IHTMLDOMNode_Release(node
);
5287 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
5288 test_elem_tag((IUnknown
*)node
, "TABLE");
5289 test_elem_all((IUnknown
*)node
, NULL
, 0);
5290 IHTMLDOMNode_Release(node
);
5292 IHTMLTable_Release(table
);
5295 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
5305 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
5306 SafeArrayAccessData(sa
, (void**)&var
);
5307 V_VT(var
) = VT_BSTR
;
5308 V_BSTR(var
) = str
= a2bstr(text
);
5309 SafeArrayUnaccessData(sa
);
5312 hres
= IHTMLDocument2_writeln(doc
, sa
);
5314 hres
= IHTMLDocument2_write(doc
, sa
);
5315 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
5318 SafeArrayDestroy(sa
);
5321 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
5323 IHTMLDocument2
*window_doc
, *elem_doc
;
5324 IHTMLFrameElement3
*frame_elem3
;
5325 IHTMLWindow2
*content_window
;
5328 content_window
= get_frame_content_window(frame_elem
);
5329 window_doc
= get_window_doc(content_window
);
5330 IHTMLWindow2_Release(content_window
);
5332 elem_doc
= get_elem_doc(frame_elem
);
5333 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
5336 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
5337 if(SUCCEEDED(hres
)) {
5338 IDispatch
*disp
= NULL
;
5340 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
5341 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
5342 ok(disp
!= NULL
, "contentDocument == NULL\n");
5343 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
5345 IDispatch_Release(disp
);
5346 IHTMLFrameElement3_Release(frame_elem3
);
5348 win_skip("IHTMLFrameElement3 not supported\n");
5352 IHTMLDocument2_Release(elem_doc
);
5353 IHTMLDocument2_Release(window_doc
);
5356 static void test_iframe_elem(IHTMLElement
*elem
)
5358 IHTMLDocument2
*content_doc
, *owner_doc
;
5359 IHTMLElementCollection
*col
;
5360 IHTMLWindow2
*content_window
;
5366 static const elem_type_t all_types
[] = {
5374 test_frame_doc((IUnknown
*)elem
, TRUE
);
5376 content_window
= get_frame_content_window((IUnknown
*)elem
);
5377 test_window_length(content_window
, 0);
5379 content_doc
= get_window_doc(content_window
);
5380 IHTMLWindow2_Release(content_window
);
5382 str
= a2bstr("text/html");
5383 V_VT(&errv
) = VT_ERROR
;
5385 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5387 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5388 ok(disp
!= NULL
, "disp == NULL\n");
5389 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5390 IDispatch_Release(disp
);
5392 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head><body><br /></body>");
5393 doc_write(content_doc
, TRUE
, "</html>");
5395 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5396 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5397 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5398 IHTMLElementCollection_Release(col
);
5400 hres
= IHTMLDocument2_close(content_doc
);
5401 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5403 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5404 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5406 IHTMLDocument2_Release(content_doc
);
5409 static void test_stylesheet(IDispatch
*disp
)
5411 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5412 IHTMLStyleSheet
*stylesheet
;
5415 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5416 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5418 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5419 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5420 ok(col
!= NULL
, "col == NULL\n");
5422 IHTMLStyleSheetRulesCollection_Release(col
);
5423 IHTMLStyleSheet_Release(stylesheet
);
5426 static void test_stylesheets(IHTMLDocument2
*doc
)
5428 IHTMLStyleSheetsCollection
*col
= NULL
;
5433 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5434 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5435 ok(col
!= NULL
, "col == NULL\n");
5437 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5438 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5439 ok(len
== 1, "len=%d\n", len
);
5445 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5446 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5447 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5448 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5449 test_stylesheet(V_DISPATCH(&res
));
5456 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5457 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5458 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5459 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5462 IHTMLStyleSheetsCollection_Release(col
);
5465 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
5467 IDispatchEx
*dispex
;
5469 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
5477 static const WCHAR w0
[] = {'0',0};
5478 static const WCHAR w100
[] = {'1','0','0',0};
5480 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
5481 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
5483 bstr
= SysAllocString(w0
);
5484 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5485 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5486 SysFreeString(bstr
);
5489 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
5490 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
5491 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
5492 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
5493 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
5494 type
= get_node_type((IUnknown
*)node
);
5495 ok(type
== 3, "type=%d\n", type
);
5496 IHTMLDOMNode_Release(node
);
5499 bstr
= SysAllocString(w100
);
5500 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5501 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
5502 SysFreeString(bstr
);
5504 IDispatchEx_Release(dispex
);
5509 static void test_elems(IHTMLDocument2
*doc
)
5511 IHTMLElementCollection
*col
;
5512 IHTMLDOMChildrenCollection
*child_col
;
5513 IHTMLElement
*elem
, *elem2
, *elem3
;
5514 IHTMLDOMNode
*node
, *node2
;
5515 IHTMLWindow2
*window
;
5519 IHTMLElementCollection
*collection
;
5520 IHTMLDocument3
*doc3
;
5523 static const elem_type_t all_types
[] = {
5549 static const elem_type_t item_types
[] = {
5555 hres
= IHTMLDocument2_get_all(doc
, &col
);
5556 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5557 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5558 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
5559 IHTMLElementCollection_Release(col
);
5561 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5562 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5565 static const elem_type_t images_types
[] = {ET_IMG
};
5566 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5568 IHTMLElementCollection_Release(collection
);
5571 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5572 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5575 static const elem_type_t images_types
[] = {ET_A
};
5576 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5578 IHTMLElementCollection_Release(collection
);
5581 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5582 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5585 static const elem_type_t anchor_types
[] = {ET_A
};
5586 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
5588 IHTMLElementCollection_Release(collection
);
5591 elem
= get_doc_elem(doc
);
5592 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
5593 IHTMLElement_Release(elem
);
5595 get_elem_by_id(doc
, "xxx", FALSE
);
5596 elem
= get_doc_elem_by_id(doc
, "xxx");
5597 ok(!elem
, "elem != NULL\n");
5599 elem
= get_doc_elem_by_id(doc
, "s");
5600 ok(elem
!= NULL
, "elem == NULL\n");
5602 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
5603 test_elem_attr(elem
, "xxx", NULL
);
5604 test_elem_attr(elem
, "id", "s");
5605 test_elem_class((IUnknown
*)elem
, NULL
);
5606 test_elem_set_class((IUnknown
*)elem
, "cl");
5607 test_elem_set_class((IUnknown
*)elem
, NULL
);
5608 test_elem_tabindex((IUnknown
*)elem
, 0);
5609 test_elem_set_tabindex((IUnknown
*)elem
, 1);
5610 test_elem_filters((IUnknown
*)elem
);
5612 node
= test_node_get_parent((IUnknown
*)elem
);
5613 ok(node
!= NULL
, "node == NULL\n");
5614 test_node_name((IUnknown
*)node
, "BODY");
5615 node2
= test_node_get_parent((IUnknown
*)node
);
5616 IHTMLDOMNode_Release(node
);
5617 ok(node2
!= NULL
, "node == NULL\n");
5618 test_node_name((IUnknown
*)node2
, "HTML");
5619 node
= test_node_get_parent((IUnknown
*)node2
);
5620 IHTMLDOMNode_Release(node2
);
5621 ok(node
!= NULL
, "node == NULL\n");
5624 test_node_name((IUnknown
*)node
, "#document");
5625 type
= get_node_type((IUnknown
*)node
);
5626 ok(type
== 9, "type=%d, expected 9\n", type
);
5627 node2
= test_node_get_parent((IUnknown
*)node
);
5628 IHTMLDOMNode_Release(node
);
5629 ok(node2
== NULL
, "node != NULL\n");
5632 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5633 ok(elem2
!= NULL
, "elem2 == NULL\n");
5634 test_node_name((IUnknown
*)elem2
, "BODY");
5635 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
5636 IHTMLElement_Release(elem2
);
5637 ok(elem3
!= NULL
, "elem3 == NULL\n");
5638 test_node_name((IUnknown
*)elem3
, "HTML");
5639 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
5640 IHTMLElement_Release(elem3
);
5641 ok(elem2
== NULL
, "elem2 != NULL\n");
5643 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
5644 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
5645 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
5647 test_elem_innertext(elem
, "opt1opt2");
5649 IHTMLElement_Release(elem
);
5652 elem
= get_elem_by_id(doc
, "s", TRUE
);
5654 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
5655 IHTMLDocument2
*doc_node
, *elem_doc
;
5657 test_select_elem(select
);
5659 test_elem_title((IUnknown
*)select
, NULL
);
5660 test_elem_set_title((IUnknown
*)select
, "Title");
5661 test_elem_title((IUnknown
*)select
, "Title");
5662 test_elem_offset((IUnknown
*)select
);
5664 node
= get_first_child((IUnknown
*)select
);
5665 ok(node
!= NULL
, "node == NULL\n");
5667 test_elem_type((IUnknown
*)node
, ET_OPTION
);
5668 IHTMLDOMNode_Release(node
);
5671 type
= get_node_type((IUnknown
*)select
);
5672 ok(type
== 1, "type=%d\n", type
);
5674 IHTMLSelectElement_Release(select
);
5676 elem_doc
= get_elem_doc((IUnknown
*)elem
);
5678 doc_node
= get_doc_node(doc
);
5679 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
5680 IHTMLDocument2_Release(doc_node
);
5681 IHTMLDocument2_Release(elem_doc
);
5683 IHTMLElement_Release(elem
);
5686 elem
= get_elem_by_id(doc
, "sc", TRUE
);
5688 IHTMLScriptElement
*script
;
5691 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
5692 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
5698 hres
= IHTMLScriptElement_put_type (script
, NULL
);
5699 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5700 hres
= IHTMLScriptElement_get_type(script
, &type
);
5701 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5702 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
5704 hres
= IHTMLScriptElement_put_type (script
, a2bstr ("text/javascript"));
5705 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
5706 hres
= IHTMLScriptElement_get_type(script
, &type
);
5707 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5708 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
5710 SysFreeString(type
);
5713 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
5714 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5716 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
5717 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
5718 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
5720 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
5721 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5724 IHTMLScriptElement_Release(script
);
5727 elem
= get_elem_by_id(doc
, "in", TRUE
);
5729 IHTMLInputElement
*input
;
5731 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
5732 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
5734 test_elem_id((IUnknown
*)elem
, "in");
5735 test_elem_put_id((IUnknown
*)elem
, "newin");
5736 test_input_get_disabled(input
, VARIANT_FALSE
);
5737 test_input_set_disabled(input
, VARIANT_TRUE
);
5738 test_input_set_disabled(input
, VARIANT_FALSE
);
5739 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
5740 test_input_get_disabled(input
, VARIANT_TRUE
);
5741 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
5742 test_input_get_disabled(input
, VARIANT_FALSE
);
5743 test_elem_client_size((IUnknown
*)elem
);
5744 test_input_type(input
, "text");
5746 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5747 test_node_put_value_str((IUnknown
*)elem
, "test");
5748 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5749 test_input_value((IUnknown
*)elem
, NULL
);
5750 test_input_put_value((IUnknown
*)elem
, "test");
5751 test_input_value((IUnknown
*)elem
, NULL
);
5752 test_elem_class((IUnknown
*)elem
, "testclass");
5753 test_elem_tabindex((IUnknown
*)elem
, 2);
5754 test_elem_set_tabindex((IUnknown
*)elem
, 3);
5755 test_elem_title((IUnknown
*)elem
, "test title");
5757 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
5758 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
5759 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
5761 test_input_get_checked(input
, VARIANT_FALSE
);
5762 test_input_set_checked(input
, VARIANT_TRUE
);
5763 test_input_set_checked(input
, VARIANT_FALSE
);
5765 test_input_name(input
, NULL
);
5766 test_input_set_name(input
, "test");
5768 test_input_src(input
, NULL
);
5769 test_input_set_src(input
, "about:blank");
5771 IHTMLInputElement_Release(input
);
5772 IHTMLElement_Release(elem
);
5775 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5777 test_img_src((IUnknown
*)elem
, "");
5778 test_img_set_src((IUnknown
*)elem
, "about:blank");
5779 test_img_alt((IUnknown
*)elem
, NULL
);
5780 test_img_set_alt((IUnknown
*)elem
, "alt test");
5781 test_img_name((IUnknown
*)elem
, "WineImg");
5782 IHTMLElement_Release(elem
);
5785 elem
= get_doc_elem_by_id(doc
, "tbl");
5786 ok(elem
!= NULL
, "elem == NULL\n");
5788 test_table_elem(elem
);
5789 IHTMLElement_Release(elem
);
5792 elem
= get_doc_elem_by_id(doc
, "row2");
5793 ok(elem
!= NULL
, "elem == NULL\n");
5796 IHTMLElement_Release(elem
);
5799 elem
= get_doc_elem_by_id(doc
, "ifr");
5800 ok(elem
!= NULL
, "elem == NULL\n");
5802 test_iframe_elem(elem
);
5803 IHTMLElement_Release(elem
);
5806 elem
= get_elem_by_id(doc
, "a", TRUE
);
5808 test_anchor_href((IUnknown
*)elem
, "http://test/");
5809 IHTMLElement_Release(elem
);
5812 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5813 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5815 node
= get_first_child((IUnknown
*)elem
);
5816 ok(node
!= NULL
, "node == NULL\n");
5818 test_ifaces((IUnknown
*)node
, text_iids
);
5819 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5821 node2
= get_first_child((IUnknown
*)node
);
5822 ok(!node2
, "node2 != NULL\n");
5824 type
= get_node_type((IUnknown
*)node
);
5825 ok(type
== 3, "type=%d\n", type
);
5827 test_node_get_value_str((IUnknown
*)node
, "text test");
5828 test_node_put_value_str((IUnknown
*)elem
, "test text");
5829 test_node_get_value_str((IUnknown
*)node
, "text test");
5831 IHTMLDOMNode_Release(node
);
5834 child_col
= get_child_nodes((IUnknown
*)elem
);
5835 ok(child_col
!= NULL
, "child_coll == NULL\n");
5839 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
5841 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
5842 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5843 ok(length
, "length=0\n");
5846 node
= get_child_item(child_col
, 0);
5847 ok(node
!= NULL
, "node == NULL\n");
5849 type
= get_node_type((IUnknown
*)node
);
5850 ok(type
== 3, "type=%d\n", type
);
5851 node2
= node_get_next((IUnknown
*)node
);
5852 IHTMLDOMNode_Release(node
);
5855 node
= get_child_item(child_col
, 1);
5856 ok(node
!= NULL
, "node == NULL\n");
5858 type
= get_node_type((IUnknown
*)node
);
5859 ok(type
== 8, "type=%d\n", type
);
5861 test_elem_id((IUnknown
*)node
, NULL
);
5862 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
5863 IHTMLDOMNode_Release(node2
);
5864 IHTMLDOMNode_Release(node
);
5867 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
5868 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5870 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
5871 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5873 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
5874 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5876 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
5877 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5879 test_child_col_disp(child_col
);
5881 IHTMLDOMChildrenCollection_Release(child_col
);
5884 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5885 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
5886 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5888 IHTMLElement_Release(elem
);
5890 elem
= get_doc_elem_by_id(doc
, "frm");
5891 ok(elem
!= NULL
, "elem == NULL\n");
5893 test_form_length((IUnknown
*)elem
, 0);
5894 IHTMLElement_Release(elem
);
5897 test_stylesheets(doc
);
5898 test_create_option_elem(doc
);
5899 test_create_img_elem(doc
);
5901 elem
= get_doc_elem_by_id(doc
, "tbl");
5902 ok(elem
!= NULL
, "elem = NULL\n");
5903 test_elem_set_innertext(elem
, "inner text");
5904 IHTMLElement_Release(elem
);
5906 test_doc_title(doc
, "test");
5907 test_doc_set_title(doc
, "test title");
5908 test_doc_title(doc
, "test title");
5911 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5912 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5915 IDispatchEx
*dispex
;
5916 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
5917 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
5921 BSTR str
= a2bstr("Testing");
5922 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
5923 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5924 ok(pid
!= -1, "pid == -1\n");
5926 IDispatchEx_Release(dispex
);
5929 IDispatch_Release(disp
);
5931 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5932 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5934 str
= a2bstr("img");
5935 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
5936 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
5940 static const elem_type_t img_types
[] = { ET_IMG
};
5942 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
5943 IHTMLElementCollection_Release(col
);
5946 elem
= get_doc_elem_by_id(doc
, "y");
5947 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
5948 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
5949 test_elem_set_innerhtml((IUnknown
*)elem
, "");
5950 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
5951 node
= node_get_next((IUnknown
*)elem
);
5952 ok(!node
, "node = %p\n", node
);
5954 elem2
= get_doc_elem_by_id(doc
, "x");
5955 test_elem_tag((IUnknown
*)elem2
, "A");
5956 node
= node_get_next((IUnknown
*)elem2
);
5957 IHTMLDOMNode_Release(node
);
5958 IHTMLElement_Release(elem2
);
5959 IHTMLElement_Release(elem
);
5961 IHTMLDocument3_Release(doc3
);
5963 elem
= get_elem_by_id(doc
, "s", TRUE
);
5965 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
5967 test_select_put_length((IUnknown
*)elem
, 3);
5968 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
5969 test_select_put_length((IUnknown
*)elem
, 1);
5970 test_elem_all((IUnknown
*)elem
, select_types
, 1);
5971 IHTMLElement_Release(elem
);
5974 window
= get_doc_window(doc
);
5975 test_window_name(window
, NULL
);
5976 set_window_name(window
, "test name");
5977 test_window_length(window
, 1);
5978 IHTMLWindow2_Release(window
);
5981 static void test_elems2(IHTMLDocument2
*doc
)
5983 IHTMLElement
*elem
, *elem2
;
5985 static const elem_type_t outer_types
[] = {
5990 elem
= get_doc_elem_by_id(doc
, "divid");
5992 test_elem_set_innerhtml((IUnknown
*)elem
, "<div id=\"innerid\"></div>");
5993 elem2
= get_doc_elem_by_id(doc
, "innerid");
5994 ok(elem2
!= NULL
, "elem2 == NULL\n");
5995 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5996 test_elem_all((IUnknown
*)elem
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
5997 IHTMLElement_Release(elem2
);
5999 elem2
= get_doc_elem_by_id(doc
, "aid");
6000 ok(elem2
!= NULL
, "elem2 == NULL\n");
6001 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
6002 test_elem_all((IUnknown
*)elem
, outer_types
, 1);
6003 IHTMLElement_Release(elem2
);
6005 IHTMLElement_Release(elem
);
6008 static void test_create_elems(IHTMLDocument2
*doc
)
6010 IHTMLElement
*elem
, *body
, *elem2
;
6011 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
6012 IHTMLDocument5
*doc5
;
6019 static const elem_type_t types1
[] = { ET_TESTG
};
6021 elem
= test_create_elem(doc
, "TEST");
6022 test_elem_tag((IUnknown
*)elem
, "TEST");
6023 type
= get_node_type((IUnknown
*)elem
);
6024 ok(type
== 1, "type=%d\n", type
);
6025 test_ifaces((IUnknown
*)elem
, elem_iids
);
6026 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
6028 hres
= IHTMLDocument2_get_body(doc
, &body
);
6029 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
6030 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6032 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
6033 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
6034 elem2
= get_elem_iface((IUnknown
*)node
);
6035 IHTMLElement_Release(elem2
);
6037 hres
= IHTMLElement_get_all(body
, &disp
);
6038 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6039 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
6040 IDispatch_Release(disp
);
6042 test_node_remove_child((IUnknown
*)body
, node
);
6044 hres
= IHTMLElement_get_all(body
, &disp
);
6045 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6046 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
6047 IDispatch_Release(disp
);
6048 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
6050 IHTMLElement_Release(elem
);
6051 IHTMLDOMNode_Release(node
);
6053 node
= test_create_text(doc
, "test");
6054 test_ifaces((IUnknown
*)node
, text_iids
);
6055 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
6056 test_text_length((IUnknown
*)node
, 4);
6058 V_VT(&var
) = VT_NULL
;
6059 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6060 IHTMLDOMNode_Release(node
);
6062 node
= test_create_text(doc
, "insert ");
6064 V_VT(&var
) = VT_DISPATCH
;
6065 V_DISPATCH(&var
) = (IDispatch
*)node2
;
6066 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
6067 IHTMLDOMNode_Release(node
);
6068 IHTMLDOMNode_Release(node2
);
6069 IHTMLDOMNode_Release(node3
);
6071 test_elem_innertext(body
, "insert test");
6072 test_elem_innerhtml((IUnknown
*)body
, "insert test");
6074 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
6077 str
= a2bstr("testing");
6078 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
6080 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
6083 type
= get_node_type((IUnknown
*)comment
);
6084 ok(type
== 8, "type=%d, expected 8\n", type
);
6086 test_node_get_value_str((IUnknown
*)comment
, "testing");
6087 test_elem_title((IUnknown
*)comment
, NULL
);
6088 test_elem_set_title((IUnknown
*)comment
, "comment title");
6089 test_elem_title((IUnknown
*)comment
, "comment title");
6090 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
6091 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
6093 IHTMLDOMNode_Release(comment
);
6096 IHTMLDocument5_Release(doc5
);
6099 IHTMLElement_Release(body
);
6102 static void test_null_write(IHTMLDocument2
*doc
)
6106 doc_write(doc
, FALSE
, NULL
);
6107 doc_write(doc
, TRUE
, NULL
);
6109 hres
= IHTMLDocument2_write(doc
, NULL
);
6111 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
6113 hres
= IHTMLDocument2_writeln(doc
, NULL
);
6115 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
6118 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
6120 IOleCommandTarget
*cmdtrg
;
6123 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
6124 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
6126 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
6127 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
6129 IOleCommandTarget_Release(cmdtrg
);
6132 static void test_indent(IHTMLDocument2
*doc
)
6134 IHTMLElementCollection
*col
;
6135 IHTMLTxtRange
*range
;
6138 static const elem_type_t all_types
[] = {
6147 static const elem_type_t indent_types
[] = {
6158 hres
= IHTMLDocument2_get_all(doc
, &col
);
6159 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6160 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6161 IHTMLElementCollection_Release(col
);
6163 range
= test_create_body_range(doc
);
6164 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
6165 IHTMLTxtRange_Release(range
);
6167 hres
= IHTMLDocument2_get_all(doc
, &col
);
6168 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6169 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
6170 IHTMLElementCollection_Release(col
);
6173 static void test_cond_comment(IHTMLDocument2
*doc
)
6175 IHTMLElementCollection
*col
;
6178 static const elem_type_t all_types
[] = {
6186 hres
= IHTMLDocument2_get_all(doc
, &col
);
6187 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6188 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6189 IHTMLElementCollection_Release(col
);
6192 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6194 IHTMLWindow2
*frame2
, *parent
, *top
;
6195 IHTMLDocument2
*parent_doc
, *top_doc
;
6196 IHTMLWindow4
*frame
;
6197 IHTMLFrameBase
*frame_elem
;
6200 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6201 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6205 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6206 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6207 IHTMLWindow4_Release(frame
);
6211 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6212 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6213 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6214 IHTMLElement_Release(frame_elem
);
6216 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6217 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6221 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6222 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6224 IHTMLWindow2_Release(frame2
);
6228 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6229 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6230 IHTMLWindow2_Release(parent
);
6232 IHTMLWindow2_Release(frame2
);
6236 test_doc_title(parent_doc
, "frameset test");
6237 IHTMLDocument2_Release(parent_doc
);
6240 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6241 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6242 IHTMLWindow2_Release(frame2
);
6246 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6247 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6248 IHTMLWindow2_Release(top
);
6252 test_doc_title(top_doc
, "frameset test");
6253 IHTMLDocument2_Release(top_doc
);
6256 static void test_frameset(IHTMLDocument2
*doc
)
6258 IHTMLWindow2
*window
;
6259 IHTMLFramesCollection2
*frames
;
6261 IHTMLFrameBase
*fbase
;
6263 VARIANT index_var
, result_var
;
6267 window
= get_doc_window(doc
);
6269 /* test using IHTMLFramesCollection object */
6271 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6272 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6273 IHTMLWindow2_Release(window
);
6277 /* test result length */
6278 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6279 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6280 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6282 /* test first frame */
6283 V_VT(&index_var
) = VT_I4
;
6284 V_I4(&index_var
) = 0;
6285 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6286 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6287 if(SUCCEEDED(hres
)) {
6288 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6289 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6291 VariantClear(&result_var
);
6293 /* test second frame */
6294 V_I4(&index_var
) = 1;
6295 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6296 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6297 if(SUCCEEDED(hres
)) {
6298 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6299 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6301 VariantClear(&result_var
);
6303 /* fail on next frame */
6304 V_I4(&index_var
) = 3;
6305 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6306 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6307 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6308 VariantClear(&result_var
);
6310 /* string argument (element id lookup) */
6311 V_VT(&index_var
) = VT_BSTR
;
6312 V_BSTR(&index_var
) = a2bstr("fr1");
6313 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6314 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6315 if(SUCCEEDED(hres
)) {
6316 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6317 test_frame(V_DISPATCH(&result_var
), "fr1");
6319 VariantClear(&result_var
);
6320 VariantClear(&index_var
);
6322 /* invalid argument */
6323 V_VT(&index_var
) = VT_BOOL
;
6324 V_BOOL(&index_var
) = VARIANT_TRUE
;
6325 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6326 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6327 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6328 VariantClear(&result_var
);
6330 IHTMLFramesCollection2_Release(frames
);
6332 /* test using IHTMLWindow2 inheritance */
6334 /* test result length */
6335 hres
= IHTMLWindow2_get_length(window
, &length
);
6336 ok(hres
== S_OK
, "IHTMLWindow2_get_length failed: 0x%08x\n", hres
);
6337 ok(length
== 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length
);
6339 /* test first frame */
6340 V_VT(&index_var
) = VT_I4
;
6341 V_I4(&index_var
) = 0;
6342 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6343 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6344 if(SUCCEEDED(hres
)) {
6345 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6346 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6348 VariantClear(&result_var
);
6350 /* test second frame */
6351 V_I4(&index_var
) = 1;
6352 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6353 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6354 if(SUCCEEDED(hres
)) {
6355 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6356 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6358 VariantClear(&result_var
);
6360 /* fail on next frame */
6361 V_I4(&index_var
) = 3;
6362 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6363 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLWindow2_item should have"
6364 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6365 VariantClear(&result_var
);
6367 /* string argument (element id lookup) */
6368 V_VT(&index_var
) = VT_BSTR
;
6369 V_BSTR(&index_var
) = a2bstr("fr2");
6370 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6371 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6372 if(SUCCEEDED(hres
)) {
6373 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6374 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6376 VariantClear(&result_var
);
6377 VariantClear(&index_var
);
6379 /* invalid argument */
6380 V_VT(&index_var
) = VT_BOOL
;
6381 V_BOOL(&index_var
) = VARIANT_TRUE
;
6382 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6383 ok(hres
== E_INVALIDARG
, "IHTMLWindow2_item should have"
6384 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6385 VariantClear(&result_var
);
6387 /* getElementById with node name attributes */
6388 elem
= get_doc_elem_by_id(doc
, "nm1");
6389 test_elem_id((IUnknown
*)elem
, "fr1");
6391 /* get/put scrolling */
6392 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6393 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6395 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6396 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6397 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6401 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6402 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6405 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6406 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6407 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6410 str
= a2bstr("junk");
6411 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6412 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6413 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6416 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6417 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6418 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6422 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6423 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6424 ok(!strcmp_wa(str
, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str
));
6427 IHTMLFrameBase_Release(fbase
);
6428 IHTMLElement_Release(elem
);
6430 /* get_name with no name attr */
6431 elem
= get_doc_elem_by_id(doc
, "fr3");
6432 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6433 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6435 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6436 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6437 ok(str
== NULL
, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str
));
6440 IHTMLFrameBase_Release(fbase
);
6441 IHTMLElement_Release(elem
);
6444 static IHTMLDocument2
*notif_doc
;
6445 static BOOL doc_complete
;
6447 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
6448 REFIID riid
, void**ppv
)
6450 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
6455 ok(0, "unexpected call\n");
6456 return E_NOINTERFACE
;
6459 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
6464 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
6469 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
6471 if(dispID
== DISPID_READYSTATE
){
6475 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
6476 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
6478 if(!strcmp_wa(state
, "complete"))
6479 doc_complete
= TRUE
;
6481 SysFreeString(state
);
6487 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
6489 ok(0, "unexpected call\n");
6493 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
6494 PropertyNotifySink_QueryInterface
,
6495 PropertyNotifySink_AddRef
,
6496 PropertyNotifySink_Release
,
6497 PropertyNotifySink_OnChanged
,
6498 PropertyNotifySink_OnRequestEdit
6501 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
6503 static IHTMLDocument2
*create_doc_with_string(const char *str
)
6505 IPersistStreamInit
*init
;
6507 IHTMLDocument2
*doc
;
6511 notif_doc
= doc
= create_document();
6515 doc_complete
= FALSE
;
6517 mem
= GlobalAlloc(0, len
);
6518 memcpy(mem
, str
, len
);
6519 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
6521 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
6523 IPersistStreamInit_Load(init
, stream
);
6524 IPersistStreamInit_Release(init
);
6525 IStream_Release(stream
);
6530 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
6532 IConnectionPointContainer
*container
;
6533 IConnectionPoint
*cp
;
6537 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
6538 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
6540 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
6541 IConnectionPointContainer_Release(container
);
6542 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
6544 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
6545 IConnectionPoint_Release(cp
);
6546 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
6549 typedef void (*domtest_t
)(IHTMLDocument2
*);
6551 static void run_domtest(const char *str
, domtest_t test
)
6553 IHTMLDocument2
*doc
;
6557 doc
= create_doc_with_string(str
);
6561 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
6563 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
6564 TranslateMessage(&msg
);
6565 DispatchMessage(&msg
);
6570 ref
= IHTMLDocument2_Release(doc
);
6572 ref
== 1, /* Vista */
6580 run_domtest(doc_str1
, test_doc_elem
);
6581 run_domtest(doc_str1
, test_get_set_attr
);
6582 run_domtest(range_test_str
, test_txtrange
);
6583 run_domtest(range_test2_str
, test_txtrange2
);
6584 if (winetest_interactive
|| ! is_ie_hardened()) {
6585 run_domtest(elem_test_str
, test_elems
);
6587 skip("IE running in Enhanced Security Configuration\n");
6589 run_domtest(elem_test2_str
, test_elems2
);
6590 run_domtest(doc_blank
, test_create_elems
);
6591 run_domtest(doc_blank
, test_defaults
);
6592 run_domtest(doc_blank
, test_null_write
);
6593 run_domtest(indent_test_str
, test_indent
);
6594 run_domtest(cond_comment_str
, test_cond_comment
);
6595 run_domtest(frameset_str
, test_frameset
);