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_disp(__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_text_iface(u) _get_text_iface(__LINE__,u)
677 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
679 IHTMLDOMTextNode
*text
;
682 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
683 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
687 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
688 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
690 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
694 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
695 IHTMLDOMNode_Release(node
);
696 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
697 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
702 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
703 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
705 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
706 IDispatch
*disp
= (void*)0xdeadbeef;
707 IHTMLDocument2
*doc
= NULL
;
710 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
711 IHTMLDOMNode2_Release(node
);
712 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
715 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
716 IDispatch_Release(disp
);
717 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
723 #define get_doc_window(d) _get_doc_window(__LINE__,d)
724 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
726 IHTMLWindow2
*window
;
730 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
731 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
732 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
737 #define clone_node(n,d) _clone_node(__LINE__,n,d)
738 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
740 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
741 IHTMLDOMNode
*ret
= NULL
;
744 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
745 IHTMLDOMNode_Release(node
);
746 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
747 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
753 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
754 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
756 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
760 hres
= IHTMLElement_get_tagName(elem
, &tag
);
761 IHTMLElement_Release(elem
);
762 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
763 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
768 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
769 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
771 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
772 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
774 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
775 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
778 #define get_node_type(n) _get_node_type(__LINE__,n)
779 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
781 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
785 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
786 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
788 IHTMLDOMNode_Release(node
);
793 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
794 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
796 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
797 IHTMLDOMChildrenCollection
*col
= NULL
;
801 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
802 IHTMLDOMNode_Release(node
);
803 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
807 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
808 IDispatch_Release(disp
);
809 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
814 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
815 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
817 IHTMLDOMNode
*node
= NULL
;
821 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
822 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
824 node
= _get_node_iface(line
, (IUnknown
*)disp
);
825 IDispatch_Release(disp
);
830 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
831 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
840 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
842 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
845 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
846 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
848 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
851 VariantClear(&value
);
854 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
855 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
857 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
861 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
862 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
864 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
865 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
867 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
868 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
870 IHTMLElement_Release(elem
);
873 #define get_doc_node(d) _get_doc_node(__LINE__,d)
874 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
876 IHTMLWindow2
*window
;
880 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
881 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
883 hres
= IHTMLWindow2_get_document(window
, &ret
);
884 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
885 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
890 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
891 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
896 hres
= IHTMLWindow2_get_name(window
, &name
);
897 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
899 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
901 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
904 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
905 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
911 hres
= IHTMLWindow2_put_name(window
, str
);
913 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
915 _test_window_name(line
, window
, name
);
918 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
919 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
924 hres
= IHTMLWindow2_get_length(window
, &length
);
925 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
926 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
929 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
930 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
932 IHTMLFrameBase2
*base2
;
933 IHTMLWindow2
*window
;
936 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
937 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
940 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
941 IHTMLFrameBase2_Release(base2
);
942 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
943 ok(window
!= NULL
, "contentWindow = NULL\n");
948 static void test_get_set_attr(IHTMLDocument2
*doc
)
951 IHTMLDocument3
*doc3
;
956 /* grab an element to test with */
957 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
958 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
960 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
961 IHTMLDocument3_Release(doc3
);
962 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
964 /* get a non-present attribute */
965 bstr
= a2bstr("notAnAttribute");
966 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
967 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
968 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
972 /* get a present attribute */
973 bstr
= a2bstr("scrollHeight");
974 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
975 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
976 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
980 /* create a new BSTR attribute */
981 bstr
= a2bstr("newAttribute");
983 V_VT(&val
) = VT_BSTR
;
984 V_BSTR(&val
) = a2bstr("the value");
985 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
986 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
989 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
990 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
991 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
992 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
)));
995 /* overwrite the attribute with a BOOL */
996 V_VT(&val
) = VT_BOOL
;
997 V_BOOL(&val
) = VARIANT_TRUE
;
998 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
999 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1002 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1003 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1004 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1005 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1008 SysFreeString(bstr
);
1010 /* case-insensitive */
1011 bstr
= a2bstr("newattribute");
1012 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1013 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1014 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1015 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1017 SysFreeString(bstr
);
1019 IHTMLElement_Release(elem
);
1022 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1023 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1026 IHTMLDocument3
*doc3
;
1029 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1030 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1031 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1032 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1033 IHTMLDocument3_Release(doc3
);
1038 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1039 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1041 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1045 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1046 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1047 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1050 _test_disp_value(line
, unk
, exhref
);
1053 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1054 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1059 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1060 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1061 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1062 SysFreeString(bstr
);
1065 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1066 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1071 bstr
= a2bstr(text
);
1072 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1073 SysFreeString(bstr
);
1074 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1076 _test_option_text(line
, option
, text
);
1079 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1080 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1085 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1086 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1087 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1088 SysFreeString(bstr
);
1091 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1092 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1097 bstr
= a2bstr(value
);
1098 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1099 SysFreeString(bstr
);
1100 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1102 _test_option_value(line
, option
, value
);
1105 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1106 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1107 const char *txt
, const char *val
)
1109 IHTMLOptionElementFactory
*factory
;
1110 IHTMLOptionElement
*option
;
1111 IHTMLWindow2
*window
;
1112 VARIANT text
, value
, empty
;
1115 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1116 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1118 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1119 IHTMLWindow2_Release(window
);
1120 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1122 V_VT(&text
) = VT_BSTR
;
1123 V_BSTR(&text
) = a2bstr(txt
);
1124 V_VT(&value
) = VT_BSTR
;
1125 V_BSTR(&value
) = a2bstr(val
);
1126 V_VT(&empty
) = VT_EMPTY
;
1128 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1129 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1131 IHTMLOptionElementFactory_Release(factory
);
1132 VariantClear(&text
);
1133 VariantClear(&value
);
1135 _test_option_text(line
, option
, txt
);
1136 _test_option_value(line
, option
, val
);
1141 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1142 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1147 hres
= IHTMLImgElement_get_width(img
, &found
);
1148 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1149 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1152 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1153 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const long width
)
1157 hres
= IHTMLImgElement_put_width(img
, width
);
1158 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1160 _test_img_width(line
, img
, width
);
1163 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1164 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1169 hres
= IHTMLImgElement_get_height(img
, &found
);
1170 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1171 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1174 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1175 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const long height
)
1179 hres
= IHTMLImgElement_put_height(img
, height
);
1180 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1182 _test_img_height(line
, img
, height
);
1185 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1186 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1187 LONG wdth
, LONG hght
)
1189 IHTMLImageElementFactory
*factory
;
1190 IHTMLImgElement
*img
;
1191 IHTMLWindow2
*window
;
1192 VARIANT width
, height
;
1196 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1197 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1199 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1200 IHTMLWindow2_Release(window
);
1201 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1203 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1204 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1207 snprintf(buf
, 16, "%d", wdth
);
1208 V_VT(&width
) = VT_BSTR
;
1209 V_BSTR(&width
) = a2bstr(buf
);
1211 V_VT(&width
) = VT_EMPTY
;
1216 snprintf(buf
, 16, "%d", hght
);
1217 V_VT(&height
) = VT_BSTR
;
1218 V_BSTR(&height
) = a2bstr(buf
);
1220 V_VT(&height
) = VT_EMPTY
;
1224 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1225 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1227 IHTMLImageElementFactory_Release(factory
);
1228 VariantClear(&width
);
1229 VariantClear(&height
);
1231 if(SUCCEEDED(hres
)) {
1232 _test_img_width(line
, img
, wdth
);
1233 _test_img_height(line
, img
, hght
);
1240 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1241 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1243 LONG len
= 0xdeadbeef;
1246 hres
= IHTMLSelectElement_get_length(select
, &len
);
1247 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1248 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1251 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1252 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1254 LONG idx
= 0xdeadbeef;
1257 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1258 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1259 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1262 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1263 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1267 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1268 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1269 _test_select_selidx(line
, select
, index
);
1272 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1273 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1278 hres
= IHTMLSelectElement_get_value(select
, &val
);
1279 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1281 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1283 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1286 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1287 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1293 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1294 SysFreeString(bstr
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1298 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1299 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1304 hres
= IHTMLSelectElement_get_type(select
, &type
);
1305 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1306 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1309 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1310 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1315 hres
= IHTMLTxtRange_get_text(range
, &text
);
1316 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1319 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1320 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1322 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1325 SysFreeString(text
);
1329 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1330 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1334 hres
= IHTMLTxtRange_collapse(range
, b
);
1335 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1336 _test_range_text(line
, range
, NULL
);
1339 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1340 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1341 VARIANT_BOOL exb
, const char *extext
)
1343 VARIANT_BOOL b
= 0xe0e0;
1346 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1347 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1348 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1349 _test_range_text(line
, range
, extext
);
1352 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1353 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1355 LONG c
= 0xdeadbeef;
1358 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1359 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1360 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1361 _test_range_text(line
, range
, NULL
);
1364 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1365 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1366 LPWSTR unit
, LONG cnt
, LONG excnt
)
1368 LONG c
= 0xdeadbeef;
1371 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1372 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1373 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1376 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1377 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1379 LONG c
= 0xdeadbeef;
1382 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1383 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1384 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1387 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1388 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1391 BSTR bstr
= a2bstr(text
);
1393 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1394 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1395 SysFreeString(bstr
);
1396 _test_range_text(line
, range
, NULL
);
1399 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1400 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1406 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1407 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1408 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1411 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1412 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1418 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1419 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1420 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1423 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1424 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1425 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1428 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1429 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1433 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1434 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1439 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1440 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1442 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1444 IHTMLElement_Release(elem
);
1447 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1448 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1449 const elem_type_t
*elem_types
, LONG exlen
)
1451 IHTMLElementCollection
*col
;
1454 VARIANT name
, index
;
1455 IDispatch
*disp
, *disp2
;
1458 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1459 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1461 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1463 hres
= IHTMLElementCollection_get_length(col
, &len
);
1464 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1465 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1470 V_VT(&index
) = VT_EMPTY
;
1472 for(i
=0; i
<len
; i
++) {
1473 V_VT(&name
) = VT_I4
;
1475 disp
= (void*)0xdeadbeef;
1476 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1477 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1478 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1479 if(FAILED(hres
) || !disp
)
1482 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1485 V_VT(&name
) = VT_UINT
;
1487 disp2
= (void*)0xdeadbeef;
1488 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1489 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1490 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1492 IDispatch_Release(disp2
);
1495 IDispatch_Release(disp
);
1498 V_VT(&name
) = VT_I4
;
1500 disp
= (void*)0xdeadbeef;
1501 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1502 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1503 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1505 V_VT(&name
) = VT_I4
;
1507 disp
= (void*)0xdeadbeef;
1508 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1509 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1510 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1512 IHTMLElementCollection_Release(col
);
1515 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1516 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1518 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1522 hres
= IHTMLElement_get_all(elem
, &disp
);
1523 IHTMLElement_Release(elem
);
1524 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1526 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1527 IDispatch_Release(disp
);
1530 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1531 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1533 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1534 IHTMLElementCollection
*col
= NULL
;
1535 elem_type_t
*types
= NULL
;
1540 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1541 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1543 IHTMLElement2_Release(elem
);
1544 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1545 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1548 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1549 for(i
=0; i
<exlen
; i
++)
1553 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1555 HeapFree(GetProcessHeap(), 0, types
);
1558 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1559 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1564 hres
= IHTMLElement_get_innerText(elem
, &text
);
1565 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1566 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1567 wine_dbgstr_w(text
), extext
);
1568 SysFreeString(text
);
1571 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1572 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1574 IHTMLDOMChildrenCollection
*col
;
1579 hres
= IHTMLElement_put_innerText(elem
, str
);
1580 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1583 _test_elem_innertext(line
, elem
, text
);
1586 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1587 ok(col
!= NULL
, "col == NULL\n");
1589 LONG length
= 0, type
;
1592 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1593 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1594 ok(length
== 1, "length = %d\n", length
);
1596 node
= _get_child_item(line
, col
, 0);
1597 ok(node
!= NULL
, "node == NULL\n");
1599 type
= _get_node_type(line
, (IUnknown
*)node
);
1600 ok(type
== 3, "type=%d\n", type
);
1601 IHTMLDOMNode_Release(node
);
1604 IHTMLDOMChildrenCollection_Release(col
);
1609 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1610 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1612 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1616 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
1617 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
1619 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
1621 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
1623 IHTMLElement_Release(elem
);
1624 SysFreeString(html
);
1627 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1628 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1630 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1634 html
= a2bstr(inner_html
);
1635 hres
= IHTMLElement_put_innerHTML(elem
, html
);
1636 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
1638 IHTMLElement_Release(elem
);
1639 SysFreeString(html
);
1642 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1643 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1645 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1649 html
= a2bstr(outer_html
);
1650 hres
= IHTMLElement_put_outerHTML(elem
, html
);
1651 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
1653 IHTMLElement_Release(elem
);
1654 SysFreeString(html
);
1657 #define get_first_child(n) _get_first_child(__LINE__,n)
1658 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1660 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1661 IHTMLDOMNode
*child
= NULL
;
1664 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1665 IHTMLDOMNode_Release(node
);
1666 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1671 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1672 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1674 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1675 VARIANT_BOOL b
= 0xdead;
1678 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1679 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1680 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1682 IHTMLDOMNode_Release(node
);
1685 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1686 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1688 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1689 IHTMLDOMNode
*parent
;
1692 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1693 IHTMLDOMNode_Release(node
);
1694 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1699 #define node_get_next(u) _node_get_next(__LINE__,u)
1700 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
1702 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1706 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
1707 IHTMLDOMNode_Release(node
);
1708 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
1713 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1714 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1716 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1717 IHTMLElement
*parent
;
1720 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1721 IHTMLElement_Release(elem
);
1722 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1727 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1728 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1730 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1731 VARIANT_BOOL disabled
= 100;
1735 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1736 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1737 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1738 IHTMLElement3_Release(elem3
);
1741 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1742 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1744 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1748 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1749 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1751 IHTMLElement3_Release(elem3
);
1752 _test_elem3_get_disabled(line
, unk
, b
);
1755 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1756 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1758 VARIANT_BOOL disabled
= 100;
1761 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1762 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1763 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1765 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1768 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1769 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
1771 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
1775 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
1776 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1777 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
1778 IHTMLDOMTextNode_Release(text
);
1781 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1782 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1786 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1787 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1789 _test_select_get_disabled(line
, select
, b
);
1792 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1793 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1795 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1796 IHTMLTextContainer
*txtcont
;
1797 LONG l
= -1, l2
= -1;
1800 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1801 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1802 IHTMLElement2_Release(elem
);
1804 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1805 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1807 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1808 IHTMLTextContainer_Release(txtcont
);
1809 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
1810 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
1815 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1816 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1818 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1819 IHTMLTextContainer
*txtcont
;
1820 LONG l
= -1, l2
= -1;
1823 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1824 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1825 IHTMLElement2_Release(elem
);
1827 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1828 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1830 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1831 IHTMLTextContainer_Release(txtcont
);
1832 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
1833 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
1838 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1839 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1841 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1842 IHTMLTextContainer
*txtcont
;
1843 LONG l
= -1, l2
= -1;
1846 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1847 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1848 IHTMLElement2_Release(elem
);
1850 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1851 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1853 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1854 IHTMLTextContainer_Release(txtcont
);
1855 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
1856 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
1861 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1862 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
1864 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1865 IHTMLTextContainer
*txtcont
;
1866 LONG l
= -1, l2
= -1;
1869 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
1870 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
1872 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
1873 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1874 IHTMLElement2_Release(elem
);
1876 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1877 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1879 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
1880 IHTMLTextContainer_Release(txtcont
);
1881 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
1882 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
1885 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1886 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
1888 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1892 hres
= IHTMLImgElement_get_src(img
, &src
);
1893 IHTMLImgElement_Release(img
);
1894 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
1895 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
1899 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1900 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
1902 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1907 hres
= IHTMLImgElement_put_src(img
, tmp
);
1908 IHTMLImgElement_Release(img
);
1910 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
1912 _test_img_src(line
, unk
, src
);
1915 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1916 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
1918 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1922 hres
= IHTMLImgElement_get_alt(img
, &alt
);
1923 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1925 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
1927 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
1931 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1932 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
1934 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1939 hres
= IHTMLImgElement_put_alt(img
, tmp
);
1940 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1943 _test_img_alt(line
, unk
, alt
);
1946 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
1947 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
1949 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1953 hres
= IHTMLImgElement_get_name(img
, &sName
);
1954 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
1955 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
1956 SysFreeString(sName
);
1960 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1961 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1963 VARIANT_BOOL disabled
= 100;
1966 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
1967 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1968 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1970 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
1973 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1974 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1978 hres
= IHTMLInputElement_put_disabled(input
, b
);
1979 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1981 _test_input_get_disabled(line
, input
, b
);
1984 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1985 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1987 VARIANT_BOOL checked
= 100;
1990 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
1991 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
1992 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
1995 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1996 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2000 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2001 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2003 _test_input_get_defaultchecked(line
, input
, b
);
2006 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2007 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2009 VARIANT_BOOL checked
= 100;
2012 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2013 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2014 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2017 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2018 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2022 hres
= IHTMLInputElement_put_checked(input
, b
);
2023 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2025 _test_input_get_checked(line
, input
, b
);
2028 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2029 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2031 IHTMLInputElement
*input
;
2035 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2036 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2040 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2041 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2043 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2045 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
2046 SysFreeString(bstr
);
2047 IHTMLInputElement_Release(input
);
2050 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2051 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2053 IHTMLInputElement
*input
;
2057 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2058 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2063 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2064 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2065 SysFreeString(bstr
);
2066 IHTMLInputElement_Release(input
);
2069 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2070 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2075 hres
= IHTMLInputElement_get_src(input
, &src
);
2076 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2078 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2080 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2084 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2085 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2091 hres
= IHTMLInputElement_put_src(input
, tmp
);
2093 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2095 _test_input_src(line
, input
, src
);
2098 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2099 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2101 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2102 BSTR
class = (void*)0xdeadbeef;
2105 hres
= IHTMLElement_get_className(elem
, &class);
2106 IHTMLElement_Release(elem
);
2107 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2109 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2111 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2112 SysFreeString(class);
2115 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2116 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2118 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2122 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2123 IHTMLElement2_Release(elem2
);
2124 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2125 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2128 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2129 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2131 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2134 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2135 IHTMLElement2_Release(elem2
);
2136 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2138 _test_elem_tabindex(line
, unk
, index
);
2141 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2142 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2144 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2146 IHTMLFiltersCollection
*filters
;
2148 hres
= IHTMLElement_get_filters(elem
, &filters
);
2149 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2150 "get_filters failed: %08x\n", hres
);
2154 IDispatchEx
*dispex
;
2156 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2157 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2158 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2160 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2161 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2162 "Could not get IDispatchEx interface: %08x\n", hres
);
2163 if(SUCCEEDED(hres
)) {
2164 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2165 IDispatchEx_Release(dispex
);
2168 IHTMLFiltersCollection_Release(filters
);
2171 IHTMLElement_Release(elem
);
2174 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2175 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2177 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2181 tmp
= class ? a2bstr(class) : NULL
;
2182 hres
= IHTMLElement_put_className(elem
, tmp
);
2183 IHTMLElement_Release(elem
);
2184 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
2187 _test_elem_class(line
, unk
, class);
2190 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2191 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
2193 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2194 BSTR id
= (void*)0xdeadbeef;
2197 hres
= IHTMLElement_get_id(elem
, &id
);
2198 IHTMLElement_Release(elem
);
2199 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
2202 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
2204 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
2209 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2210 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
2212 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2213 BSTR tmp
= a2bstr(new_id
);
2216 hres
= IHTMLElement_put_id(elem
, tmp
);
2217 IHTMLElement_Release(elem
);
2219 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
2221 _test_elem_id(line
, unk
, new_id
);
2224 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2225 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
2227 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2231 hres
= IHTMLElement_get_title(elem
, &title
);
2232 IHTMLElement_Release(elem
);
2233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2235 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2237 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
2239 SysFreeString(title
);
2242 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2243 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
2245 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2249 tmp
= a2bstr(title
);
2250 hres
= IHTMLElement_put_title(elem
, tmp
);
2251 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2253 IHTMLElement_Release(elem
);
2257 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2258 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
2260 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2264 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
2265 IHTMLDOMNode_Release(node
);
2266 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2269 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
2270 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2272 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
2278 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2279 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
2281 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2285 V_VT(&var
) = VT_BSTR
;
2286 V_BSTR(&var
) = a2bstr(val
);
2288 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
2289 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2290 IHTMLDOMNode_Release(node
);
2294 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2295 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
2297 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2301 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
2302 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
2303 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
2304 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
2306 IHTMLElement2_Release(elem
);
2309 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2310 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
2312 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2316 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
2317 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
2318 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
2320 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
2321 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
2322 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
2324 IHTMLElement2_Release(elem
);
2327 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2328 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
2330 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2331 IHTMLDocument2
*doc
;
2336 hres
= IHTMLElement_get_document(elem
, &disp
);
2337 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2338 ok(disp
!= NULL
, "disp == NULL\n");
2340 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
2341 IDispatch_Release(disp
);
2342 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
2347 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2348 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
2350 IHTMLDocument2
*doc
;
2354 hres
= IHTMLWindow2_get_document(window
, &doc
);
2355 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2356 ok(doc
!= NULL
, "disp == NULL\n");
2361 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2362 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
2364 IHTMLElement
*elem
= NULL
;
2369 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
2370 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2371 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
2376 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2377 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
2379 IHTMLDocument3
*doc3
;
2380 IHTMLDOMNode
*node
= NULL
;
2384 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2385 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
2388 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
2389 IHTMLDocument3_Release(doc3
);
2390 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2391 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
2396 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2397 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
2399 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2400 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
2401 IHTMLDOMNode
*new_child
= NULL
;
2404 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
2405 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
2406 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2407 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2409 IHTMLDOMNode_Release(node
);
2410 IHTMLDOMNode_Release(child
);
2415 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2416 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
2418 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2419 IHTMLDOMNode
*new_child
= NULL
;
2422 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
2423 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
2424 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2425 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2427 IHTMLDOMNode_Release(node
);
2432 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2433 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
2435 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2436 IHTMLDOMNode
*new_node
= NULL
;
2439 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
2440 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
2441 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
2442 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2444 IHTMLDOMNode_Release(node
);
2445 IHTMLDOMNode_Release(new_node
);
2448 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2449 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
2454 hres
= IHTMLDocument2_get_title(doc
, &title
);
2455 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2456 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2457 SysFreeString(title
);
2460 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2461 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
2466 tmp
= a2bstr(title
);
2467 hres
= IHTMLDocument2_put_title(doc
, tmp
);
2468 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2472 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2473 static void _test_border_styles(unsigned line
, IHTMLStyle
*pStyle
, BSTR Name
)
2478 hres
= IHTMLStyle_GetIDsOfNames(pStyle
, &IID_NULL
, &Name
, 1,
2479 LOCALE_USER_DEFAULT
, &dispid
);
2480 ok_(__FILE__
,line
) (hres
== S_OK
, "GetIDsOfNames: %08x\n", hres
);
2483 DISPPARAMS params
= {NULL
,NULL
,0,0};
2484 DISPID dispidNamed
= DISPID_PROPERTYPUT
;
2489 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2490 DISPATCH_PROPERTYGET
, ¶ms
, &vDefault
, NULL
, NULL
);
2491 ok_(__FILE__
,line
) (hres
== S_OK
, "get_default. ret: %08x\n", hres
);
2494 params
.cNamedArgs
= 1;
2495 params
.rgdispidNamedArgs
= &dispidNamed
;
2496 V_VT(&arg
) = VT_BSTR
;
2497 V_BSTR(&arg
) = a2bstr("none");
2498 params
.rgvarg
= &arg
;
2499 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2500 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2501 ok_(__FILE__
,line
) (hres
== S_OK
, "none. ret: %08x\n", hres
);
2504 V_VT(&arg
) = VT_BSTR
;
2505 V_BSTR(&arg
) = a2bstr("dotted");
2506 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2507 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2508 ok_(__FILE__
,line
) (hres
== S_OK
, "dotted. ret: %08x\n", hres
);
2511 V_VT(&arg
) = VT_BSTR
;
2512 V_BSTR(&arg
) = a2bstr("dashed");
2513 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2514 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2515 ok_(__FILE__
,line
) (hres
== S_OK
, "dashed. ret: %08x\n", hres
);
2518 V_VT(&arg
) = VT_BSTR
;
2519 V_BSTR(&arg
) = a2bstr("solid");
2520 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2521 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2522 ok_(__FILE__
,line
) (hres
== S_OK
, "solid. ret: %08x\n", hres
);
2525 V_VT(&arg
) = VT_BSTR
;
2526 V_BSTR(&arg
) = a2bstr("double");
2527 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2528 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2529 ok_(__FILE__
,line
) (hres
== S_OK
, "double. ret: %08x\n", hres
);
2532 V_VT(&arg
) = VT_BSTR
;
2533 V_BSTR(&arg
) = a2bstr("groove");
2534 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2535 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2536 ok_(__FILE__
,line
) (hres
== S_OK
, "groove. ret: %08x\n", hres
);
2539 V_VT(&arg
) = VT_BSTR
;
2540 V_BSTR(&arg
) = a2bstr("ridge");
2541 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2542 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2543 ok_(__FILE__
,line
) (hres
== S_OK
, "ridge. ret: %08x\n", hres
);
2546 V_VT(&arg
) = VT_BSTR
;
2547 V_BSTR(&arg
) = a2bstr("inset");
2548 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2549 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2550 ok_(__FILE__
,line
) (hres
== S_OK
, "inset. ret: %08x\n", hres
);
2553 V_VT(&arg
) = VT_BSTR
;
2554 V_BSTR(&arg
) = a2bstr("outset");
2555 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2556 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2557 ok_(__FILE__
,line
) (hres
== S_OK
, "outset. ret: %08x\n", hres
);
2560 V_VT(&arg
) = VT_BSTR
;
2561 V_BSTR(&arg
) = a2bstr("invalid");
2562 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2563 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2564 ok_(__FILE__
,line
) (FAILED(hres
), "invalid value passed.\n");
2567 params
.rgvarg
= &vDefault
;
2568 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2569 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2570 ok_(__FILE__
,line
) (hres
== S_OK
, "default. ret: %08x\n", hres
);
2574 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2575 static void _test_style_csstext(unsigned line
, IHTMLStyle
*style
, const char *extext
)
2577 BSTR text
= (void*)0xdeadbeef;
2580 hres
= IHTMLStyle_get_cssText(style
, &text
);
2581 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
2583 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "cssText = %s\n", wine_dbgstr_w(text
));
2585 ok_(__FILE__
,line
)(!text
, "cssText = %s\n", wine_dbgstr_w(text
));
2587 SysFreeString(text
);
2590 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2591 static void _test_style_set_csstext(unsigned line
, IHTMLStyle
*style
, const char *text
)
2597 hres
= IHTMLStyle_put_cssText(style
, tmp
);
2598 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
2602 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
2603 const elem_type_t
*elem_types
, LONG len
)
2606 VARIANT name
, index
;
2610 V_VT(&index
) = VT_EMPTY
;
2611 V_VT(&name
) = VT_BSTR
;
2612 V_BSTR(&name
) = a2bstr(n
);
2614 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2615 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2617 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
2618 IDispatch_Release(disp
);
2619 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
2623 V_VT(&index
) = VT_I4
;
2625 for(i
=0; i
<len
; i
++) {
2627 disp
= (void*)0xdeadbeef;
2628 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2629 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2630 ok(disp
!= NULL
, "disp == NULL\n");
2631 if(FAILED(hres
) || !disp
)
2634 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
2636 IDispatch_Release(disp
);
2640 disp
= (void*)0xdeadbeef;
2641 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2642 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2643 ok(disp
== NULL
, "disp != NULL\n");
2646 disp
= (void*)0xdeadbeef;
2647 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2648 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2649 ok(disp
== NULL
, "disp != NULL\n");
2652 SysFreeString(V_BSTR(&name
));
2655 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
2657 IHTMLElementCollection
*col
;
2659 IDispatch
*disp
= (void*)0xdeadbeef;
2660 VARIANT name
, index
;
2663 hres
= IHTMLDocument2_get_all(doc
, &col
);
2664 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2665 ok(col
!= NULL
, "col == NULL\n");
2666 if(FAILED(hres
) || !col
)
2669 V_VT(&index
) = VT_EMPTY
;
2670 V_VT(&name
) = VT_BSTR
;
2671 V_BSTR(&name
) = a2bstr(id
);
2673 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2674 IHTMLElementCollection_Release(col
);
2675 SysFreeString(V_BSTR(&name
));
2676 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2677 if(!expect_success
) {
2678 ok(disp
== NULL
, "disp != NULL\n");
2682 ok(disp
!= NULL
, "disp == NULL\n");
2686 elem
= get_elem_iface((IUnknown
*)disp
);
2687 IDispatch_Release(disp
);
2692 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
2694 IHTMLDocument3
*doc3
;
2699 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2700 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
2703 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
2705 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
2707 IHTMLDocument3_Release(doc3
);
2712 static void test_select_elem(IHTMLSelectElement
*select
)
2714 test_select_type(select
, "select-one");
2715 test_select_length(select
, 2);
2716 test_select_selidx(select
, 0);
2717 test_select_put_selidx(select
, 1);
2719 test_select_set_value(select
, "val1");
2720 test_select_value(select
, "val1");
2722 test_select_get_disabled(select
, VARIANT_FALSE
);
2723 test_select_set_disabled(select
, VARIANT_TRUE
);
2724 test_select_set_disabled(select
, VARIANT_FALSE
);
2727 static void test_create_option_elem(IHTMLDocument2
*doc
)
2729 IHTMLOptionElement
*option
;
2731 option
= create_option_elem(doc
, "test text", "test value");
2733 test_option_put_text(option
, "new text");
2734 test_option_put_value(option
, "new value");
2736 IHTMLOptionElement_Release(option
);
2739 static void test_create_img_elem(IHTMLDocument2
*doc
)
2741 IHTMLImgElement
*img
;
2743 img
= create_img_elem(doc
, 10, 15);
2746 test_img_put_width(img
, 5);
2747 test_img_put_height(img
, 20);
2749 IHTMLImgElement_Release(img
);
2753 img
= create_img_elem(doc
, -1, -1);
2756 test_img_put_width(img
, 5);
2757 test_img_put_height(img
, 20);
2759 IHTMLImgElement_Release(img
);
2763 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
2765 IHTMLBodyElement
*body
;
2766 IHTMLTxtRange
*range
;
2770 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2771 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2773 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
2774 IHTMLElement_Release(elem
);
2776 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
2777 IHTMLBodyElement_Release(body
);
2778 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
2783 static void test_txtrange(IHTMLDocument2
*doc
)
2785 IHTMLTxtRange
*body_range
, *range
, *range2
;
2786 IHTMLSelectionObject
*selection
;
2787 IDispatch
*disp_range
;
2790 body_range
= test_create_body_range(doc
);
2792 test_range_text(body_range
, "test abc 123\r\nit's text");
2794 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2795 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2797 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
2798 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2799 test_range_isequal(range
, range2
, VARIANT_TRUE
);
2801 test_range_text(range
, "test abc 123\r\nit's text");
2802 test_range_text(body_range
, "test abc 123\r\nit's text");
2804 test_range_collapse(range
, TRUE
);
2805 test_range_isequal(range
, range2
, VARIANT_FALSE
);
2806 test_range_inrange(range
, range2
, VARIANT_FALSE
);
2807 test_range_inrange(range2
, range
, VARIANT_TRUE
);
2808 IHTMLTxtRange_Release(range2
);
2810 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2811 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
2812 test_range_move(range
, characterW
, 2, 2);
2813 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2815 test_range_collapse(range
, FALSE
);
2816 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
2818 test_range_collapse(range
, FALSE
);
2819 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2820 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
2821 test_range_move(range
, characterW
, 2, 2);
2822 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2823 test_range_moveend(range
, characterW
, -5, -5);
2824 test_range_text(range
, NULL
);
2825 test_range_moveend(range
, characterW
, 3, 3);
2826 test_range_text(range
, "c 1");
2827 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
2828 test_range_collapse(range
, TRUE
);
2829 test_range_move(range
, characterW
, 4, 4);
2830 test_range_moveend(range
, characterW
, 1, 1);
2831 test_range_text(range
, " ");
2832 test_range_move(range
, wordW
, 1, 1);
2833 test_range_moveend(range
, characterW
, 2, 2);
2834 test_range_text(range
, "ab");
2836 IHTMLTxtRange_Release(range
);
2838 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2839 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2841 test_range_text(range
, "test abc 123\r\nit's text");
2842 test_range_move(range
, characterW
, 3, 3);
2843 test_range_moveend(range
, characterW
, 1, 1);
2844 test_range_text(range
, "t");
2845 test_range_moveend(range
, characterW
, 3, 3);
2846 test_range_text(range
, "t ab");
2847 test_range_moveend(range
, characterW
, -2, -2);
2848 test_range_text(range
, "t ");
2849 test_range_move(range
, characterW
, 6, 6);
2850 test_range_moveend(range
, characterW
, 3, 3);
2851 test_range_text(range
, "123");
2852 test_range_moveend(range
, characterW
, 2, 2);
2853 test_range_text(range
, "123\r\ni");
2855 IHTMLTxtRange_Release(range
);
2857 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2858 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2860 test_range_move(range
, wordW
, 1, 1);
2861 test_range_moveend(range
, characterW
, 2, 2);
2862 test_range_text(range
, "ab");
2864 test_range_move(range
, characterW
, -2, -2);
2865 test_range_moveend(range
, characterW
, 2, 2);
2866 test_range_text(range
, "t ");
2868 test_range_move(range
, wordW
, 3, 3);
2869 test_range_move(range
, wordW
, -2, -2);
2870 test_range_moveend(range
, characterW
, 2, 2);
2871 test_range_text(range
, "ab");
2873 test_range_move(range
, characterW
, -6, -5);
2874 test_range_moveend(range
, characterW
, -1, 0);
2875 test_range_moveend(range
, characterW
, -6, 0);
2876 test_range_move(range
, characterW
, 2, 2);
2877 test_range_moveend(range
, characterW
, 2, 2);
2878 test_range_text(range
, "st");
2879 test_range_moveend(range
, characterW
, -6, -4);
2880 test_range_moveend(range
, characterW
, 2, 2);
2882 IHTMLTxtRange_Release(range
);
2884 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2885 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2887 test_range_move(range
, wordW
, 2, 2);
2888 test_range_moveend(range
, characterW
, 2, 2);
2889 test_range_text(range
, "12");
2891 test_range_move(range
, characterW
, 15, 14);
2892 test_range_move(range
, characterW
, -2, -2);
2893 test_range_moveend(range
, characterW
, 3, 2);
2894 test_range_text(range
, "t");
2895 test_range_moveend(range
, characterW
, -1, -1);
2896 test_range_text(range
, "t");
2897 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
2898 test_range_move(range
, characterW
, -2, -2);
2899 test_range_moveend(range
, characterW
, 2, 2);
2900 test_range_text(range
, "s ");
2901 test_range_move(range
, characterW
, 100, 7);
2902 test_range_move(range
, wordW
, 1, 0);
2903 test_range_move(range
, characterW
, -2, -2);
2904 test_range_moveend(range
, characterW
, 3, 2);
2905 test_range_text(range
, "t");
2907 IHTMLTxtRange_Release(range
);
2909 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2910 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2912 test_range_collapse(range
, TRUE
);
2913 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2914 test_range_put_text(range
, "word");
2915 test_range_text(body_range
, "wordabc 123\r\nit's text");
2916 test_range_text(range
, NULL
);
2917 test_range_moveend(range
, characterW
, 3, 3);
2918 test_range_text(range
, "abc");
2919 test_range_movestart(range
, characterW
, -2, -2);
2920 test_range_text(range
, "rdabc");
2921 test_range_movestart(range
, characterW
, 3, 3);
2922 test_range_text(range
, "bc");
2923 test_range_movestart(range
, characterW
, 4, 4);
2924 test_range_text(range
, NULL
);
2925 test_range_movestart(range
, characterW
, -3, -3);
2926 test_range_text(range
, "c 1");
2927 test_range_movestart(range
, characterW
, -7, -6);
2928 test_range_text(range
, "wordabc 1");
2929 test_range_movestart(range
, characterW
, 100, 22);
2930 test_range_text(range
, NULL
);
2932 IHTMLTxtRange_Release(range
);
2933 IHTMLTxtRange_Release(body_range
);
2935 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2936 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
2938 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
2939 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
2940 IHTMLSelectionObject_Release(selection
);
2942 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
2943 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
2944 IDispatch_Release(disp_range
);
2946 test_range_text(range
, NULL
);
2947 test_range_moveend(range
, characterW
, 3, 3);
2948 test_range_text(range
, "wor");
2949 test_range_parent(range
, ET_BODY
);
2950 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2951 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2952 test_range_move(range
, characterW
, 3, 3);
2953 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
2954 test_range_moveend(range
, characterW
, -4, -4);
2955 test_range_put_text(range
, "abc def ");
2956 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
2957 test_range_move(range
, wordW
, 1, 1);
2958 test_range_movestart(range
, characterW
, -1, -1);
2959 test_range_text(range
, " ");
2960 test_range_move(range
, wordW
, 1, 1);
2961 test_range_moveend(range
, characterW
, 3, 3);
2962 test_range_text(range
, "def");
2963 test_range_put_text(range
, "xyz");
2964 test_range_moveend(range
, characterW
, 1, 1);
2965 test_range_move(range
, wordW
, 1, 1);
2966 test_range_moveend(range
, characterW
, 2, 2);
2967 test_range_text(range
, "ab");
2969 IHTMLTxtRange_Release(range
);
2972 static void test_txtrange2(IHTMLDocument2
*doc
)
2974 IHTMLTxtRange
*range
;
2976 range
= test_create_body_range(doc
);
2978 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2979 test_range_move(range
, characterW
, 5, 5);
2980 test_range_moveend(range
, characterW
, 1, 1);
2981 test_range_text(range
, "2");
2982 test_range_move(range
, characterW
, -3, -3);
2983 test_range_moveend(range
, characterW
, 3, 3);
2984 test_range_text(range
, "c\r\n\r\n1");
2985 test_range_collapse(range
, VARIANT_FALSE
);
2986 test_range_moveend(range
, characterW
, 4, 4);
2987 test_range_text(range
, "23");
2988 test_range_moveend(range
, characterW
, 1, 1);
2989 test_range_text(range
, "23\r\n\r\n\r\nd");
2990 test_range_moveend(range
, characterW
, -1, -1);
2991 test_range_text(range
, "23");
2992 test_range_moveend(range
, characterW
, -1, -1);
2993 test_range_text(range
, "23");
2994 test_range_moveend(range
, characterW
, -2, -2);
2995 test_range_text(range
, "2");
2997 IHTMLTxtRange_Release(range
);
3000 static void test_compatmode(IHTMLDocument2
*doc
)
3002 IHTMLDocument5
*doc5
;
3006 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3007 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
3011 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
3012 IHTMLDocument5_Release(doc5
);
3013 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
3014 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
3015 SysFreeString(mode
);
3018 static void test_location(IHTMLDocument2
*doc
)
3020 IHTMLLocation
*location
, *location2
;
3021 IHTMLWindow2
*window
;
3026 hres
= IHTMLDocument2_get_location(doc
, &location
);
3027 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3029 hres
= IHTMLDocument2_get_location(doc
, &location2
);
3030 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3032 ok(location
== location2
, "location != location2\n");
3033 IHTMLLocation_Release(location2
);
3035 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3036 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3038 hres
= IHTMLWindow2_get_location(window
, &location2
);
3039 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3040 ok(location
== location2
, "location != location2\n");
3041 IHTMLLocation_Release(location2
);
3043 test_ifaces((IUnknown
*)location
, location_iids
);
3044 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
3046 hres
= IHTMLLocation_get_pathname(location
, &str
);
3047 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
3048 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
3050 hres
= IHTMLLocation_get_href(location
, NULL
);
3051 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
3053 hres
= IHTMLLocation_get_href(location
, &str
);
3054 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
3055 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
3057 ref
= IHTMLLocation_Release(location
);
3058 ok(!ref
, "location chould be destroyed here\n");
3061 static void test_navigator(IHTMLDocument2
*doc
)
3063 IHTMLWindow2
*window
;
3064 IOmNavigator
*navigator
, *navigator2
;
3071 static const WCHAR v40
[] = {'4','.','0'};
3073 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3074 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
3076 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
3077 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3078 ok(navigator
!= NULL
, "navigator == NULL\n");
3079 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
3081 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
3082 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3083 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
3085 IHTMLWindow2_Release(window
);
3086 IOmNavigator_Release(navigator2
);
3088 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
3089 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
3090 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3091 SysFreeString(bstr
);
3094 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
3095 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
3096 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3097 SysFreeString(bstr
);
3100 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
3101 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
3103 ok(!strcmp_wa(bstr
, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3105 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3107 SysFreeString(bstr
);
3110 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3111 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3112 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
3113 SysFreeString(bstr
);
3115 hres
= IOmNavigator_toString(navigator
, NULL
);
3116 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
3119 hres
= IOmNavigator_toString(navigator
, &bstr
);
3120 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
3121 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
3122 SysFreeString(bstr
);
3125 hres
= ObtainUserAgentString(0, buf
, &size
);
3126 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
3129 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
3130 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
3131 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
3132 SysFreeString(bstr
);
3134 ref
= IOmNavigator_Release(navigator
);
3135 ok(!ref
, "navigator should be destroyed here\n");
3138 static void test_screen(IHTMLWindow2
*window
)
3140 IHTMLScreen
*screen
, *screen2
;
3141 IDispatchEx
*dispex
;
3146 static const WCHAR displayW
[] = {'D','I','S','P','L','A','Y',0};
3149 hres
= IHTMLWindow2_get_screen(window
, &screen
);
3150 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3151 ok(screen
!= NULL
, "screen == NULL\n");
3154 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
3155 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3156 ok(screen2
!= NULL
, "screen == NULL\n");
3157 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
3158 IHTMLScreen_Release(screen2
);
3160 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
3161 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
3162 if(SUCCEEDED(hres
)) {
3163 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
3164 IDispatchEx_Release(dispex
);
3167 hdc
= CreateICW(displayW
, NULL
, NULL
, NULL
);
3169 exl
= GetDeviceCaps(hdc
, HORZRES
);
3171 hres
= IHTMLScreen_get_width(screen
, &l
);
3172 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3173 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
3175 exl
= GetDeviceCaps(hdc
, VERTRES
);
3177 hres
= IHTMLScreen_get_height(screen
, &l
);
3178 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3179 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3181 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
3183 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
3184 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3185 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3189 IHTMLScreen_Release(screen
);
3192 static void test_current_style(IHTMLCurrentStyle
*current_style
)
3198 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
, "[object]");
3199 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
3201 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
3202 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3203 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", wine_dbgstr_w(str
));
3206 hres
= IHTMLCurrentStyle_get_position(current_style
, &str
);
3207 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3208 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3211 hres
= IHTMLCurrentStyle_get_fontFamily(current_style
, &str
);
3212 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3215 hres
= IHTMLCurrentStyle_get_fontStyle(current_style
, &str
);
3216 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
3217 ok(!strcmp_wa(str
, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str
));
3220 hres
= IHTMLCurrentStyle_get_backgroundImage(current_style
, &str
);
3221 ok(hres
== S_OK
, "get_backgroundImage failed: %08x\n", hres
);
3222 ok(!strcmp_wa(str
, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str
));
3225 hres
= IHTMLCurrentStyle_get_fontVariant(current_style
, &str
);
3226 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3227 ok(!strcmp_wa(str
, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str
));
3230 hres
= IHTMLCurrentStyle_get_borderTopStyle(current_style
, &str
);
3231 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
3232 ok(!strcmp_wa(str
, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str
));
3235 hres
= IHTMLCurrentStyle_get_borderRightStyle(current_style
, &str
);
3236 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
3237 ok(!strcmp_wa(str
, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str
));
3240 hres
= IHTMLCurrentStyle_get_borderBottomStyle(current_style
, &str
);
3241 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
3242 ok(!strcmp_wa(str
, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str
));
3245 hres
= IHTMLCurrentStyle_get_borderLeftStyle(current_style
, &str
);
3246 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
3247 ok(!strcmp_wa(str
, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str
));
3250 hres
= IHTMLCurrentStyle_get_textAlign(current_style
, &str
);
3251 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
3252 ok(!strcmp_wa(str
, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str
));
3255 hres
= IHTMLCurrentStyle_get_textDecoration(current_style
, &str
);
3256 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3257 ok(!strcmp_wa(str
, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str
));
3260 hres
= IHTMLCurrentStyle_get_cursor(current_style
, &str
);
3261 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
3262 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
3265 hres
= IHTMLCurrentStyle_get_backgroundRepeat(current_style
, &str
);
3266 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
3267 ok(!strcmp_wa(str
, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str
));
3270 hres
= IHTMLCurrentStyle_get_borderColor(current_style
, &str
);
3271 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
3274 hres
= IHTMLCurrentStyle_get_borderStyle(current_style
, &str
);
3275 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
3278 hres
= IHTMLCurrentStyle_get_visibility(current_style
, &str
);
3279 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3282 hres
= IHTMLCurrentStyle_get_overflow(current_style
, &str
);
3283 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
3286 hres
= IHTMLCurrentStyle_get_borderWidth(current_style
, &str
);
3287 ok(hres
== S_OK
, "get_borderWidth failed: %08x\n", hres
);
3290 hres
= IHTMLCurrentStyle_get_margin(current_style
, &str
);
3291 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3294 hres
= IHTMLCurrentStyle_get_fontWeight(current_style
, &v
);
3295 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3296 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3297 ok( V_I4(&v
) == 400, "expect 400 got (%d)\n", V_I4(&v
));
3300 hres
= IHTMLCurrentStyle_get_fontSize(current_style
, &v
);
3301 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3302 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3305 hres
= IHTMLCurrentStyle_get_left(current_style
, &v
);
3306 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3307 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3310 hres
= IHTMLCurrentStyle_get_top(current_style
, &v
);
3311 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3312 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3315 hres
= IHTMLCurrentStyle_get_width(current_style
, &v
);
3316 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3317 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3320 hres
= IHTMLCurrentStyle_get_height(current_style
, &v
);
3321 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3322 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3325 hres
= IHTMLCurrentStyle_get_paddingLeft(current_style
, &v
);
3326 ok(hres
== S_OK
, "get_paddingLeft failed: %08x\n", hres
);
3327 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3330 hres
= IHTMLCurrentStyle_get_zIndex(current_style
, &v
);
3331 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
3332 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3333 ok( V_I4(&v
) == 1, "expect 1 got (%d)\n", V_I4(&v
));
3336 hres
= IHTMLCurrentStyle_get_verticalAlign(current_style
, &v
);
3337 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
3338 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3339 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3342 hres
= IHTMLCurrentStyle_get_marginRight(current_style
, &v
);
3343 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3344 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3347 hres
= IHTMLCurrentStyle_get_marginLeft(current_style
, &v
);
3348 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3349 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3352 hres
= IHTMLCurrentStyle_get_borderLeftWidth(current_style
, &v
);
3353 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
3354 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3358 hres
= IHTMLCurrentStyle_get_borderRightWidth(current_style
, &v
);
3359 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
3360 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3363 hres
= IHTMLCurrentStyle_get_borderBottomWidth(current_style
, &v
);
3364 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
3365 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3368 hres
= IHTMLCurrentStyle_get_borderTopWidth(current_style
, &v
);
3369 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
3370 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3373 hres
= IHTMLCurrentStyle_get_color(current_style
, &v
);
3374 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3375 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3378 hres
= IHTMLCurrentStyle_get_backgroundColor(current_style
, &v
);
3379 ok(hres
== S_OK
, "get_backgroundColor failed: %08x\n", hres
);
3380 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3383 hres
= IHTMLCurrentStyle_get_borderLeftColor(current_style
, &v
);
3384 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
3385 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3388 hres
= IHTMLCurrentStyle_get_borderTopColor(current_style
, &v
);
3389 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
3390 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3393 hres
= IHTMLCurrentStyle_get_borderRightColor(current_style
, &v
);
3394 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
3395 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3398 hres
= IHTMLCurrentStyle_get_borderBottomColor(current_style
, &v
);
3399 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
3400 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3403 hres
= IHTMLCurrentStyle_get_paddingTop(current_style
, &v
);
3404 ok(hres
== S_OK
, "get_paddingTop failed: %08x\n", hres
);
3405 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3408 hres
= IHTMLCurrentStyle_get_paddingRight(current_style
, &v
);
3409 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3410 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3413 hres
= IHTMLCurrentStyle_get_paddingBottom(current_style
, &v
);
3414 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3415 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3418 hres
= IHTMLCurrentStyle_get_letterSpacing(current_style
, &v
);
3419 ok(hres
== S_OK
, "get_letterSpacing failed: %08x\n", hres
);
3420 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3423 hres
= IHTMLCurrentStyle_get_marginTop(current_style
, &v
);
3424 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3425 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3428 hres
= IHTMLCurrentStyle_get_marginBottom(current_style
, &v
);
3429 ok(hres
== S_OK
, "get_marginBottom failed: %08x\n", hres
);
3430 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3433 hres
= IHTMLCurrentStyle_get_right(current_style
, &v
);
3434 ok(hres
== S_OK
, "get_Right failed: %08x\n", hres
);
3435 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3438 hres
= IHTMLCurrentStyle_get_bottom(current_style
, &v
);
3439 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3440 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3443 hres
= IHTMLCurrentStyle_get_lineHeight(current_style
, &v
);
3444 ok(hres
== S_OK
, "get_lineHeight failed: %08x\n", hres
);
3445 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3448 hres
= IHTMLCurrentStyle_get_textIndent(current_style
, &v
);
3449 ok(hres
== S_OK
, "get_textIndent failed: %08x\n", hres
);
3450 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3454 static void test_style2(IHTMLStyle2
*style2
)
3460 str
= (void*)0xdeadbeef;
3461 hres
= IHTMLStyle2_get_position(style2
, &str
);
3462 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3463 ok(!str
, "str != NULL\n");
3465 str
= a2bstr("absolute");
3466 hres
= IHTMLStyle2_put_position(style2
, str
);
3467 ok(hres
== S_OK
, "put_position failed: %08x\n", hres
);
3471 hres
= IHTMLStyle2_get_position(style2
, &str
);
3472 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3473 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3477 V_VT(&v
) = VT_EMPTY
;
3478 hres
= IHTMLStyle2_get_right(style2
, &v
);
3479 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3480 ok(V_VT(&v
) == VT_BSTR
, "V_VT(right)=%d\n", V_VT(&v
));
3481 ok(!V_BSTR(&v
), "V_BSTR(right) != NULL\n");
3485 V_BSTR(&v
) = a2bstr("3px");
3486 hres
= IHTMLStyle2_put_right(style2
, v
);
3487 ok(hres
== S_OK
, "put_right failed: %08x\n", hres
);
3490 V_VT(&v
) = VT_EMPTY
;
3491 hres
= IHTMLStyle2_get_right(style2
, &v
);
3492 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3493 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3494 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3498 static void test_style3(IHTMLStyle3
*style3
)
3503 str
= (void*)0xdeadbeef;
3504 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3505 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3506 ok(!str
, "str != NULL\n");
3508 str
= a2bstr("break-word");
3509 hres
= IHTMLStyle3_put_wordWrap(style3
, str
);
3510 ok(hres
== S_OK
, "put_wordWrap failed: %08x\n", hres
);
3514 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3515 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3516 ok(!strcmp_wa(str
, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str
));
3520 static void test_style4(IHTMLStyle4
*style4
)
3526 hres
= IHTMLStyle4_get_minHeight(style4
, &vdefault
);
3527 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3530 V_BSTR(&v
) = a2bstr("10px");
3531 hres
= IHTMLStyle4_put_minHeight(style4
, v
);
3532 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3535 hres
= IHTMLStyle4_get_minHeight(style4
, &v
);
3536 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3537 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3538 ok( !strcmp_wa(V_BSTR(&v
), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
3540 hres
= IHTMLStyle4_put_minHeight(style4
, vdefault
);
3541 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3542 VariantClear(&vdefault
);
3545 static void test_default_style(IHTMLStyle
*style
)
3547 IHTMLStyle2
*style2
;
3548 IHTMLStyle3
*style3
;
3549 IHTMLStyle4
*style4
;
3555 BSTR sOverflowDefault
;
3559 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
3560 test_ifaces((IUnknown
*)style
, style_iids
);
3562 test_style_csstext(style
, NULL
);
3564 hres
= IHTMLStyle_get_position(style
, &str
);
3565 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3566 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
3569 hres
= IHTMLStyle_get_marginRight(style
, &v
);
3570 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3571 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginRight) = %d\n", V_VT(&v
));
3572 ok(!V_BSTR(&v
), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3575 hres
= IHTMLStyle_get_marginLeft(style
, &v
);
3576 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3577 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginLeft) = %d\n", V_VT(&v
));
3578 ok(!V_BSTR(&v
), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3580 str
= (void*)0xdeadbeef;
3581 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
3582 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3583 ok(!str
, "fontFamily = %s\n", wine_dbgstr_w(str
));
3585 str
= (void*)0xdeadbeef;
3586 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3587 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3588 ok(!str
, "fontWeight = %s\n", wine_dbgstr_w(str
));
3590 hres
= IHTMLStyle_get_fontWeight(style
, &sDefault
);
3591 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3593 str
= a2bstr("test");
3594 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3595 ok(hres
== E_INVALIDARG
, "put_fontWeight failed: %08x\n", hres
);
3598 str
= a2bstr("bold");
3599 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3600 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3603 str
= a2bstr("bolder");
3604 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3605 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3608 str
= a2bstr("lighter");
3609 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3610 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3613 str
= a2bstr("100");
3614 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3615 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3618 str
= a2bstr("200");
3619 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3620 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3623 str
= a2bstr("300");
3624 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3625 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3628 str
= a2bstr("400");
3629 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3630 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3633 str
= a2bstr("500");
3634 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3635 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3638 str
= a2bstr("600");
3639 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3640 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3643 str
= a2bstr("700");
3644 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3645 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3648 str
= a2bstr("800");
3649 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3650 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3653 str
= a2bstr("900");
3654 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3655 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3658 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3659 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3660 ok(!strcmp_wa(str
, "900"), "str != style900\n");
3663 hres
= IHTMLStyle_put_fontWeight(style
, sDefault
);
3664 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3665 SysFreeString(sDefault
);
3668 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
3669 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
3671 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
3672 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3674 str
= a2bstr("test");
3675 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3676 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
3679 str
= a2bstr("small-caps");
3680 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3681 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3684 str
= a2bstr("normal");
3685 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3686 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3689 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
3690 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3691 SysFreeString(sDefault
);
3693 str
= (void*)0xdeadbeef;
3694 hres
= IHTMLStyle_get_display(style
, &str
);
3695 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3696 ok(!str
, "display = %s\n", wine_dbgstr_w(str
));
3698 str
= (void*)0xdeadbeef;
3699 hres
= IHTMLStyle_get_visibility(style
, &str
);
3700 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3701 ok(!str
, "visibility = %s\n", wine_dbgstr_w(str
));
3704 hres
= IHTMLStyle_get_fontSize(style
, &v
);
3705 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3706 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
3707 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3710 hres
= IHTMLStyle_get_color(style
, &v
);
3711 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3712 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
3713 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3716 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3717 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3718 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3720 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_TRUE
);
3721 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3722 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3724 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3725 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3726 ok(b
== VARIANT_TRUE
, "textDecorationUnderline = %x\n", b
);
3728 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_FALSE
);
3729 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3732 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3733 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3734 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3736 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_TRUE
);
3737 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3738 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3740 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3741 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3742 ok(b
== VARIANT_TRUE
, "textDecorationLineThrough = %x\n", b
);
3744 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_FALSE
);
3745 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3748 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3749 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3750 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3752 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_TRUE
);
3753 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3754 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3756 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3757 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3758 ok(b
== VARIANT_TRUE
, "textDecorationNone = %x\n", b
);
3760 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_FALSE
);
3761 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3764 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3765 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3766 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3768 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_TRUE
);
3769 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3770 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3772 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3773 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3774 ok(b
== VARIANT_TRUE
, "textDecorationOverline = %x\n", b
);
3776 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_FALSE
);
3777 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3780 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3781 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3782 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3784 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_TRUE
);
3785 ok(hres
== S_OK
, "put_textDecorationBlink failed: %08x\n", hres
);
3786 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3788 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3789 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3790 ok(b
== VARIANT_TRUE
, "textDecorationBlink = %x\n", b
);
3792 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_FALSE
);
3793 ok(hres
== S_OK
, "textDecorationBlink failed: %08x\n", hres
);
3795 hres
= IHTMLStyle_get_textDecoration(style
, &sDefault
);
3796 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3798 str
= a2bstr("invalid");
3799 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3800 ok(hres
== E_INVALIDARG
, "put_textDecoration failed: %08x\n", hres
);
3803 str
= a2bstr("none");
3804 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3805 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3808 str
= a2bstr("underline");
3809 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3810 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3813 str
= a2bstr("overline");
3814 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3815 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3818 str
= a2bstr("line-through");
3819 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3820 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3823 str
= a2bstr("blink");
3824 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3825 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3828 hres
= IHTMLStyle_get_textDecoration(style
, &str
);
3829 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3830 ok(!strcmp_wa(str
, "blink"), "str != blink\n");
3833 hres
= IHTMLStyle_put_textDecoration(style
, sDefault
);
3834 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3835 SysFreeString(sDefault
);
3837 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
3838 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
3840 hres
= IHTMLStyle_get_posWidth(style
, &f
);
3841 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
3842 ok(f
== 0.0f
, "f = %f\n", f
);
3844 V_VT(&v
) = VT_EMPTY
;
3845 hres
= IHTMLStyle_get_width(style
, &v
);
3846 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3847 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3848 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
3850 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
3851 ok(hres
== S_OK
, "put_posWidth failed: %08x\n", hres
);
3853 hres
= IHTMLStyle_get_posWidth(style
, &f
);
3854 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
3856 f
== 2.2f
, /* IE8 */
3860 V_BSTR(&v
) = a2bstr("auto");
3861 hres
= IHTMLStyle_put_width(style
, v
);
3862 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
3865 V_VT(&v
) = VT_EMPTY
;
3866 hres
= IHTMLStyle_get_width(style
, &v
);
3867 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3868 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3869 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
3874 hres
= IHTMLStyle_put_width(style
, v
);
3875 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
3877 V_VT(&v
) = VT_EMPTY
;
3878 hres
= IHTMLStyle_get_width(style
, &v
);
3879 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3880 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3881 ok(!strcmp_wa(V_BSTR(&v
), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
3885 str
= (void*)0xdeadbeef;
3886 hres
= IHTMLStyle_get_margin(style
, &str
);
3887 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3888 ok(!str
, "margin = %s\n", wine_dbgstr_w(str
));
3891 hres
= IHTMLStyle_put_margin(style
, str
);
3892 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
3895 hres
= IHTMLStyle_get_margin(style
, &str
);
3896 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3897 ok(!strcmp_wa(str
, "1px"), "margin = %s\n", wine_dbgstr_w(str
));
3899 hres
= IHTMLStyle_put_margin(style
, NULL
);
3900 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
3902 str
= (void*)0xdeadbeef;
3903 hres
= IHTMLStyle_get_marginTop(style
, &v
);
3904 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3905 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
3906 ok(!V_BSTR(&v
), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3909 V_BSTR(&v
) = a2bstr("6px");
3910 hres
= IHTMLStyle_put_marginTop(style
, v
);
3911 SysFreeString(V_BSTR(&v
));
3912 ok(hres
== S_OK
, "put_marginTop failed: %08x\n", hres
);
3914 str
= (void*)0xdeadbeef;
3915 hres
= IHTMLStyle_get_marginTop(style
, &v
);
3916 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3917 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
3918 ok(!strcmp_wa(V_BSTR(&v
), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3921 hres
= IHTMLStyle_get_border(style
, &str
);
3922 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
3923 ok(!str
|| !*str
, "str is not empty\n");
3926 str
= a2bstr("1px");
3927 hres
= IHTMLStyle_put_border(style
, str
);
3928 ok(hres
== S_OK
, "put_border failed: %08x\n", hres
);
3931 V_VT(&v
) = VT_EMPTY
;
3932 hres
= IHTMLStyle_get_left(style
, &v
);
3933 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3934 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3935 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
3939 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
3940 ok(hres
== E_POINTER
, "get_posLeft failed: %08x\n", hres
);
3943 hres
= IHTMLStyle_get_posLeft(style
, &f
);
3944 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
3945 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
3947 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
3948 ok(hres
== S_OK
, "put_posLeft failed: %08x\n", hres
);
3950 hres
= IHTMLStyle_get_posLeft(style
, &f
);
3951 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
3953 f
== 4.9f
, /* IE8 */
3954 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
3956 /* Ensure left is updated correctly. */
3957 V_VT(&v
) = VT_EMPTY
;
3958 hres
= IHTMLStyle_get_left(style
, &v
);
3959 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3960 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3961 ok(!strcmp_wa(V_BSTR(&v
), "4px") ||
3962 !strcmp_wa(V_BSTR(&v
), "4.9px"), /* IE8 */
3963 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3968 V_BSTR(&v
) = a2bstr("3px");
3969 hres
= IHTMLStyle_put_left(style
, v
);
3970 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
3973 hres
= IHTMLStyle_get_posLeft(style
, &f
);
3974 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
3975 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
3977 V_VT(&v
) = VT_EMPTY
;
3978 hres
= IHTMLStyle_get_left(style
, &v
);
3979 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3980 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3981 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3985 hres
= IHTMLStyle_put_left(style
, v
);
3986 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
3988 V_VT(&v
) = VT_EMPTY
;
3989 hres
= IHTMLStyle_get_left(style
, &v
);
3990 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3991 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3992 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
3995 V_VT(&v
) = VT_EMPTY
;
3996 hres
= IHTMLStyle_get_top(style
, &v
);
3997 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3998 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3999 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4003 hres
= IHTMLStyle_get_posTop(style
, NULL
);
4004 ok(hres
== E_POINTER
, "get_posTop failed: %08x\n", hres
);
4007 hres
= IHTMLStyle_get_posTop(style
, &f
);
4008 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4009 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4011 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
4012 ok(hres
== S_OK
, "put_posTop failed: %08x\n", hres
);
4014 hres
= IHTMLStyle_get_posTop(style
, &f
);
4015 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4017 f
== 4.9f
, /* IE8 */
4018 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4021 V_BSTR(&v
) = a2bstr("3px");
4022 hres
= IHTMLStyle_put_top(style
, v
);
4023 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4026 V_VT(&v
) = VT_EMPTY
;
4027 hres
= IHTMLStyle_get_top(style
, &v
);
4028 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4029 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4030 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4033 hres
= IHTMLStyle_get_posTop(style
, &f
);
4034 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4035 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4038 hres
= IHTMLStyle_put_top(style
, v
);
4039 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4041 V_VT(&v
) = VT_EMPTY
;
4042 hres
= IHTMLStyle_get_top(style
, &v
);
4043 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4044 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4045 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4048 /* Test posHeight */
4049 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
4050 ok(hres
== E_POINTER
, "get_posHeight failed: %08x\n", hres
);
4052 V_VT(&v
) = VT_EMPTY
;
4053 hres
= IHTMLStyle_get_height(style
, &v
);
4054 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4055 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4056 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4060 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4061 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4062 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4064 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
4065 ok(hres
== S_OK
, "put_posHeight failed: %08x\n", hres
);
4067 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4068 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4070 f
== 4.9f
, /* IE8 */
4071 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4074 V_BSTR(&v
) = a2bstr("64px");
4075 hres
= IHTMLStyle_put_height(style
, v
);
4076 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
4079 V_VT(&v
) = VT_EMPTY
;
4080 hres
= IHTMLStyle_get_height(style
, &v
);
4081 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4082 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4083 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4086 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4087 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4088 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
4090 str
= (void*)0xdeadbeef;
4091 hres
= IHTMLStyle_get_cursor(style
, &str
);
4092 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4093 ok(!str
, "get_cursor != NULL\n");
4096 str
= a2bstr("default");
4097 hres
= IHTMLStyle_put_cursor(style
, str
);
4098 ok(hres
== S_OK
, "put_cursor failed: %08x\n", hres
);
4102 hres
= IHTMLStyle_get_cursor(style
, &str
);
4103 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4104 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
4107 V_VT(&v
) = VT_EMPTY
;
4108 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4109 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
4110 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4111 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4115 V_BSTR(&v
) = a2bstr("middle");
4116 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
4117 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
4120 V_VT(&v
) = VT_EMPTY
;
4121 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4122 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4123 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4124 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4127 str
= (void*)0xdeadbeef;
4128 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4129 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4130 ok(!str
, "textAlign != NULL\n");
4132 str
= a2bstr("center");
4133 hres
= IHTMLStyle_put_textAlign(style
, str
);
4134 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
4138 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4139 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4140 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4143 str
= (void*)0xdeadbeef;
4144 hres
= IHTMLStyle_get_filter(style
, &str
);
4145 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
4146 ok(!str
, "filter != NULL\n");
4148 str
= a2bstr("alpha(opacity=100)");
4149 hres
= IHTMLStyle_put_filter(style
, str
);
4150 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
4153 V_VT(&v
) = VT_EMPTY
;
4154 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4155 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4156 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4157 ok(!V_I4(&v
), "V_I4(v) != 0\n");
4161 V_BSTR(&v
) = a2bstr("1");
4162 hres
= IHTMLStyle_put_zIndex(style
, v
);
4163 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
4166 V_VT(&v
) = VT_EMPTY
;
4167 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4168 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4169 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4170 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
4174 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
4175 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
4177 str
= a2bstr("test");
4178 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4179 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
4182 str
= a2bstr("italic");
4183 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4184 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4187 str
= a2bstr("oblique");
4188 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4189 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4192 str
= a2bstr("normal");
4193 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4194 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4197 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
4198 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4199 SysFreeString(sDefault
);
4202 hres
= IHTMLStyle_get_overflow(style
, NULL
);
4203 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
4205 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
4206 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4208 str
= a2bstr("test");
4209 hres
= IHTMLStyle_put_overflow(style
, str
);
4210 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
4213 str
= a2bstr("visible");
4214 hres
= IHTMLStyle_put_overflow(style
, str
);
4215 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4218 str
= a2bstr("scroll");
4219 hres
= IHTMLStyle_put_overflow(style
, str
);
4220 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4223 str
= a2bstr("hidden");
4224 hres
= IHTMLStyle_put_overflow(style
, str
);
4225 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4228 str
= a2bstr("auto");
4229 hres
= IHTMLStyle_put_overflow(style
, str
);
4230 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4233 hres
= IHTMLStyle_get_overflow(style
, &str
);
4234 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4235 ok(!strcmp_wa(str
, "auto"), "str=%s\n", wine_dbgstr_w(str
));
4239 hres
= IHTMLStyle_put_overflow(style
, str
);
4240 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4243 hres
= IHTMLStyle_get_overflow(style
, &str
);
4244 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4245 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4248 /* restore overflow default */
4249 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
4250 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4251 SysFreeString(sOverflowDefault
);
4253 /* Attribute Tests*/
4254 hres
= IHTMLStyle_getAttribute(style
, NULL
, 1, &v
);
4255 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4257 str
= a2bstr("position");
4258 hres
= IHTMLStyle_getAttribute(style
, str
, 1, NULL
);
4259 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4261 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4262 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4263 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4266 hres
= IHTMLStyle_setAttribute(style
, NULL
, v
, 1);
4267 ok(hres
== E_INVALIDARG
, "setAttribute failed: %08x\n", hres
);
4270 V_BSTR(&v
) = a2bstr("absolute");
4271 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4272 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4275 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4276 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4277 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4278 ok(!strcmp_wa(V_BSTR(&v
), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4283 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4284 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4289 str
= a2bstr("borderLeftStyle");
4290 test_border_styles(style
, str
);
4293 str
= a2bstr("borderbottomstyle");
4294 test_border_styles(style
, str
);
4297 str
= a2bstr("borderrightstyle");
4298 test_border_styles(style
, str
);
4301 str
= a2bstr("bordertopstyle");
4302 test_border_styles(style
, str
);
4305 hres
= IHTMLStyle_get_borderStyle(style
, &sDefault
);
4306 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4308 str
= a2bstr("none dotted dashed solid");
4309 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4310 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4313 str
= a2bstr("none dotted dashed solid");
4314 hres
= IHTMLStyle_get_borderStyle(style
, &str
);
4315 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4316 ok(!strcmp_wa(str
, "none dotted dashed solid"),
4317 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4320 str
= a2bstr("double groove ridge inset");
4321 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4322 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4325 str
= a2bstr("window-inset outset ridge inset");
4326 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4327 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4330 str
= a2bstr("window-inset");
4331 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4332 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4335 str
= a2bstr("none none none none none");
4336 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4337 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4340 str
= a2bstr("invalid none none none");
4341 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4342 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4345 str
= a2bstr("none invalid none none");
4346 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4347 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4350 hres
= IHTMLStyle_put_borderStyle(style
, sDefault
);
4351 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4352 SysFreeString(sDefault
);
4354 /* backgoundColor */
4355 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4356 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4357 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4358 ok(!V_BSTR(&v
), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4362 hres
= IHTMLStyle_get_paddingLeft(style
, &vDefault
);
4363 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4366 V_BSTR(&v
) = a2bstr("10");
4367 hres
= IHTMLStyle_put_paddingLeft(style
, v
);
4368 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4371 hres
= IHTMLStyle_get_paddingLeft(style
, &v
);
4372 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4373 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4375 hres
= IHTMLStyle_put_paddingLeft(style
, vDefault
);
4376 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4378 /* BackgroundRepeat */
4379 hres
= IHTMLStyle_get_backgroundRepeat(style
, &sDefault
);
4380 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4382 str
= a2bstr("invalid");
4383 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4384 ok(hres
== E_INVALIDARG
, "put_backgroundRepeat failed: %08x\n", hres
);
4387 str
= a2bstr("repeat");
4388 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4389 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4392 str
= a2bstr("no-repeat");
4393 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4394 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4397 str
= a2bstr("repeat-x");
4398 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4399 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4402 str
= a2bstr("repeat-y");
4403 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4404 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4407 hres
= IHTMLStyle_get_backgroundRepeat(style
, &str
);
4408 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4409 ok(!strcmp_wa(str
, "repeat-y"), "str=%s\n", wine_dbgstr_w(str
));
4412 hres
= IHTMLStyle_put_backgroundRepeat(style
, sDefault
);
4413 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4414 SysFreeString(sDefault
);
4417 hres
= IHTMLStyle_get_borderColor(style
, &sDefault
);
4418 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4420 str
= a2bstr("red green red blue");
4421 hres
= IHTMLStyle_put_borderColor(style
, str
);
4422 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4425 hres
= IHTMLStyle_get_borderColor(style
, &str
);
4426 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4427 ok(!strcmp_wa(str
, "red green red blue"), "str=%s\n", wine_dbgstr_w(str
));
4430 hres
= IHTMLStyle_put_borderColor(style
, sDefault
);
4431 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4432 SysFreeString(sDefault
);
4435 hres
= IHTMLStyle_get_borderRight(style
, &sDefault
);
4436 ok(hres
== S_OK
, "get_borderRight failed: %08x\n", hres
);
4438 str
= a2bstr("thick dotted red");
4439 hres
= IHTMLStyle_put_borderRight(style
, str
);
4440 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4443 /* IHTMLStyle_get_borderRight appears to have a bug where
4444 it returns the first letter of the color. So we check
4445 each style individually.
4448 hres
= IHTMLStyle_get_borderRightColor(style
, &v
);
4449 todo_wine
ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
4450 todo_wine
ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4454 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4455 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
4456 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4459 hres
= IHTMLStyle_get_borderRightStyle(style
, &str
);
4460 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
4461 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4464 hres
= IHTMLStyle_put_borderRight(style
, sDefault
);
4465 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4466 SysFreeString(sDefault
);
4469 hres
= IHTMLStyle_get_borderTop(style
, &sDefault
);
4470 ok(hres
== S_OK
, "get_borderTop failed: %08x\n", hres
);
4472 str
= a2bstr("thick dotted red");
4473 hres
= IHTMLStyle_put_borderTop(style
, str
);
4474 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4477 /* IHTMLStyle_get_borderTop appears to have a bug where
4478 it returns the first letter of the color. So we check
4479 each style individually.
4482 hres
= IHTMLStyle_get_borderTopColor(style
, &v
);
4483 todo_wine
ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
4484 todo_wine
ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4488 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4489 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
4490 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4493 hres
= IHTMLStyle_get_borderTopStyle(style
, &str
);
4494 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
4495 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4498 hres
= IHTMLStyle_put_borderTop(style
, sDefault
);
4499 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4500 SysFreeString(sDefault
);
4503 hres
= IHTMLStyle_get_borderBottom(style
, &sDefault
);
4504 ok(hres
== S_OK
, "get_borderBottom failed: %08x\n", hres
);
4506 str
= a2bstr("thick dotted red");
4507 hres
= IHTMLStyle_put_borderBottom(style
, str
);
4508 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4511 /* IHTMLStyle_get_borderBottom appears to have a bug where
4512 it returns the first letter of the color. So we check
4513 each style individually.
4516 hres
= IHTMLStyle_get_borderBottomColor(style
, &v
);
4517 todo_wine
ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
4518 todo_wine
ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4522 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4523 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
4524 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4527 hres
= IHTMLStyle_get_borderBottomStyle(style
, &str
);
4528 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
4529 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4532 hres
= IHTMLStyle_put_borderBottom(style
, sDefault
);
4533 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4534 SysFreeString(sDefault
);
4537 hres
= IHTMLStyle_get_borderLeft(style
, &sDefault
);
4538 ok(hres
== S_OK
, "get_borderLeft failed: %08x\n", hres
);
4540 str
= a2bstr("thick dotted red");
4541 hres
= IHTMLStyle_put_borderLeft(style
, str
);
4542 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4545 /* IHTMLStyle_get_borderLeft appears to have a bug where
4546 it returns the first letter of the color. So we check
4547 each style individually.
4550 hres
= IHTMLStyle_get_borderLeftColor(style
, &v
);
4551 todo_wine
ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
4552 todo_wine
ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4556 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4557 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
4558 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4561 hres
= IHTMLStyle_get_borderLeftStyle(style
, &str
);
4562 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
4563 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4566 hres
= IHTMLStyle_put_borderLeft(style
, sDefault
);
4567 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4568 SysFreeString(sDefault
);
4570 /* backgroundPositionX */
4571 hres
= IHTMLStyle_get_backgroundPositionX(style
, &vDefault
);
4572 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4575 V_BSTR(&v
) = a2bstr("10px");
4576 hres
= IHTMLStyle_put_backgroundPositionX(style
, v
);
4577 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4580 hres
= IHTMLStyle_get_backgroundPositionX(style
, &v
);
4581 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4582 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4585 hres
= IHTMLStyle_put_backgroundPositionX(style
, vDefault
);
4586 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4587 VariantClear(&vDefault
);
4589 /* backgroundPositionY */
4590 hres
= IHTMLStyle_get_backgroundPositionY(style
, &vDefault
);
4591 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4594 V_BSTR(&v
) = a2bstr("10px");
4595 hres
= IHTMLStyle_put_backgroundPositionY(style
, v
);
4596 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4599 hres
= IHTMLStyle_get_backgroundPositionY(style
, &v
);
4600 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4601 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4604 hres
= IHTMLStyle_put_backgroundPositionY(style
, vDefault
);
4605 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4606 VariantClear(&vDefault
);
4608 /* borderTopWidth */
4609 hres
= IHTMLStyle_get_borderTopWidth(style
, &vDefault
);
4610 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4613 V_BSTR(&v
) = a2bstr("10px");
4614 hres
= IHTMLStyle_put_borderTopWidth(style
, v
);
4615 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4618 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4619 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4620 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4623 hres
= IHTMLStyle_put_borderTopWidth(style
, vDefault
);
4624 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4625 VariantClear(&vDefault
);
4627 /* borderRightWidth */
4628 hres
= IHTMLStyle_get_borderRightWidth(style
, &vDefault
);
4629 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4632 V_BSTR(&v
) = a2bstr("10");
4633 hres
= IHTMLStyle_put_borderRightWidth(style
, v
);
4634 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4637 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4638 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4639 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4642 hres
= IHTMLStyle_put_borderRightWidth(style
, vDefault
);
4643 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4644 VariantClear(&vDefault
);
4646 /* borderBottomWidth */
4647 hres
= IHTMLStyle_get_borderBottomWidth(style
, &vDefault
);
4648 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4651 V_BSTR(&v
) = a2bstr("10");
4652 hres
= IHTMLStyle_put_borderBottomWidth(style
, v
);
4653 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4656 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4657 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4658 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4661 hres
= IHTMLStyle_put_borderBottomWidth(style
, vDefault
);
4662 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4663 VariantClear(&vDefault
);
4665 /* borderLeftWidth */
4666 hres
= IHTMLStyle_get_borderLeftWidth(style
, &vDefault
);
4667 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4670 V_BSTR(&v
) = a2bstr("10");
4671 hres
= IHTMLStyle_put_borderLeftWidth(style
, v
);
4672 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4675 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4676 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4677 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4680 hres
= IHTMLStyle_put_borderLeftWidth(style
, vDefault
);
4681 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4682 VariantClear(&vDefault
);
4685 hres
= IHTMLStyle_get_wordSpacing(style
, &vDefault
);
4686 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4689 V_BSTR(&v
) = a2bstr("10");
4690 hres
= IHTMLStyle_put_wordSpacing(style
, v
);
4691 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4694 hres
= IHTMLStyle_get_wordSpacing(style
, &v
);
4695 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4696 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4697 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4700 hres
= IHTMLStyle_put_wordSpacing(style
, vDefault
);
4701 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4702 VariantClear(&vDefault
);
4705 hres
= IHTMLStyle_get_letterSpacing(style
, &vDefault
);
4706 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4709 V_BSTR(&v
) = a2bstr("11");
4710 hres
= IHTMLStyle_put_letterSpacing(style
, v
);
4711 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4714 hres
= IHTMLStyle_get_letterSpacing(style
, &v
);
4715 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4716 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4717 ok(!strcmp_wa(V_BSTR(&v
), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4720 hres
= IHTMLStyle_put_letterSpacing(style
, vDefault
);
4721 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4722 VariantClear(&vDefault
);
4724 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
4725 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
4726 if(SUCCEEDED(hres
)) {
4727 test_style2(style2
);
4728 IHTMLStyle2_Release(style2
);
4731 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle3
, (void**)&style3
);
4732 ok(hres
== S_OK
, "Could not get IHTMLStyle3 iface: %08x\n", hres
);
4733 if(SUCCEEDED(hres
)) {
4734 test_style3(style3
);
4735 IHTMLStyle3_Release(style3
);
4738 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle4
, (void**)&style4
);
4739 ok(hres
== S_OK
, "Could not get IHTMLStyle4 iface: %08x\n", hres
);
4740 if(SUCCEEDED(hres
)) {
4741 test_style4(style4
);
4742 IHTMLStyle4_Release(style4
);
4746 static void test_set_csstext(IHTMLStyle
*style
)
4751 test_style_set_csstext(style
, "background-color: black;");
4753 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4754 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4755 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4756 ok(!strcmp_wa(V_BSTR(&v
), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4760 static void test_default_selection(IHTMLDocument2
*doc
)
4762 IHTMLSelectionObject
*selection
;
4763 IHTMLTxtRange
*range
;
4768 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4769 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
4771 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
4772 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4773 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
4776 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
4777 IHTMLSelectionObject_Release(selection
);
4778 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
4780 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
4781 IDispatch_Release(disp
);
4782 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
4784 test_range_text(range
, NULL
);
4785 IHTMLTxtRange_Release(range
);
4788 static void test_doc_elem(IHTMLDocument2
*doc
)
4790 IHTMLDocument2
*doc_node
, *owner_doc
;
4792 IHTMLDocument3
*doc3
;
4795 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4796 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
4798 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
4799 IHTMLDocument3_Release(doc3
);
4800 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
4802 test_node_name((IUnknown
*)elem
, "HTML");
4803 test_elem_tag((IUnknown
*)elem
, "HTML");
4805 doc_node
= get_doc_node(doc
);
4806 owner_doc
= get_owner_doc((IUnknown
*)elem
);
4807 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
4808 IHTMLDocument2_Release(owner_doc
);
4810 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
4811 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
4812 IHTMLDocument2_Release(doc_node
);
4814 test_elem_client_rect((IUnknown
*)elem
);
4816 IHTMLElement_Release(elem
);
4819 static void test_default_body(IHTMLBodyElement
*body
)
4826 bstr
= (void*)0xdeadbeef;
4827 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
4828 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
4829 ok(bstr
== NULL
, "bstr != NULL\n");
4831 l
= elem_get_scroll_height((IUnknown
*)body
);
4832 ok(l
!= -1, "scrollHeight == -1\n");
4833 l
= elem_get_scroll_width((IUnknown
*)body
);
4834 ok(l
!= -1, "scrollWidth == -1\n");
4835 l
= elem_get_scroll_top((IUnknown
*)body
);
4836 ok(!l
, "scrollTop = %d\n", l
);
4837 elem_get_scroll_left((IUnknown
*)body
);
4839 /* get_text tests */
4840 hres
= IHTMLBodyElement_get_text(body
, &v
);
4841 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4842 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4843 ok(bstr
== NULL
, "bstr != NULL\n");
4845 /* get_text - Invalid Text */
4847 V_BSTR(&v
) = a2bstr("Invalid");
4848 hres
= IHTMLBodyElement_put_text(body
, v
);
4849 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4853 hres
= IHTMLBodyElement_get_text(body
, &v
);
4854 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4855 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4856 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
4859 /* get_text - Valid Text */
4861 V_BSTR(&v
) = a2bstr("#FF0000");
4862 hres
= IHTMLBodyElement_put_text(body
, v
);
4863 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4867 hres
= IHTMLBodyElement_get_text(body
, &v
);
4868 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4869 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4870 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
4874 static void test_body_funs(IHTMLBodyElement
*body
)
4876 VARIANT vbg
, vDefaultbg
;
4879 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
4880 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4881 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
4882 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
4884 V_VT(&vbg
) = VT_BSTR
;
4885 V_BSTR(&vbg
) = a2bstr("red");
4886 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
4887 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4890 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
4891 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4892 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
4893 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
4896 /* Restore Originial */
4897 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
4898 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4899 VariantClear(&vDefaultbg
);
4902 static void test_window(IHTMLDocument2
*doc
)
4904 IHTMLWindow2
*window
, *window2
, *self
;
4905 IHTMLDocument2
*doc2
= NULL
;
4911 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
4912 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
4913 test_ifaces((IUnknown
*)window
, window_iids
);
4914 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
4916 hres
= IHTMLWindow2_get_document(window
, &doc2
);
4917 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4918 ok(doc2
!= NULL
, "doc2 == NULL\n");
4920 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
4921 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
4923 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
4924 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
4926 unk
= (void*)0xdeadbeef;
4927 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
4928 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
4929 ok(!unk
, "unk = %p\n", unk
);
4931 IHTMLDocument_Release(doc2
);
4933 hres
= IHTMLWindow2_get_window(window
, &window2
);
4934 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
4935 ok(window2
!= NULL
, "window2 == NULL\n");
4937 hres
= IHTMLWindow2_get_self(window
, &self
);
4938 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
4939 ok(window2
!= NULL
, "self == NULL\n");
4941 ok(self
== window2
, "self != window2\n");
4943 IHTMLWindow2_Release(window2
);
4944 IHTMLWindow2_Release(self
);
4947 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
4948 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
4949 ok(disp
== (void*)window
, "disp != window\n");
4950 IDispatch_Release(disp
);
4952 hres
= IHTMLWindow2_toString(window
, NULL
);
4953 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
4956 hres
= IHTMLWindow2_toString(window
, &str
);
4957 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
4958 ok(!strcmp_wa(str
, "[object]"), "toString returned %s\n", wine_dbgstr_w(str
));
4961 test_window_name(window
, NULL
);
4962 set_window_name(window
, "test");
4963 test_window_length(window
, 0);
4964 test_screen(window
);
4966 IHTMLWindow2_Release(window
);
4969 static void test_defaults(IHTMLDocument2
*doc
)
4971 IHTMLStyleSheetsCollection
*stylesheetcol
;
4972 IHTMLCurrentStyle
*cstyle
;
4973 IHTMLBodyElement
*body
;
4974 IHTMLElement2
*elem2
;
4979 IHTMLElementCollection
*collection
;
4981 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4982 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4984 hres
= IHTMLDocument2_get_images(doc
, NULL
);
4985 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4987 hres
= IHTMLDocument2_get_images(doc
, &collection
);
4988 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
4991 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
4992 IHTMLElementCollection_Release(collection
);
4995 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
4996 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
4998 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
4999 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5002 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5003 IHTMLElementCollection_Release(collection
);
5006 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5007 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5009 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5010 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5013 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5014 IHTMLElementCollection_Release(collection
);
5017 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5018 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5020 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5021 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5024 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5025 IHTMLElementCollection_Release(collection
);
5028 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5029 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5031 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5032 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5035 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5036 IHTMLElementCollection_Release(collection
);
5039 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5040 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5041 test_default_body(body
);
5042 test_body_funs(body
);
5043 IHTMLBodyElement_Release(body
);
5045 hres
= IHTMLElement_get_style(elem
, &style
);
5046 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5048 test_default_style(style
);
5050 test_compatmode(doc
);
5052 test_navigator(doc
);
5054 elem2
= get_elem2_iface((IUnknown
*)elem
);
5055 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5056 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5057 if(SUCCEEDED(hres
)) {
5058 test_current_style(cstyle
);
5059 IHTMLCurrentStyle_Release(cstyle
);
5061 IHTMLElement2_Release(elem2
);
5063 IHTMLElement_Release(elem
);
5065 test_set_csstext(style
);
5066 IHTMLStyle_Release(style
);
5068 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5069 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5072 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5073 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5074 ok(l
== 0, "length = %d\n", l
);
5076 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5078 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5079 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5081 test_default_selection(doc
);
5082 test_doc_title(doc
, "");
5085 static void test_tr_elem(IHTMLElement
*elem
)
5087 IHTMLElementCollection
*col
;
5091 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
5093 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
5094 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
5099 hres
= IHTMLTableRow_get_cells(row
, &col
);
5100 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
5101 ok(col
!= NULL
, "get_cells returned NULL\n");
5103 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
5104 IHTMLElementCollection_Release(col
);
5106 IHTMLTable_Release(row
);
5109 static void test_table_elem(IHTMLElement
*elem
)
5111 IHTMLElementCollection
*col
;
5116 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
5117 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
5119 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
5120 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
5125 hres
= IHTMLTable_get_rows(table
, &col
);
5126 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5127 ok(col
!= NULL
, "get_ros returned NULL\n");
5129 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
5130 IHTMLElementCollection_Release(col
);
5132 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5134 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
5135 test_elem_tag((IUnknown
*)node
, "TABLE");
5136 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5137 IHTMLDOMNode_Release(node
);
5139 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
5140 test_elem_tag((IUnknown
*)node
, "TABLE");
5141 test_elem_all((IUnknown
*)node
, NULL
, 0);
5142 IHTMLDOMNode_Release(node
);
5144 IHTMLTable_Release(table
);
5147 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
5157 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
5158 SafeArrayAccessData(sa
, (void**)&var
);
5159 V_VT(var
) = VT_BSTR
;
5160 V_BSTR(var
) = str
= a2bstr(text
);
5161 SafeArrayUnaccessData(sa
);
5164 hres
= IHTMLDocument2_writeln(doc
, sa
);
5166 hres
= IHTMLDocument2_write(doc
, sa
);
5167 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
5170 SafeArrayDestroy(sa
);
5173 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
5175 IHTMLDocument2
*window_doc
, *elem_doc
;
5176 IHTMLFrameElement3
*frame_elem3
;
5177 IHTMLWindow2
*content_window
;
5180 content_window
= get_frame_content_window(frame_elem
);
5181 window_doc
= get_window_doc(content_window
);
5182 IHTMLWindow2_Release(content_window
);
5184 elem_doc
= get_elem_doc(frame_elem
);
5185 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
5188 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
5189 if(SUCCEEDED(hres
)) {
5190 IDispatch
*disp
= NULL
;
5192 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
5193 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
5194 ok(disp
!= NULL
, "contentDocument == NULL\n");
5195 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
5197 IDispatch_Release(disp
);
5198 IHTMLFrameElement3_Release(frame_elem3
);
5200 win_skip("IHTMLFrameElement3 not supported\n");
5204 IHTMLDocument2_Release(elem_doc
);
5205 IHTMLDocument2_Release(window_doc
);
5208 static void test_iframe_elem(IHTMLElement
*elem
)
5210 IHTMLDocument2
*content_doc
, *owner_doc
;
5211 IHTMLElementCollection
*col
;
5212 IHTMLWindow2
*content_window
;
5218 static const elem_type_t all_types
[] = {
5226 test_frame_doc((IUnknown
*)elem
, TRUE
);
5228 content_window
= get_frame_content_window((IUnknown
*)elem
);
5229 test_window_length(content_window
, 0);
5231 content_doc
= get_window_doc(content_window
);
5232 IHTMLWindow2_Release(content_window
);
5234 str
= a2bstr("text/html");
5235 V_VT(&errv
) = VT_ERROR
;
5237 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5239 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5240 ok(disp
!= NULL
, "disp == NULL\n");
5241 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5242 IDispatch_Release(disp
);
5244 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head><body><br /></body>");
5245 doc_write(content_doc
, TRUE
, "</html>");
5247 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5248 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5249 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5250 IHTMLElementCollection_Release(col
);
5252 hres
= IHTMLDocument2_close(content_doc
);
5253 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5255 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5256 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5258 IHTMLDocument2_Release(content_doc
);
5261 static void test_stylesheet(IDispatch
*disp
)
5263 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5264 IHTMLStyleSheet
*stylesheet
;
5267 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5268 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5270 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5271 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5272 ok(col
!= NULL
, "col == NULL\n");
5274 IHTMLStyleSheetRulesCollection_Release(col
);
5275 IHTMLStyleSheet_Release(stylesheet
);
5278 static void test_stylesheets(IHTMLDocument2
*doc
)
5280 IHTMLStyleSheetsCollection
*col
= NULL
;
5285 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5286 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5287 ok(col
!= NULL
, "col == NULL\n");
5289 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5290 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5291 ok(len
== 1, "len=%d\n", len
);
5297 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5298 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5299 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5300 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5301 test_stylesheet(V_DISPATCH(&res
));
5308 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5309 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5310 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5311 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5314 IHTMLStyleSheetsCollection_Release(col
);
5317 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
5319 IDispatchEx
*dispex
;
5321 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
5329 static const WCHAR w0
[] = {'0',0};
5330 static const WCHAR w100
[] = {'1','0','0',0};
5332 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
5333 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
5335 bstr
= SysAllocString(w0
);
5336 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5337 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5338 SysFreeString(bstr
);
5341 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
5342 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
5343 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
5344 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
5345 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
5346 type
= get_node_type((IUnknown
*)node
);
5347 ok(type
== 3, "type=%d\n", type
);
5348 IHTMLDOMNode_Release(node
);
5351 bstr
= SysAllocString(w100
);
5352 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5353 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
5354 SysFreeString(bstr
);
5356 IDispatchEx_Release(dispex
);
5361 static void test_elems(IHTMLDocument2
*doc
)
5363 IHTMLElementCollection
*col
;
5364 IHTMLDOMChildrenCollection
*child_col
;
5365 IHTMLElement
*elem
, *elem2
, *elem3
;
5366 IHTMLDOMNode
*node
, *node2
;
5367 IHTMLWindow2
*window
;
5371 IHTMLElementCollection
*collection
;
5372 IHTMLDocument3
*doc3
;
5375 static const elem_type_t all_types
[] = {
5401 static const elem_type_t item_types
[] = {
5407 hres
= IHTMLDocument2_get_all(doc
, &col
);
5408 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5409 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5410 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
5411 IHTMLElementCollection_Release(col
);
5413 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5414 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5417 static const elem_type_t images_types
[] = {ET_IMG
};
5418 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5420 IHTMLElementCollection_Release(collection
);
5423 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5424 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5427 static const elem_type_t images_types
[] = {ET_A
};
5428 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5430 IHTMLElementCollection_Release(collection
);
5433 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5434 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5437 static const elem_type_t anchor_types
[] = {ET_A
};
5438 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
5440 IHTMLElementCollection_Release(collection
);
5443 elem
= get_doc_elem(doc
);
5444 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
5445 IHTMLElement_Release(elem
);
5447 get_elem_by_id(doc
, "xxx", FALSE
);
5448 elem
= get_doc_elem_by_id(doc
, "xxx");
5449 ok(!elem
, "elem != NULL\n");
5451 elem
= get_doc_elem_by_id(doc
, "s");
5452 ok(elem
!= NULL
, "elem == NULL\n");
5454 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
5455 test_elem_attr(elem
, "xxx", NULL
);
5456 test_elem_attr(elem
, "id", "s");
5457 test_elem_class((IUnknown
*)elem
, NULL
);
5458 test_elem_set_class((IUnknown
*)elem
, "cl");
5459 test_elem_set_class((IUnknown
*)elem
, NULL
);
5460 test_elem_tabindex((IUnknown
*)elem
, 0);
5461 test_elem_set_tabindex((IUnknown
*)elem
, 1);
5462 test_elem_filters((IUnknown
*)elem
);
5464 node
= test_node_get_parent((IUnknown
*)elem
);
5465 ok(node
!= NULL
, "node == NULL\n");
5466 test_node_name((IUnknown
*)node
, "BODY");
5467 node2
= test_node_get_parent((IUnknown
*)node
);
5468 IHTMLDOMNode_Release(node
);
5469 ok(node2
!= NULL
, "node == NULL\n");
5470 test_node_name((IUnknown
*)node2
, "HTML");
5471 node
= test_node_get_parent((IUnknown
*)node2
);
5472 IHTMLDOMNode_Release(node2
);
5473 ok(node
!= NULL
, "node == NULL\n");
5476 test_node_name((IUnknown
*)node
, "#document");
5477 type
= get_node_type((IUnknown
*)node
);
5478 ok(type
== 9, "type=%d, expected 9\n", type
);
5479 node2
= test_node_get_parent((IUnknown
*)node
);
5480 IHTMLDOMNode_Release(node
);
5481 ok(node2
== NULL
, "node != NULL\n");
5484 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5485 ok(elem2
!= NULL
, "elem2 == NULL\n");
5486 test_node_name((IUnknown
*)elem2
, "BODY");
5487 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
5488 IHTMLElement_Release(elem2
);
5489 ok(elem3
!= NULL
, "elem3 == NULL\n");
5490 test_node_name((IUnknown
*)elem3
, "HTML");
5491 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
5492 IHTMLElement_Release(elem3
);
5493 ok(elem2
== NULL
, "elem2 != NULL\n");
5495 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
5496 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
5497 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
5499 test_elem_innertext(elem
, "opt1opt2");
5501 IHTMLElement_Release(elem
);
5504 elem
= get_elem_by_id(doc
, "s", TRUE
);
5506 IHTMLSelectElement
*select
;
5507 IHTMLDocument2
*doc_node
, *elem_doc
;
5509 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
5510 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
5512 test_select_elem(select
);
5514 test_elem_title((IUnknown
*)select
, NULL
);
5515 test_elem_set_title((IUnknown
*)select
, "Title");
5516 test_elem_title((IUnknown
*)select
, "Title");
5517 test_elem_offset((IUnknown
*)select
);
5519 node
= get_first_child((IUnknown
*)select
);
5520 ok(node
!= NULL
, "node == NULL\n");
5522 test_elem_type((IUnknown
*)node
, ET_OPTION
);
5523 IHTMLDOMNode_Release(node
);
5526 type
= get_node_type((IUnknown
*)select
);
5527 ok(type
== 1, "type=%d\n", type
);
5529 IHTMLSelectElement_Release(select
);
5531 elem_doc
= get_elem_doc((IUnknown
*)elem
);
5533 doc_node
= get_doc_node(doc
);
5534 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
5535 IHTMLDocument2_Release(doc_node
);
5536 IHTMLDocument2_Release(elem_doc
);
5538 IHTMLElement_Release(elem
);
5541 elem
= get_elem_by_id(doc
, "sc", TRUE
);
5543 IHTMLScriptElement
*script
;
5546 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
5547 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
5553 hres
= IHTMLScriptElement_get_type(script
, &type
);
5554 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5555 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
5556 SysFreeString(type
);
5559 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
5560 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5562 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
5563 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
5564 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
5566 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
5567 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5570 IHTMLScriptElement_Release(script
);
5573 elem
= get_elem_by_id(doc
, "in", TRUE
);
5575 IHTMLInputElement
*input
;
5577 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
5578 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
5580 test_elem_id((IUnknown
*)elem
, "in");
5581 test_elem_put_id((IUnknown
*)elem
, "newin");
5582 test_input_get_disabled(input
, VARIANT_FALSE
);
5583 test_input_set_disabled(input
, VARIANT_TRUE
);
5584 test_input_set_disabled(input
, VARIANT_FALSE
);
5585 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
5586 test_input_get_disabled(input
, VARIANT_TRUE
);
5587 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
5588 test_input_get_disabled(input
, VARIANT_FALSE
);
5589 test_elem_client_size((IUnknown
*)elem
);
5591 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5592 test_node_put_value_str((IUnknown
*)elem
, "test");
5593 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5594 test_input_value((IUnknown
*)elem
, NULL
);
5595 test_input_put_value((IUnknown
*)elem
, "test");
5596 test_input_value((IUnknown
*)elem
, NULL
);
5597 test_elem_class((IUnknown
*)elem
, "testclass");
5598 test_elem_tabindex((IUnknown
*)elem
, 2);
5599 test_elem_set_tabindex((IUnknown
*)elem
, 3);
5600 test_elem_title((IUnknown
*)elem
, "test title");
5602 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
5603 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
5604 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
5606 test_input_get_checked(input
, VARIANT_FALSE
);
5607 test_input_set_checked(input
, VARIANT_TRUE
);
5608 test_input_set_checked(input
, VARIANT_FALSE
);
5610 test_input_src(input
, NULL
);
5611 test_input_set_src(input
, "about:blank");
5613 IHTMLInputElement_Release(input
);
5614 IHTMLElement_Release(elem
);
5617 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5619 test_img_src((IUnknown
*)elem
, "");
5620 test_img_set_src((IUnknown
*)elem
, "about:blank");
5621 test_img_alt((IUnknown
*)elem
, NULL
);
5622 test_img_set_alt((IUnknown
*)elem
, "alt test");
5623 test_img_name((IUnknown
*)elem
, "WineImg");
5624 IHTMLElement_Release(elem
);
5627 elem
= get_doc_elem_by_id(doc
, "tbl");
5628 ok(elem
!= NULL
, "elem == NULL\n");
5630 test_table_elem(elem
);
5631 IHTMLElement_Release(elem
);
5634 elem
= get_doc_elem_by_id(doc
, "row2");
5635 ok(elem
!= NULL
, "elem == NULL\n");
5638 IHTMLElement_Release(elem
);
5641 elem
= get_doc_elem_by_id(doc
, "ifr");
5642 ok(elem
!= NULL
, "elem == NULL\n");
5644 test_iframe_elem(elem
);
5645 IHTMLElement_Release(elem
);
5648 elem
= get_elem_by_id(doc
, "a", TRUE
);
5650 test_anchor_href((IUnknown
*)elem
, "http://test/");
5651 IHTMLElement_Release(elem
);
5654 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5655 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5657 node
= get_first_child((IUnknown
*)elem
);
5658 ok(node
!= NULL
, "node == NULL\n");
5660 test_ifaces((IUnknown
*)node
, text_iids
);
5661 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5663 node2
= get_first_child((IUnknown
*)node
);
5664 ok(!node2
, "node2 != NULL\n");
5666 type
= get_node_type((IUnknown
*)node
);
5667 ok(type
== 3, "type=%d\n", type
);
5669 test_node_get_value_str((IUnknown
*)node
, "text test");
5670 test_node_put_value_str((IUnknown
*)elem
, "test text");
5671 test_node_get_value_str((IUnknown
*)node
, "text test");
5673 IHTMLDOMNode_Release(node
);
5676 child_col
= get_child_nodes((IUnknown
*)elem
);
5677 ok(child_col
!= NULL
, "child_coll == NULL\n");
5681 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
5683 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
5684 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5685 ok(length
, "length=0\n");
5688 node
= get_child_item(child_col
, 0);
5689 ok(node
!= NULL
, "node == NULL\n");
5691 type
= get_node_type((IUnknown
*)node
);
5692 ok(type
== 3, "type=%d\n", type
);
5693 node2
= node_get_next((IUnknown
*)node
);
5694 IHTMLDOMNode_Release(node
);
5697 node
= get_child_item(child_col
, 1);
5698 ok(node
!= NULL
, "node == NULL\n");
5700 type
= get_node_type((IUnknown
*)node
);
5701 ok(type
== 8, "type=%d\n", type
);
5703 test_elem_id((IUnknown
*)node
, NULL
);
5704 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
5705 IHTMLDOMNode_Release(node2
);
5706 IHTMLDOMNode_Release(node
);
5709 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
5710 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5712 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
5713 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5715 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
5716 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5718 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
5719 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5721 test_child_col_disp(child_col
);
5723 IHTMLDOMChildrenCollection_Release(child_col
);
5726 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5727 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
5728 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5730 IHTMLElement_Release(elem
);
5732 test_stylesheets(doc
);
5733 test_create_option_elem(doc
);
5734 test_create_img_elem(doc
);
5736 elem
= get_doc_elem_by_id(doc
, "tbl");
5737 ok(elem
!= NULL
, "elem = NULL\n");
5738 test_elem_set_innertext(elem
, "inner text");
5739 IHTMLElement_Release(elem
);
5741 test_doc_title(doc
, "test");
5742 test_doc_set_title(doc
, "test title");
5743 test_doc_title(doc
, "test title");
5746 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5747 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5750 IDispatchEx
*dispex
;
5751 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
5752 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
5756 BSTR str
= a2bstr("Testing");
5757 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
5758 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5759 ok(pid
!= -1, "pid == -1\n");
5761 IDispatchEx_Release(dispex
);
5764 IDispatch_Release(disp
);
5766 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5767 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5769 str
= a2bstr("img");
5770 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
5771 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
5775 static const elem_type_t img_types
[] = { ET_IMG
};
5777 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
5778 IHTMLElementCollection_Release(col
);
5781 elem
= get_doc_elem_by_id(doc
, "y");
5782 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
5783 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
5784 test_elem_set_innerhtml((IUnknown
*)elem
, "");
5785 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
5786 node
= node_get_next((IUnknown
*)elem
);
5787 ok(!node
, "node = %p\n", node
);
5789 elem2
= get_doc_elem_by_id(doc
, "x");
5790 test_elem_tag((IUnknown
*)elem2
, "A");
5791 node
= node_get_next((IUnknown
*)elem2
);
5792 IHTMLDOMNode_Release(node
);
5793 IHTMLElement_Release(elem2
);
5794 IHTMLElement_Release(elem
);
5796 IHTMLDocument3_Release(doc3
);
5798 window
= get_doc_window(doc
);
5799 test_window_name(window
, NULL
);
5800 set_window_name(window
, "test name");
5801 test_window_length(window
, 1);
5802 IHTMLWindow2_Release(window
);
5805 static void test_elems2(IHTMLDocument2
*doc
)
5807 IHTMLElement
*elem
, *elem2
;
5809 static const elem_type_t outer_types
[] = {
5814 elem
= get_doc_elem_by_id(doc
, "divid");
5816 test_elem_set_innerhtml((IUnknown
*)elem
, "<div id=\"innerid\"></div>");
5817 elem2
= get_doc_elem_by_id(doc
, "innerid");
5818 ok(elem2
!= NULL
, "elem2 == NULL\n");
5819 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5820 test_elem_all((IUnknown
*)elem
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
5821 IHTMLElement_Release(elem2
);
5823 elem2
= get_doc_elem_by_id(doc
, "aid");
5824 ok(elem2
!= NULL
, "elem2 == NULL\n");
5825 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
5826 test_elem_all((IUnknown
*)elem
, outer_types
, 1);
5827 IHTMLElement_Release(elem2
);
5829 IHTMLElement_Release(elem
);
5832 static void test_create_elems(IHTMLDocument2
*doc
)
5834 IHTMLElement
*elem
, *body
, *elem2
;
5835 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
5836 IHTMLDocument5
*doc5
;
5843 static const elem_type_t types1
[] = { ET_TESTG
};
5845 elem
= test_create_elem(doc
, "TEST");
5846 test_elem_tag((IUnknown
*)elem
, "TEST");
5847 type
= get_node_type((IUnknown
*)elem
);
5848 ok(type
== 1, "type=%d\n", type
);
5849 test_ifaces((IUnknown
*)elem
, elem_iids
);
5850 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
5852 hres
= IHTMLDocument2_get_body(doc
, &body
);
5853 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5854 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5856 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
5857 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
5858 elem2
= get_elem_iface((IUnknown
*)node
);
5859 IHTMLElement_Release(elem2
);
5861 hres
= IHTMLElement_get_all(body
, &disp
);
5862 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5863 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
5864 IDispatch_Release(disp
);
5866 test_node_remove_child((IUnknown
*)body
, node
);
5868 hres
= IHTMLElement_get_all(body
, &disp
);
5869 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5870 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
5871 IDispatch_Release(disp
);
5872 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5874 IHTMLElement_Release(elem
);
5875 IHTMLDOMNode_Release(node
);
5877 node
= test_create_text(doc
, "test");
5878 test_ifaces((IUnknown
*)node
, text_iids
);
5879 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5880 test_text_length((IUnknown
*)node
, 4);
5882 V_VT(&var
) = VT_NULL
;
5883 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5884 IHTMLDOMNode_Release(node
);
5886 node
= test_create_text(doc
, "insert ");
5888 V_VT(&var
) = VT_DISPATCH
;
5889 V_DISPATCH(&var
) = (IDispatch
*)node2
;
5890 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5891 IHTMLDOMNode_Release(node
);
5892 IHTMLDOMNode_Release(node2
);
5893 IHTMLDOMNode_Release(node3
);
5895 test_elem_innertext(body
, "insert test");
5896 test_elem_innerhtml((IUnknown
*)body
, "insert test");
5898 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
5901 str
= a2bstr("testing");
5902 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
5904 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
5907 type
= get_node_type((IUnknown
*)comment
);
5908 ok(type
== 8, "type=%d, expected 8\n", type
);
5910 test_node_get_value_str((IUnknown
*)comment
, "testing");
5911 test_elem_title((IUnknown
*)comment
, NULL
);
5912 test_elem_set_title((IUnknown
*)comment
, "comment title");
5913 test_elem_title((IUnknown
*)comment
, "comment title");
5915 IHTMLDOMNode_Release(comment
);
5918 IHTMLDocument5_Release(doc5
);
5921 IHTMLElement_Release(body
);
5924 static void test_null_write(IHTMLDocument2
*doc
)
5928 doc_write(doc
, FALSE
, NULL
);
5929 doc_write(doc
, TRUE
, NULL
);
5931 hres
= IHTMLDocument2_write(doc
, NULL
);
5933 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
5935 hres
= IHTMLDocument2_writeln(doc
, NULL
);
5937 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
5940 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
5942 IOleCommandTarget
*cmdtrg
;
5945 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
5946 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
5948 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
5949 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
5951 IOleCommandTarget_Release(cmdtrg
);
5954 static void test_indent(IHTMLDocument2
*doc
)
5956 IHTMLElementCollection
*col
;
5957 IHTMLTxtRange
*range
;
5960 static const elem_type_t all_types
[] = {
5969 static const elem_type_t indent_types
[] = {
5980 hres
= IHTMLDocument2_get_all(doc
, &col
);
5981 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5982 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5983 IHTMLElementCollection_Release(col
);
5985 range
= test_create_body_range(doc
);
5986 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
5987 IHTMLTxtRange_Release(range
);
5989 hres
= IHTMLDocument2_get_all(doc
, &col
);
5990 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5991 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
5992 IHTMLElementCollection_Release(col
);
5995 static void test_cond_comment(IHTMLDocument2
*doc
)
5997 IHTMLElementCollection
*col
;
6000 static const elem_type_t all_types
[] = {
6008 hres
= IHTMLDocument2_get_all(doc
, &col
);
6009 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6010 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6011 IHTMLElementCollection_Release(col
);
6014 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6016 IHTMLWindow2
*frame2
, *parent
, *top
;
6017 IHTMLDocument2
*parent_doc
, *top_doc
;
6018 IHTMLWindow4
*frame
;
6019 IHTMLFrameBase
*frame_elem
;
6022 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6023 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6027 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6028 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6029 IHTMLWindow4_Release(frame
);
6033 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6034 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6035 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6036 IHTMLElement_Release(frame_elem
);
6038 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6039 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6043 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6044 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6046 IHTMLWindow2_Release(frame2
);
6050 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6051 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6052 IHTMLWindow2_Release(parent
);
6054 IHTMLWindow2_Release(frame2
);
6058 test_doc_title(parent_doc
, "frameset test");
6059 IHTMLDocument2_Release(parent_doc
);
6062 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6063 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6064 IHTMLWindow2_Release(frame2
);
6068 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6069 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6070 IHTMLWindow2_Release(top
);
6074 test_doc_title(top_doc
, "frameset test");
6075 IHTMLDocument2_Release(top_doc
);
6078 static void test_frameset(IHTMLDocument2
*doc
)
6080 IHTMLWindow2
*window
;
6081 IHTMLFramesCollection2
*frames
;
6083 IHTMLFrameBase
*fbase
;
6085 VARIANT index_var
, result_var
;
6089 window
= get_doc_window(doc
);
6091 /* test using IHTMLFramesCollection object */
6093 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6094 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6095 IHTMLWindow2_Release(window
);
6099 /* test result length */
6100 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6101 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6102 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6104 /* test first frame */
6105 V_VT(&index_var
) = VT_I4
;
6106 V_I4(&index_var
) = 0;
6107 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6108 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6109 if(SUCCEEDED(hres
)) {
6110 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6111 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6113 VariantClear(&result_var
);
6115 /* test second frame */
6116 V_I4(&index_var
) = 1;
6117 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6118 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6119 if(SUCCEEDED(hres
)) {
6120 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6121 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6123 VariantClear(&result_var
);
6125 /* fail on next frame */
6126 V_I4(&index_var
) = 3;
6127 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6128 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6129 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6130 VariantClear(&result_var
);
6132 /* string argument (element id lookup) */
6133 V_VT(&index_var
) = VT_BSTR
;
6134 V_BSTR(&index_var
) = a2bstr("fr1");
6135 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6136 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6137 if(SUCCEEDED(hres
)) {
6138 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6139 test_frame(V_DISPATCH(&result_var
), "fr1");
6141 VariantClear(&result_var
);
6142 VariantClear(&index_var
);
6144 /* invalid argument */
6145 V_VT(&index_var
) = VT_BOOL
;
6146 V_BOOL(&index_var
) = VARIANT_TRUE
;
6147 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6148 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6149 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6150 VariantClear(&result_var
);
6152 IHTMLFramesCollection2_Release(frames
);
6154 /* test using IHTMLWindow2 inheritance */
6156 /* test result length */
6157 hres
= IHTMLWindow2_get_length(window
, &length
);
6158 ok(hres
== S_OK
, "IHTMLWindow2_get_length failed: 0x%08x\n", hres
);
6159 ok(length
== 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length
);
6161 /* test first frame */
6162 V_VT(&index_var
) = VT_I4
;
6163 V_I4(&index_var
) = 0;
6164 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6165 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6166 if(SUCCEEDED(hres
)) {
6167 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6168 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6170 VariantClear(&result_var
);
6172 /* test second frame */
6173 V_I4(&index_var
) = 1;
6174 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6175 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6176 if(SUCCEEDED(hres
)) {
6177 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6178 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6180 VariantClear(&result_var
);
6182 /* fail on next frame */
6183 V_I4(&index_var
) = 3;
6184 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6185 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLWindow2_item should have"
6186 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6187 VariantClear(&result_var
);
6189 /* string argument (element id lookup) */
6190 V_VT(&index_var
) = VT_BSTR
;
6191 V_BSTR(&index_var
) = a2bstr("fr2");
6192 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6193 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6194 if(SUCCEEDED(hres
)) {
6195 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6196 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6198 VariantClear(&result_var
);
6199 VariantClear(&index_var
);
6201 /* invalid argument */
6202 V_VT(&index_var
) = VT_BOOL
;
6203 V_BOOL(&index_var
) = VARIANT_TRUE
;
6204 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6205 ok(hres
== E_INVALIDARG
, "IHTMLWindow2_item should have"
6206 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6207 VariantClear(&result_var
);
6209 /* getElementById with node name attributes */
6210 elem
= get_doc_elem_by_id(doc
, "nm1");
6211 test_elem_id((IUnknown
*)elem
, "fr1");
6213 /* get/put scrolling */
6214 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6215 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6217 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6218 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6219 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6223 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6224 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6227 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6228 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6229 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6232 str
= a2bstr("junk");
6233 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6234 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6235 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6238 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6239 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6240 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6244 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6245 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6246 ok(!strcmp_wa(str
, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str
));
6249 IHTMLFrameBase_Release(fbase
);
6250 IHTMLElement_Release(elem
);
6252 /* get_name with no name attr */
6253 elem
= get_doc_elem_by_id(doc
, "fr3");
6254 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6255 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6257 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6258 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6259 ok(str
== NULL
, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str
));
6262 IHTMLFrameBase_Release(fbase
);
6263 IHTMLElement_Release(elem
);
6266 static IHTMLDocument2
*notif_doc
;
6267 static BOOL doc_complete
;
6269 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
6270 REFIID riid
, void**ppv
)
6272 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
6277 ok(0, "unexpected call\n");
6278 return E_NOINTERFACE
;
6281 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
6286 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
6291 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
6293 if(dispID
== DISPID_READYSTATE
){
6297 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
6298 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
6300 if(!strcmp_wa(state
, "complete"))
6301 doc_complete
= TRUE
;
6303 SysFreeString(state
);
6309 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
6311 ok(0, "unexpected call\n");
6315 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
6316 PropertyNotifySink_QueryInterface
,
6317 PropertyNotifySink_AddRef
,
6318 PropertyNotifySink_Release
,
6319 PropertyNotifySink_OnChanged
,
6320 PropertyNotifySink_OnRequestEdit
6323 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
6325 static IHTMLDocument2
*create_doc_with_string(const char *str
)
6327 IPersistStreamInit
*init
;
6329 IHTMLDocument2
*doc
;
6333 notif_doc
= doc
= create_document();
6337 doc_complete
= FALSE
;
6339 mem
= GlobalAlloc(0, len
);
6340 memcpy(mem
, str
, len
);
6341 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
6343 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
6345 IPersistStreamInit_Load(init
, stream
);
6346 IPersistStreamInit_Release(init
);
6347 IStream_Release(stream
);
6352 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
6354 IConnectionPointContainer
*container
;
6355 IConnectionPoint
*cp
;
6359 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
6360 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
6362 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
6363 IConnectionPointContainer_Release(container
);
6364 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
6366 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
6367 IConnectionPoint_Release(cp
);
6368 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
6371 typedef void (*domtest_t
)(IHTMLDocument2
*);
6373 static void run_domtest(const char *str
, domtest_t test
)
6375 IHTMLDocument2
*doc
;
6379 doc
= create_doc_with_string(str
);
6383 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
6385 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
6386 TranslateMessage(&msg
);
6387 DispatchMessage(&msg
);
6392 ref
= IHTMLDocument2_Release(doc
);
6394 ref
== 1, /* Vista */
6402 run_domtest(doc_str1
, test_doc_elem
);
6403 run_domtest(doc_str1
, test_get_set_attr
);
6404 run_domtest(range_test_str
, test_txtrange
);
6405 run_domtest(range_test2_str
, test_txtrange2
);
6406 if (winetest_interactive
|| ! is_ie_hardened()) {
6407 run_domtest(elem_test_str
, test_elems
);
6409 skip("IE running in Enhanced Security Configuration\n");
6411 run_domtest(elem_test2_str
, test_elems2
);
6412 run_domtest(doc_blank
, test_create_elems
);
6413 run_domtest(doc_blank
, test_defaults
);
6414 run_domtest(doc_blank
, test_null_write
);
6415 run_domtest(indent_test_str
, test_indent
);
6416 run_domtest(cond_comment_str
, test_cond_comment
);
6417 run_domtest(frameset_str
, test_frameset
);