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 get_comment_iface(u) _get_comment_iface(__LINE__,u)
688 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
690 IHTMLCommentElement
*comment
;
693 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
694 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
698 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
699 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
701 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
705 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
706 IHTMLDOMNode_Release(node
);
707 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
708 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
713 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
714 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
716 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
717 IDispatch
*disp
= (void*)0xdeadbeef;
718 IHTMLDocument2
*doc
= NULL
;
721 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
722 IHTMLDOMNode2_Release(node
);
723 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
726 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
727 IDispatch_Release(disp
);
728 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
734 #define get_doc_window(d) _get_doc_window(__LINE__,d)
735 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
737 IHTMLWindow2
*window
;
741 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
742 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
743 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
748 #define clone_node(n,d) _clone_node(__LINE__,n,d)
749 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
751 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
752 IHTMLDOMNode
*ret
= NULL
;
755 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
756 IHTMLDOMNode_Release(node
);
757 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
758 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
764 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
765 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
767 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
771 hres
= IHTMLElement_get_tagName(elem
, &tag
);
772 IHTMLElement_Release(elem
);
773 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
774 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
779 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
780 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
782 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
783 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
785 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
786 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
789 #define get_node_type(n) _get_node_type(__LINE__,n)
790 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
792 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
796 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
797 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
799 IHTMLDOMNode_Release(node
);
804 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
805 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
807 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
808 IHTMLDOMChildrenCollection
*col
= NULL
;
812 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
813 IHTMLDOMNode_Release(node
);
814 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
818 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
819 IDispatch_Release(disp
);
820 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
825 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
826 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
828 IHTMLDOMNode
*node
= NULL
;
832 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
833 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
835 node
= _get_node_iface(line
, (IUnknown
*)disp
);
836 IDispatch_Release(disp
);
841 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
842 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
851 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
853 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
856 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
857 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
859 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
862 VariantClear(&value
);
865 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
866 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
868 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
872 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
873 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
875 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
876 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
878 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
879 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
881 IHTMLElement_Release(elem
);
884 #define get_doc_node(d) _get_doc_node(__LINE__,d)
885 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
887 IHTMLWindow2
*window
;
891 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
892 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
894 hres
= IHTMLWindow2_get_document(window
, &ret
);
895 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
896 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
901 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
902 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
907 hres
= IHTMLWindow2_get_name(window
, &name
);
908 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
910 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
912 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
915 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
916 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
922 hres
= IHTMLWindow2_put_name(window
, str
);
924 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
926 _test_window_name(line
, window
, name
);
929 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
930 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
935 hres
= IHTMLWindow2_get_length(window
, &length
);
936 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
937 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
940 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
941 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
943 IHTMLFrameBase2
*base2
;
944 IHTMLWindow2
*window
;
947 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
948 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
951 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
952 IHTMLFrameBase2_Release(base2
);
953 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
954 ok(window
!= NULL
, "contentWindow = NULL\n");
959 static void test_get_set_attr(IHTMLDocument2
*doc
)
962 IHTMLDocument3
*doc3
;
967 /* grab an element to test with */
968 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
969 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
971 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
972 IHTMLDocument3_Release(doc3
);
973 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
975 /* get a non-present attribute */
976 bstr
= a2bstr("notAnAttribute");
977 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
978 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
979 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
983 /* get a present attribute */
984 bstr
= a2bstr("scrollHeight");
985 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
986 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
987 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
991 /* create a new BSTR attribute */
992 bstr
= a2bstr("newAttribute");
994 V_VT(&val
) = VT_BSTR
;
995 V_BSTR(&val
) = a2bstr("the value");
996 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
997 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1000 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1001 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1002 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1003 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
)));
1006 /* overwrite the attribute with a BOOL */
1007 V_VT(&val
) = VT_BOOL
;
1008 V_BOOL(&val
) = VARIANT_TRUE
;
1009 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1010 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1013 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1014 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1015 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1016 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1019 SysFreeString(bstr
);
1021 /* case-insensitive */
1022 bstr
= a2bstr("newattribute");
1023 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1024 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1025 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1026 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1028 SysFreeString(bstr
);
1030 IHTMLElement_Release(elem
);
1033 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1034 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1037 IHTMLDocument3
*doc3
;
1040 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1041 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1042 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1043 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1044 IHTMLDocument3_Release(doc3
);
1049 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1050 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1052 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1056 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1057 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1058 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1061 _test_disp_value(line
, unk
, exhref
);
1064 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1065 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1070 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1071 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1072 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1073 SysFreeString(bstr
);
1076 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1077 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1082 bstr
= a2bstr(text
);
1083 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1084 SysFreeString(bstr
);
1085 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1087 _test_option_text(line
, option
, text
);
1090 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1091 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1096 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1097 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1098 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1099 SysFreeString(bstr
);
1102 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1103 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1108 bstr
= a2bstr(value
);
1109 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1110 SysFreeString(bstr
);
1111 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1113 _test_option_value(line
, option
, value
);
1116 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1117 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1119 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1123 text
= a2bstr(extext
);
1124 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1125 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1126 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1128 IHTMLCommentElement_Release(comment
);
1129 SysFreeString(text
);
1132 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1133 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1134 const char *txt
, const char *val
)
1136 IHTMLOptionElementFactory
*factory
;
1137 IHTMLOptionElement
*option
;
1138 IHTMLWindow2
*window
;
1139 VARIANT text
, value
, empty
;
1142 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1143 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1145 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1146 IHTMLWindow2_Release(window
);
1147 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1149 V_VT(&text
) = VT_BSTR
;
1150 V_BSTR(&text
) = a2bstr(txt
);
1151 V_VT(&value
) = VT_BSTR
;
1152 V_BSTR(&value
) = a2bstr(val
);
1153 V_VT(&empty
) = VT_EMPTY
;
1155 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1156 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1158 IHTMLOptionElementFactory_Release(factory
);
1159 VariantClear(&text
);
1160 VariantClear(&value
);
1162 _test_option_text(line
, option
, txt
);
1163 _test_option_value(line
, option
, val
);
1168 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1169 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1174 hres
= IHTMLImgElement_get_width(img
, &found
);
1175 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1176 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1179 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1180 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const long width
)
1184 hres
= IHTMLImgElement_put_width(img
, width
);
1185 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1187 _test_img_width(line
, img
, width
);
1190 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1191 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const long exp
)
1196 hres
= IHTMLImgElement_get_height(img
, &found
);
1197 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1198 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1201 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1202 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const long height
)
1206 hres
= IHTMLImgElement_put_height(img
, height
);
1207 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1209 _test_img_height(line
, img
, height
);
1212 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1213 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1214 LONG wdth
, LONG hght
)
1216 IHTMLImageElementFactory
*factory
;
1217 IHTMLImgElement
*img
;
1218 IHTMLWindow2
*window
;
1219 VARIANT width
, height
;
1223 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1224 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1226 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1227 IHTMLWindow2_Release(window
);
1228 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1230 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1231 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1234 snprintf(buf
, 16, "%d", wdth
);
1235 V_VT(&width
) = VT_BSTR
;
1236 V_BSTR(&width
) = a2bstr(buf
);
1238 V_VT(&width
) = VT_EMPTY
;
1243 snprintf(buf
, 16, "%d", hght
);
1244 V_VT(&height
) = VT_BSTR
;
1245 V_BSTR(&height
) = a2bstr(buf
);
1247 V_VT(&height
) = VT_EMPTY
;
1251 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1252 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1254 IHTMLImageElementFactory_Release(factory
);
1255 VariantClear(&width
);
1256 VariantClear(&height
);
1258 if(SUCCEEDED(hres
)) {
1259 _test_img_width(line
, img
, wdth
);
1260 _test_img_height(line
, img
, hght
);
1267 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1268 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1270 LONG len
= 0xdeadbeef;
1273 hres
= IHTMLSelectElement_get_length(select
, &len
);
1274 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1275 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1278 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1279 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1281 LONG idx
= 0xdeadbeef;
1284 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1285 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1286 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1289 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1290 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1294 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1296 _test_select_selidx(line
, select
, index
);
1299 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1300 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1305 hres
= IHTMLSelectElement_get_value(select
, &val
);
1306 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1308 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1310 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1313 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1314 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1320 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1321 SysFreeString(bstr
);
1322 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1325 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1326 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1331 hres
= IHTMLSelectElement_get_type(select
, &type
);
1332 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
1333 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
1336 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1337 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
1342 hres
= IHTMLTxtRange_get_text(range
, &text
);
1343 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1346 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
1347 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
1349 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
1352 SysFreeString(text
);
1356 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1357 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
1361 hres
= IHTMLTxtRange_collapse(range
, b
);
1362 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
1363 _test_range_text(line
, range
, NULL
);
1366 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1367 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
1368 VARIANT_BOOL exb
, const char *extext
)
1370 VARIANT_BOOL b
= 0xe0e0;
1373 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
1374 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
1375 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
1376 _test_range_text(line
, range
, extext
);
1379 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1380 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1382 LONG c
= 0xdeadbeef;
1385 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
1386 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1387 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1388 _test_range_text(line
, range
, NULL
);
1391 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1392 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
1393 LPWSTR unit
, LONG cnt
, LONG excnt
)
1395 LONG c
= 0xdeadbeef;
1398 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
1399 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1400 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1403 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1404 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
1406 LONG c
= 0xdeadbeef;
1409 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
1410 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
1411 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
1414 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1415 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
1418 BSTR bstr
= a2bstr(text
);
1420 hres
= IHTMLTxtRange_put_text(range
, bstr
);
1421 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
1422 SysFreeString(bstr
);
1423 _test_range_text(line
, range
, NULL
);
1426 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1427 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1433 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
1434 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1435 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1438 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1439 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
1445 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
1446 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
1447 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
1450 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
1451 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
1452 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
1455 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
1456 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
1460 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1461 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
1466 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
1467 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
1469 _test_elem_type(line
, (IUnknown
*)elem
, type
);
1471 IHTMLElement_Release(elem
);
1474 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1475 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1476 const elem_type_t
*elem_types
, LONG exlen
)
1478 IHTMLElementCollection
*col
;
1481 VARIANT name
, index
;
1482 IDispatch
*disp
, *disp2
;
1485 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1486 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1488 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
1490 hres
= IHTMLElementCollection_get_length(col
, &len
);
1491 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1492 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
1497 V_VT(&index
) = VT_EMPTY
;
1499 for(i
=0; i
<len
; i
++) {
1500 V_VT(&name
) = VT_I4
;
1502 disp
= (void*)0xdeadbeef;
1503 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1504 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1505 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1506 if(FAILED(hres
) || !disp
)
1509 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1512 V_VT(&name
) = VT_UINT
;
1514 disp2
= (void*)0xdeadbeef;
1515 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
1516 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1517 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
1519 IDispatch_Release(disp2
);
1522 IDispatch_Release(disp
);
1525 V_VT(&name
) = VT_I4
;
1527 disp
= (void*)0xdeadbeef;
1528 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1529 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1530 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1532 V_VT(&name
) = VT_I4
;
1534 disp
= (void*)0xdeadbeef;
1535 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1536 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1537 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1539 IHTMLElementCollection_Release(col
);
1542 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1543 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
1545 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1549 hres
= IHTMLElement_get_all(elem
, &disp
);
1550 IHTMLElement_Release(elem
);
1551 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1553 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
1554 IDispatch_Release(disp
);
1557 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1558 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
)
1560 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1561 IHTMLElementCollection
*col
= NULL
;
1562 elem_type_t
*types
= NULL
;
1567 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1568 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1570 IHTMLElement2_Release(elem
);
1571 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1572 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1575 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1576 for(i
=0; i
<exlen
; i
++)
1580 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1582 HeapFree(GetProcessHeap(), 0, types
);
1585 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1586 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1591 hres
= IHTMLElement_get_innerText(elem
, &text
);
1592 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1593 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1594 wine_dbgstr_w(text
), extext
);
1595 SysFreeString(text
);
1598 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1599 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1601 IHTMLDOMChildrenCollection
*col
;
1606 hres
= IHTMLElement_put_innerText(elem
, str
);
1607 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1610 _test_elem_innertext(line
, elem
, text
);
1613 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1614 ok(col
!= NULL
, "col == NULL\n");
1616 LONG length
= 0, type
;
1619 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1620 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1621 ok(length
== 1, "length = %d\n", length
);
1623 node
= _get_child_item(line
, col
, 0);
1624 ok(node
!= NULL
, "node == NULL\n");
1626 type
= _get_node_type(line
, (IUnknown
*)node
);
1627 ok(type
== 3, "type=%d\n", type
);
1628 IHTMLDOMNode_Release(node
);
1631 IHTMLDOMChildrenCollection_Release(col
);
1636 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1637 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1639 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1643 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
1644 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
1646 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
1648 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
1650 IHTMLElement_Release(elem
);
1651 SysFreeString(html
);
1654 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1655 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
1657 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1661 html
= a2bstr(inner_html
);
1662 hres
= IHTMLElement_put_innerHTML(elem
, html
);
1663 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
1665 IHTMLElement_Release(elem
);
1666 SysFreeString(html
);
1669 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1670 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1672 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1676 html
= a2bstr(outer_html
);
1677 hres
= IHTMLElement_put_outerHTML(elem
, html
);
1678 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
1680 IHTMLElement_Release(elem
);
1681 SysFreeString(html
);
1684 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1685 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
1687 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1691 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
1692 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
1693 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
1695 IHTMLElement_Release(elem
);
1696 SysFreeString(html
);
1699 #define get_first_child(n) _get_first_child(__LINE__,n)
1700 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1702 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1703 IHTMLDOMNode
*child
= NULL
;
1706 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1707 IHTMLDOMNode_Release(node
);
1708 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1713 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1714 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1716 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1717 VARIANT_BOOL b
= 0xdead;
1720 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1721 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1722 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1724 IHTMLDOMNode_Release(node
);
1727 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1728 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1730 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1731 IHTMLDOMNode
*parent
;
1734 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1735 IHTMLDOMNode_Release(node
);
1736 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1741 #define node_get_next(u) _node_get_next(__LINE__,u)
1742 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
1744 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1748 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
1749 IHTMLDOMNode_Release(node
);
1750 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
1755 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1756 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1758 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1759 IHTMLElement
*parent
;
1762 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1763 IHTMLElement_Release(elem
);
1764 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1769 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1770 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1772 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1773 VARIANT_BOOL disabled
= 100;
1777 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1778 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1779 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1780 IHTMLElement3_Release(elem3
);
1783 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1784 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1786 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1790 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1791 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1793 IHTMLElement3_Release(elem3
);
1794 _test_elem3_get_disabled(line
, unk
, b
);
1797 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1798 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1800 VARIANT_BOOL disabled
= 100;
1803 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1804 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1805 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1807 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1810 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1811 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
1813 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
1817 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
1818 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1819 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
1820 IHTMLDOMTextNode_Release(text
);
1823 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1824 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1828 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1829 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1831 _test_select_get_disabled(line
, select
, b
);
1834 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1835 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1837 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1838 IHTMLTextContainer
*txtcont
;
1839 LONG l
= -1, l2
= -1;
1842 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1843 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1844 IHTMLElement2_Release(elem
);
1846 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1847 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1849 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1850 IHTMLTextContainer_Release(txtcont
);
1851 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
1852 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
1857 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1858 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1860 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1861 IHTMLTextContainer
*txtcont
;
1862 LONG l
= -1, l2
= -1;
1865 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1866 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1867 IHTMLElement2_Release(elem
);
1869 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1870 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1872 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1873 IHTMLTextContainer_Release(txtcont
);
1874 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
1875 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
1880 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1881 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1883 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1884 IHTMLTextContainer
*txtcont
;
1885 LONG l
= -1, l2
= -1;
1888 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1889 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1890 IHTMLElement2_Release(elem
);
1892 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1893 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1895 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1896 IHTMLTextContainer_Release(txtcont
);
1897 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
1898 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
1903 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1904 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
1906 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1907 IHTMLTextContainer
*txtcont
;
1908 LONG l
= -1, l2
= -1;
1911 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
1912 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
1914 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
1915 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1916 IHTMLElement2_Release(elem
);
1918 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1919 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1921 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
1922 IHTMLTextContainer_Release(txtcont
);
1923 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
1924 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
1927 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1928 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
1930 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1934 hres
= IHTMLImgElement_get_src(img
, &src
);
1935 IHTMLImgElement_Release(img
);
1936 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
1937 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
1941 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1942 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
1944 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1949 hres
= IHTMLImgElement_put_src(img
, tmp
);
1950 IHTMLImgElement_Release(img
);
1952 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
1954 _test_img_src(line
, unk
, src
);
1957 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1958 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
1960 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1964 hres
= IHTMLImgElement_get_alt(img
, &alt
);
1965 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1967 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
1969 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
1973 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1974 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
1976 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1981 hres
= IHTMLImgElement_put_alt(img
, tmp
);
1982 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1985 _test_img_alt(line
, unk
, alt
);
1988 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
1989 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
1991 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1995 hres
= IHTMLImgElement_get_name(img
, &sName
);
1996 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
1997 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
1998 SysFreeString(sName
);
2002 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2003 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2005 VARIANT_BOOL disabled
= 100;
2008 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
2009 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2010 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2012 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
2015 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2016 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2020 hres
= IHTMLInputElement_put_disabled(input
, b
);
2021 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2023 _test_input_get_disabled(line
, input
, b
);
2026 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2027 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2029 VARIANT_BOOL checked
= 100;
2032 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
2033 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2034 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2037 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2038 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2042 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
2043 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
2045 _test_input_get_defaultchecked(line
, input
, b
);
2048 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2049 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
2051 VARIANT_BOOL checked
= 100;
2054 hres
= IHTMLInputElement_get_checked(input
, &checked
);
2055 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2056 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
2059 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2060 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
2064 hres
= IHTMLInputElement_put_checked(input
, b
);
2065 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
2067 _test_input_get_checked(line
, input
, b
);
2070 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2071 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
2073 IHTMLInputElement
*input
;
2077 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2078 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2082 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2083 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2085 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
2087 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
2088 SysFreeString(bstr
);
2089 IHTMLInputElement_Release(input
);
2092 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2093 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
2095 IHTMLInputElement
*input
;
2099 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
2100 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
2105 hres
= IHTMLInputElement_get_value(input
, &bstr
);
2106 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2107 SysFreeString(bstr
);
2108 IHTMLInputElement_Release(input
);
2111 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2112 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
2117 hres
= IHTMLInputElement_get_src(input
, &src
);
2118 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2120 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2122 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
2126 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2127 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
2133 hres
= IHTMLInputElement_put_src(input
, tmp
);
2135 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2137 _test_input_src(line
, input
, src
);
2140 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2141 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
2143 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2144 BSTR
class = (void*)0xdeadbeef;
2147 hres
= IHTMLElement_get_className(elem
, &class);
2148 IHTMLElement_Release(elem
);
2149 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
2151 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
2153 ok_(__FILE__
,line
) (!class, "class != NULL\n");
2154 SysFreeString(class);
2157 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2158 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
2160 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2164 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
2165 IHTMLElement2_Release(elem2
);
2166 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2167 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
2170 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2171 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
2173 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
2176 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
2177 IHTMLElement2_Release(elem2
);
2178 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
2180 _test_elem_tabindex(line
, unk
, index
);
2183 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2184 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
2186 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2188 IHTMLFiltersCollection
*filters
;
2190 hres
= IHTMLElement_get_filters(elem
, &filters
);
2191 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
2192 "get_filters failed: %08x\n", hres
);
2196 IDispatchEx
*dispex
;
2198 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
2199 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2200 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
2202 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
2203 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
2204 "Could not get IDispatchEx interface: %08x\n", hres
);
2205 if(SUCCEEDED(hres
)) {
2206 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
2207 IDispatchEx_Release(dispex
);
2210 IHTMLFiltersCollection_Release(filters
);
2213 IHTMLElement_Release(elem
);
2216 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2217 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
2219 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2223 tmp
= class ? a2bstr(class) : NULL
;
2224 hres
= IHTMLElement_put_className(elem
, tmp
);
2225 IHTMLElement_Release(elem
);
2226 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
2229 _test_elem_class(line
, unk
, class);
2232 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2233 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
2235 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2236 BSTR id
= (void*)0xdeadbeef;
2239 hres
= IHTMLElement_get_id(elem
, &id
);
2240 IHTMLElement_Release(elem
);
2241 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
2244 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
2246 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
2251 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2252 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
2254 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2255 BSTR tmp
= a2bstr(new_id
);
2258 hres
= IHTMLElement_put_id(elem
, tmp
);
2259 IHTMLElement_Release(elem
);
2261 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
2263 _test_elem_id(line
, unk
, new_id
);
2266 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2267 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
2269 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2273 hres
= IHTMLElement_get_title(elem
, &title
);
2274 IHTMLElement_Release(elem
);
2275 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2277 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2279 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
2281 SysFreeString(title
);
2284 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2285 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
2287 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2291 tmp
= a2bstr(title
);
2292 hres
= IHTMLElement_put_title(elem
, tmp
);
2293 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2295 IHTMLElement_Release(elem
);
2299 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2300 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
2302 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2306 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
2307 IHTMLDOMNode_Release(node
);
2308 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2311 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
2312 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2314 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
2320 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2321 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
2323 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2327 V_VT(&var
) = VT_BSTR
;
2328 V_BSTR(&var
) = a2bstr(val
);
2330 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
2331 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
2332 IHTMLDOMNode_Release(node
);
2336 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2337 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
2339 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2343 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
2344 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
2345 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
2346 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
2348 IHTMLElement2_Release(elem
);
2351 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2352 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
2354 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2358 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
2359 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
2360 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
2362 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
2363 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
2364 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
2366 IHTMLElement2_Release(elem
);
2369 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2370 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
2372 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2373 IHTMLDocument2
*doc
;
2378 hres
= IHTMLElement_get_document(elem
, &disp
);
2379 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2380 ok(disp
!= NULL
, "disp == NULL\n");
2382 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
2383 IDispatch_Release(disp
);
2384 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
2389 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2390 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
2392 IHTMLDocument2
*doc
;
2396 hres
= IHTMLWindow2_get_document(window
, &doc
);
2397 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2398 ok(doc
!= NULL
, "disp == NULL\n");
2403 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2404 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
2406 IHTMLElement
*elem
= NULL
;
2411 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
2412 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2413 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
2418 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2419 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
2421 IHTMLDocument3
*doc3
;
2422 IHTMLDOMNode
*node
= NULL
;
2426 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2427 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
2430 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
2431 IHTMLDocument3_Release(doc3
);
2432 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
2433 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
2438 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2439 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
2441 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2442 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
2443 IHTMLDOMNode
*new_child
= NULL
;
2446 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
2447 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
2448 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2449 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2451 IHTMLDOMNode_Release(node
);
2452 IHTMLDOMNode_Release(child
);
2457 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2458 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
2460 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
2461 IHTMLDOMNode
*new_child
= NULL
;
2464 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
2465 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
2466 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
2467 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2469 IHTMLDOMNode_Release(node
);
2474 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2475 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
2477 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2478 IHTMLDOMNode
*new_node
= NULL
;
2481 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
2482 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
2483 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
2484 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2486 IHTMLDOMNode_Release(node
);
2487 IHTMLDOMNode_Release(new_node
);
2490 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2491 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
2496 hres
= IHTMLDocument2_get_title(doc
, &title
);
2497 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2498 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
2499 SysFreeString(title
);
2502 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2503 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
2508 tmp
= a2bstr(title
);
2509 hres
= IHTMLDocument2_put_title(doc
, tmp
);
2510 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
2514 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2515 static void _test_border_styles(unsigned line
, IHTMLStyle
*pStyle
, BSTR Name
)
2520 hres
= IHTMLStyle_GetIDsOfNames(pStyle
, &IID_NULL
, &Name
, 1,
2521 LOCALE_USER_DEFAULT
, &dispid
);
2522 ok_(__FILE__
,line
) (hres
== S_OK
, "GetIDsOfNames: %08x\n", hres
);
2525 DISPPARAMS params
= {NULL
,NULL
,0,0};
2526 DISPID dispidNamed
= DISPID_PROPERTYPUT
;
2531 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2532 DISPATCH_PROPERTYGET
, ¶ms
, &vDefault
, NULL
, NULL
);
2533 ok_(__FILE__
,line
) (hres
== S_OK
, "get_default. ret: %08x\n", hres
);
2536 params
.cNamedArgs
= 1;
2537 params
.rgdispidNamedArgs
= &dispidNamed
;
2538 V_VT(&arg
) = VT_BSTR
;
2539 V_BSTR(&arg
) = a2bstr("none");
2540 params
.rgvarg
= &arg
;
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
, "none. ret: %08x\n", hres
);
2546 V_VT(&arg
) = VT_BSTR
;
2547 V_BSTR(&arg
) = a2bstr("dotted");
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
, "dotted. ret: %08x\n", hres
);
2553 V_VT(&arg
) = VT_BSTR
;
2554 V_BSTR(&arg
) = a2bstr("dashed");
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
, "dashed. ret: %08x\n", hres
);
2560 V_VT(&arg
) = VT_BSTR
;
2561 V_BSTR(&arg
) = a2bstr("solid");
2562 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2563 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2564 ok_(__FILE__
,line
) (hres
== S_OK
, "solid. ret: %08x\n", hres
);
2567 V_VT(&arg
) = VT_BSTR
;
2568 V_BSTR(&arg
) = a2bstr("double");
2569 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2570 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2571 ok_(__FILE__
,line
) (hres
== S_OK
, "double. ret: %08x\n", hres
);
2574 V_VT(&arg
) = VT_BSTR
;
2575 V_BSTR(&arg
) = a2bstr("groove");
2576 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2577 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2578 ok_(__FILE__
,line
) (hres
== S_OK
, "groove. ret: %08x\n", hres
);
2581 V_VT(&arg
) = VT_BSTR
;
2582 V_BSTR(&arg
) = a2bstr("ridge");
2583 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2584 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2585 ok_(__FILE__
,line
) (hres
== S_OK
, "ridge. ret: %08x\n", hres
);
2588 V_VT(&arg
) = VT_BSTR
;
2589 V_BSTR(&arg
) = a2bstr("inset");
2590 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2591 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2592 ok_(__FILE__
,line
) (hres
== S_OK
, "inset. ret: %08x\n", hres
);
2595 V_VT(&arg
) = VT_BSTR
;
2596 V_BSTR(&arg
) = a2bstr("outset");
2597 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2598 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2599 ok_(__FILE__
,line
) (hres
== S_OK
, "outset. ret: %08x\n", hres
);
2602 V_VT(&arg
) = VT_BSTR
;
2603 V_BSTR(&arg
) = a2bstr("invalid");
2604 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2605 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2606 ok_(__FILE__
,line
) (FAILED(hres
), "invalid value passed.\n");
2609 params
.rgvarg
= &vDefault
;
2610 hres
= IHTMLStyle_Invoke(pStyle
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
2611 DISPATCH_PROPERTYPUT
, ¶ms
, &ret
, NULL
, NULL
);
2612 ok_(__FILE__
,line
) (hres
== S_OK
, "default. ret: %08x\n", hres
);
2616 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2617 static void _test_style_csstext(unsigned line
, IHTMLStyle
*style
, const char *extext
)
2619 BSTR text
= (void*)0xdeadbeef;
2622 hres
= IHTMLStyle_get_cssText(style
, &text
);
2623 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
2625 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "cssText = %s\n", wine_dbgstr_w(text
));
2627 ok_(__FILE__
,line
)(!text
, "cssText = %s\n", wine_dbgstr_w(text
));
2629 SysFreeString(text
);
2632 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2633 static void _test_style_set_csstext(unsigned line
, IHTMLStyle
*style
, const char *text
)
2639 hres
= IHTMLStyle_put_cssText(style
, tmp
);
2640 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
2644 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
2645 const elem_type_t
*elem_types
, LONG len
)
2648 VARIANT name
, index
;
2652 V_VT(&index
) = VT_EMPTY
;
2653 V_VT(&name
) = VT_BSTR
;
2654 V_BSTR(&name
) = a2bstr(n
);
2656 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2657 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2659 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
2660 IDispatch_Release(disp
);
2661 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
2665 V_VT(&index
) = VT_I4
;
2667 for(i
=0; i
<len
; i
++) {
2669 disp
= (void*)0xdeadbeef;
2670 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2671 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2672 ok(disp
!= NULL
, "disp == NULL\n");
2673 if(FAILED(hres
) || !disp
)
2676 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
2678 IDispatch_Release(disp
);
2682 disp
= (void*)0xdeadbeef;
2683 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2684 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2685 ok(disp
== NULL
, "disp != NULL\n");
2688 disp
= (void*)0xdeadbeef;
2689 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2690 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2691 ok(disp
== NULL
, "disp != NULL\n");
2694 SysFreeString(V_BSTR(&name
));
2697 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
2699 IHTMLElementCollection
*col
;
2701 IDispatch
*disp
= (void*)0xdeadbeef;
2702 VARIANT name
, index
;
2705 hres
= IHTMLDocument2_get_all(doc
, &col
);
2706 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2707 ok(col
!= NULL
, "col == NULL\n");
2708 if(FAILED(hres
) || !col
)
2711 V_VT(&index
) = VT_EMPTY
;
2712 V_VT(&name
) = VT_BSTR
;
2713 V_BSTR(&name
) = a2bstr(id
);
2715 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2716 IHTMLElementCollection_Release(col
);
2717 SysFreeString(V_BSTR(&name
));
2718 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
2719 if(!expect_success
) {
2720 ok(disp
== NULL
, "disp != NULL\n");
2724 ok(disp
!= NULL
, "disp == NULL\n");
2728 elem
= get_elem_iface((IUnknown
*)disp
);
2729 IDispatch_Release(disp
);
2734 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
2736 IHTMLDocument3
*doc3
;
2741 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
2742 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
2745 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
2747 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
2749 IHTMLDocument3_Release(doc3
);
2754 static void test_select_elem(IHTMLSelectElement
*select
)
2756 test_select_type(select
, "select-one");
2757 test_select_length(select
, 2);
2758 test_select_selidx(select
, 0);
2759 test_select_put_selidx(select
, 1);
2761 test_select_set_value(select
, "val1");
2762 test_select_value(select
, "val1");
2764 test_select_get_disabled(select
, VARIANT_FALSE
);
2765 test_select_set_disabled(select
, VARIANT_TRUE
);
2766 test_select_set_disabled(select
, VARIANT_FALSE
);
2769 static void test_create_option_elem(IHTMLDocument2
*doc
)
2771 IHTMLOptionElement
*option
;
2773 option
= create_option_elem(doc
, "test text", "test value");
2775 test_option_put_text(option
, "new text");
2776 test_option_put_value(option
, "new value");
2778 IHTMLOptionElement_Release(option
);
2781 static void test_create_img_elem(IHTMLDocument2
*doc
)
2783 IHTMLImgElement
*img
;
2785 img
= create_img_elem(doc
, 10, 15);
2788 test_img_put_width(img
, 5);
2789 test_img_put_height(img
, 20);
2791 IHTMLImgElement_Release(img
);
2795 img
= create_img_elem(doc
, -1, -1);
2798 test_img_put_width(img
, 5);
2799 test_img_put_height(img
, 20);
2801 IHTMLImgElement_Release(img
);
2805 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
2807 IHTMLBodyElement
*body
;
2808 IHTMLTxtRange
*range
;
2812 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2813 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2815 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
2816 IHTMLElement_Release(elem
);
2818 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
2819 IHTMLBodyElement_Release(body
);
2820 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
2825 static void test_txtrange(IHTMLDocument2
*doc
)
2827 IHTMLTxtRange
*body_range
, *range
, *range2
;
2828 IHTMLSelectionObject
*selection
;
2829 IDispatch
*disp_range
;
2832 body_range
= test_create_body_range(doc
);
2834 test_range_text(body_range
, "test abc 123\r\nit's text");
2836 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2837 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2839 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
2840 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2841 test_range_isequal(range
, range2
, VARIANT_TRUE
);
2843 test_range_text(range
, "test abc 123\r\nit's text");
2844 test_range_text(body_range
, "test abc 123\r\nit's text");
2846 test_range_collapse(range
, TRUE
);
2847 test_range_isequal(range
, range2
, VARIANT_FALSE
);
2848 test_range_inrange(range
, range2
, VARIANT_FALSE
);
2849 test_range_inrange(range2
, range
, VARIANT_TRUE
);
2850 IHTMLTxtRange_Release(range2
);
2852 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2853 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
2854 test_range_move(range
, characterW
, 2, 2);
2855 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2857 test_range_collapse(range
, FALSE
);
2858 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
2860 test_range_collapse(range
, FALSE
);
2861 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2862 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
2863 test_range_move(range
, characterW
, 2, 2);
2864 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
2865 test_range_moveend(range
, characterW
, -5, -5);
2866 test_range_text(range
, NULL
);
2867 test_range_moveend(range
, characterW
, 3, 3);
2868 test_range_text(range
, "c 1");
2869 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
2870 test_range_collapse(range
, TRUE
);
2871 test_range_move(range
, characterW
, 4, 4);
2872 test_range_moveend(range
, characterW
, 1, 1);
2873 test_range_text(range
, " ");
2874 test_range_move(range
, wordW
, 1, 1);
2875 test_range_moveend(range
, characterW
, 2, 2);
2876 test_range_text(range
, "ab");
2878 IHTMLTxtRange_Release(range
);
2880 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2881 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2883 test_range_text(range
, "test abc 123\r\nit's text");
2884 test_range_move(range
, characterW
, 3, 3);
2885 test_range_moveend(range
, characterW
, 1, 1);
2886 test_range_text(range
, "t");
2887 test_range_moveend(range
, characterW
, 3, 3);
2888 test_range_text(range
, "t ab");
2889 test_range_moveend(range
, characterW
, -2, -2);
2890 test_range_text(range
, "t ");
2891 test_range_move(range
, characterW
, 6, 6);
2892 test_range_moveend(range
, characterW
, 3, 3);
2893 test_range_text(range
, "123");
2894 test_range_moveend(range
, characterW
, 2, 2);
2895 test_range_text(range
, "123\r\ni");
2897 IHTMLTxtRange_Release(range
);
2899 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2900 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2902 test_range_move(range
, wordW
, 1, 1);
2903 test_range_moveend(range
, characterW
, 2, 2);
2904 test_range_text(range
, "ab");
2906 test_range_move(range
, characterW
, -2, -2);
2907 test_range_moveend(range
, characterW
, 2, 2);
2908 test_range_text(range
, "t ");
2910 test_range_move(range
, wordW
, 3, 3);
2911 test_range_move(range
, wordW
, -2, -2);
2912 test_range_moveend(range
, characterW
, 2, 2);
2913 test_range_text(range
, "ab");
2915 test_range_move(range
, characterW
, -6, -5);
2916 test_range_moveend(range
, characterW
, -1, 0);
2917 test_range_moveend(range
, characterW
, -6, 0);
2918 test_range_move(range
, characterW
, 2, 2);
2919 test_range_moveend(range
, characterW
, 2, 2);
2920 test_range_text(range
, "st");
2921 test_range_moveend(range
, characterW
, -6, -4);
2922 test_range_moveend(range
, characterW
, 2, 2);
2924 IHTMLTxtRange_Release(range
);
2926 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2927 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2929 test_range_move(range
, wordW
, 2, 2);
2930 test_range_moveend(range
, characterW
, 2, 2);
2931 test_range_text(range
, "12");
2933 test_range_move(range
, characterW
, 15, 14);
2934 test_range_move(range
, characterW
, -2, -2);
2935 test_range_moveend(range
, characterW
, 3, 2);
2936 test_range_text(range
, "t");
2937 test_range_moveend(range
, characterW
, -1, -1);
2938 test_range_text(range
, "t");
2939 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
2940 test_range_move(range
, characterW
, -2, -2);
2941 test_range_moveend(range
, characterW
, 2, 2);
2942 test_range_text(range
, "s ");
2943 test_range_move(range
, characterW
, 100, 7);
2944 test_range_move(range
, wordW
, 1, 0);
2945 test_range_move(range
, characterW
, -2, -2);
2946 test_range_moveend(range
, characterW
, 3, 2);
2947 test_range_text(range
, "t");
2949 IHTMLTxtRange_Release(range
);
2951 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2952 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2954 test_range_collapse(range
, TRUE
);
2955 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2956 test_range_put_text(range
, "word");
2957 test_range_text(body_range
, "wordabc 123\r\nit's text");
2958 test_range_text(range
, NULL
);
2959 test_range_moveend(range
, characterW
, 3, 3);
2960 test_range_text(range
, "abc");
2961 test_range_movestart(range
, characterW
, -2, -2);
2962 test_range_text(range
, "rdabc");
2963 test_range_movestart(range
, characterW
, 3, 3);
2964 test_range_text(range
, "bc");
2965 test_range_movestart(range
, characterW
, 4, 4);
2966 test_range_text(range
, NULL
);
2967 test_range_movestart(range
, characterW
, -3, -3);
2968 test_range_text(range
, "c 1");
2969 test_range_movestart(range
, characterW
, -7, -6);
2970 test_range_text(range
, "wordabc 1");
2971 test_range_movestart(range
, characterW
, 100, 22);
2972 test_range_text(range
, NULL
);
2974 IHTMLTxtRange_Release(range
);
2975 IHTMLTxtRange_Release(body_range
);
2977 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2978 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
2980 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
2981 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
2982 IHTMLSelectionObject_Release(selection
);
2984 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
2985 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
2986 IDispatch_Release(disp_range
);
2988 test_range_text(range
, NULL
);
2989 test_range_moveend(range
, characterW
, 3, 3);
2990 test_range_text(range
, "wor");
2991 test_range_parent(range
, ET_BODY
);
2992 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2993 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2994 test_range_move(range
, characterW
, 3, 3);
2995 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
2996 test_range_moveend(range
, characterW
, -4, -4);
2997 test_range_put_text(range
, "abc def ");
2998 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
2999 test_range_move(range
, wordW
, 1, 1);
3000 test_range_movestart(range
, characterW
, -1, -1);
3001 test_range_text(range
, " ");
3002 test_range_move(range
, wordW
, 1, 1);
3003 test_range_moveend(range
, characterW
, 3, 3);
3004 test_range_text(range
, "def");
3005 test_range_put_text(range
, "xyz");
3006 test_range_moveend(range
, characterW
, 1, 1);
3007 test_range_move(range
, wordW
, 1, 1);
3008 test_range_moveend(range
, characterW
, 2, 2);
3009 test_range_text(range
, "ab");
3011 IHTMLTxtRange_Release(range
);
3014 static void test_txtrange2(IHTMLDocument2
*doc
)
3016 IHTMLTxtRange
*range
;
3018 range
= test_create_body_range(doc
);
3020 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3021 test_range_move(range
, characterW
, 5, 5);
3022 test_range_moveend(range
, characterW
, 1, 1);
3023 test_range_text(range
, "2");
3024 test_range_move(range
, characterW
, -3, -3);
3025 test_range_moveend(range
, characterW
, 3, 3);
3026 test_range_text(range
, "c\r\n\r\n1");
3027 test_range_collapse(range
, VARIANT_FALSE
);
3028 test_range_moveend(range
, characterW
, 4, 4);
3029 test_range_text(range
, "23");
3030 test_range_moveend(range
, characterW
, 1, 1);
3031 test_range_text(range
, "23\r\n\r\n\r\nd");
3032 test_range_moveend(range
, characterW
, -1, -1);
3033 test_range_text(range
, "23");
3034 test_range_moveend(range
, characterW
, -1, -1);
3035 test_range_text(range
, "23");
3036 test_range_moveend(range
, characterW
, -2, -2);
3037 test_range_text(range
, "2");
3039 IHTMLTxtRange_Release(range
);
3042 static void test_compatmode(IHTMLDocument2
*doc
)
3044 IHTMLDocument5
*doc5
;
3048 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3049 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
3053 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
3054 IHTMLDocument5_Release(doc5
);
3055 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
3056 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode
));
3057 SysFreeString(mode
);
3060 static void test_location(IHTMLDocument2
*doc
)
3062 IHTMLLocation
*location
, *location2
;
3063 IHTMLWindow2
*window
;
3068 hres
= IHTMLDocument2_get_location(doc
, &location
);
3069 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3071 hres
= IHTMLDocument2_get_location(doc
, &location2
);
3072 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3074 ok(location
== location2
, "location != location2\n");
3075 IHTMLLocation_Release(location2
);
3077 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3078 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3080 hres
= IHTMLWindow2_get_location(window
, &location2
);
3081 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
3082 ok(location
== location2
, "location != location2\n");
3083 IHTMLLocation_Release(location2
);
3085 test_ifaces((IUnknown
*)location
, location_iids
);
3086 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
3088 hres
= IHTMLLocation_get_pathname(location
, &str
);
3089 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
3090 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
3092 hres
= IHTMLLocation_get_href(location
, NULL
);
3093 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
3095 hres
= IHTMLLocation_get_href(location
, &str
);
3096 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
3097 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
3099 ref
= IHTMLLocation_Release(location
);
3100 ok(!ref
, "location chould be destroyed here\n");
3103 static void test_navigator(IHTMLDocument2
*doc
)
3105 IHTMLWindow2
*window
;
3106 IOmNavigator
*navigator
, *navigator2
;
3113 static const WCHAR v40
[] = {'4','.','0'};
3115 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3116 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
3118 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
3119 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3120 ok(navigator
!= NULL
, "navigator == NULL\n");
3121 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
3123 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
3124 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
3125 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
3127 IHTMLWindow2_Release(window
);
3128 IOmNavigator_Release(navigator2
);
3130 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
3131 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
3132 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3133 SysFreeString(bstr
);
3136 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
3137 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
3138 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
3139 SysFreeString(bstr
);
3142 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
3143 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
3145 ok(!strcmp_wa(bstr
, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3147 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
3149 SysFreeString(bstr
);
3152 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
3153 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
3154 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
3155 SysFreeString(bstr
);
3157 hres
= IOmNavigator_toString(navigator
, NULL
);
3158 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
3161 hres
= IOmNavigator_toString(navigator
, &bstr
);
3162 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
3163 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
3164 SysFreeString(bstr
);
3167 hres
= ObtainUserAgentString(0, buf
, &size
);
3168 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
3171 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
3172 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
3173 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
3174 SysFreeString(bstr
);
3176 ref
= IOmNavigator_Release(navigator
);
3177 ok(!ref
, "navigator should be destroyed here\n");
3180 static void test_screen(IHTMLWindow2
*window
)
3182 IHTMLScreen
*screen
, *screen2
;
3183 IDispatchEx
*dispex
;
3188 static const WCHAR displayW
[] = {'D','I','S','P','L','A','Y',0};
3191 hres
= IHTMLWindow2_get_screen(window
, &screen
);
3192 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3193 ok(screen
!= NULL
, "screen == NULL\n");
3196 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
3197 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
3198 ok(screen2
!= NULL
, "screen == NULL\n");
3199 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
3200 IHTMLScreen_Release(screen2
);
3202 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
3203 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
3204 if(SUCCEEDED(hres
)) {
3205 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
3206 IDispatchEx_Release(dispex
);
3209 hdc
= CreateICW(displayW
, NULL
, NULL
, NULL
);
3211 exl
= GetDeviceCaps(hdc
, HORZRES
);
3213 hres
= IHTMLScreen_get_width(screen
, &l
);
3214 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3215 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
3217 exl
= GetDeviceCaps(hdc
, VERTRES
);
3219 hres
= IHTMLScreen_get_height(screen
, &l
);
3220 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3221 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3223 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
3225 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
3226 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3227 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
3231 IHTMLScreen_Release(screen
);
3234 static void test_current_style(IHTMLCurrentStyle
*current_style
)
3240 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
, "[object]");
3241 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
3243 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
3244 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3245 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", wine_dbgstr_w(str
));
3248 hres
= IHTMLCurrentStyle_get_position(current_style
, &str
);
3249 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3250 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3253 hres
= IHTMLCurrentStyle_get_fontFamily(current_style
, &str
);
3254 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3257 hres
= IHTMLCurrentStyle_get_fontStyle(current_style
, &str
);
3258 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
3259 ok(!strcmp_wa(str
, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str
));
3262 hres
= IHTMLCurrentStyle_get_backgroundImage(current_style
, &str
);
3263 ok(hres
== S_OK
, "get_backgroundImage failed: %08x\n", hres
);
3264 ok(!strcmp_wa(str
, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str
));
3267 hres
= IHTMLCurrentStyle_get_fontVariant(current_style
, &str
);
3268 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3269 ok(!strcmp_wa(str
, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str
));
3272 hres
= IHTMLCurrentStyle_get_borderTopStyle(current_style
, &str
);
3273 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
3274 ok(!strcmp_wa(str
, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str
));
3277 hres
= IHTMLCurrentStyle_get_borderRightStyle(current_style
, &str
);
3278 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
3279 ok(!strcmp_wa(str
, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str
));
3282 hres
= IHTMLCurrentStyle_get_borderBottomStyle(current_style
, &str
);
3283 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
3284 ok(!strcmp_wa(str
, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str
));
3287 hres
= IHTMLCurrentStyle_get_borderLeftStyle(current_style
, &str
);
3288 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
3289 ok(!strcmp_wa(str
, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str
));
3292 hres
= IHTMLCurrentStyle_get_textAlign(current_style
, &str
);
3293 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
3294 ok(!strcmp_wa(str
, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str
));
3297 hres
= IHTMLCurrentStyle_get_textDecoration(current_style
, &str
);
3298 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3299 ok(!strcmp_wa(str
, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str
));
3302 hres
= IHTMLCurrentStyle_get_cursor(current_style
, &str
);
3303 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
3304 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
3307 hres
= IHTMLCurrentStyle_get_backgroundRepeat(current_style
, &str
);
3308 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
3309 ok(!strcmp_wa(str
, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str
));
3312 hres
= IHTMLCurrentStyle_get_borderColor(current_style
, &str
);
3313 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
3316 hres
= IHTMLCurrentStyle_get_borderStyle(current_style
, &str
);
3317 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
3320 hres
= IHTMLCurrentStyle_get_visibility(current_style
, &str
);
3321 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3324 hres
= IHTMLCurrentStyle_get_overflow(current_style
, &str
);
3325 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
3328 hres
= IHTMLCurrentStyle_get_borderWidth(current_style
, &str
);
3329 ok(hres
== S_OK
, "get_borderWidth failed: %08x\n", hres
);
3332 hres
= IHTMLCurrentStyle_get_margin(current_style
, &str
);
3333 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3336 hres
= IHTMLCurrentStyle_get_fontWeight(current_style
, &v
);
3337 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3338 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3339 ok( V_I4(&v
) == 400, "expect 400 got (%d)\n", V_I4(&v
));
3342 hres
= IHTMLCurrentStyle_get_fontSize(current_style
, &v
);
3343 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3344 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3347 hres
= IHTMLCurrentStyle_get_left(current_style
, &v
);
3348 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3349 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3352 hres
= IHTMLCurrentStyle_get_top(current_style
, &v
);
3353 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3354 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3357 hres
= IHTMLCurrentStyle_get_width(current_style
, &v
);
3358 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3359 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3362 hres
= IHTMLCurrentStyle_get_height(current_style
, &v
);
3363 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
3364 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3367 hres
= IHTMLCurrentStyle_get_paddingLeft(current_style
, &v
);
3368 ok(hres
== S_OK
, "get_paddingLeft failed: %08x\n", hres
);
3369 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3372 hres
= IHTMLCurrentStyle_get_zIndex(current_style
, &v
);
3373 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
3374 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3375 ok( V_I4(&v
) == 1, "expect 1 got (%d)\n", V_I4(&v
));
3378 hres
= IHTMLCurrentStyle_get_verticalAlign(current_style
, &v
);
3379 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
3380 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3381 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3384 hres
= IHTMLCurrentStyle_get_marginRight(current_style
, &v
);
3385 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3386 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3389 hres
= IHTMLCurrentStyle_get_marginLeft(current_style
, &v
);
3390 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3391 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3394 hres
= IHTMLCurrentStyle_get_borderLeftWidth(current_style
, &v
);
3395 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
3396 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3400 hres
= IHTMLCurrentStyle_get_borderRightWidth(current_style
, &v
);
3401 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
3402 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3405 hres
= IHTMLCurrentStyle_get_borderBottomWidth(current_style
, &v
);
3406 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
3407 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3410 hres
= IHTMLCurrentStyle_get_borderTopWidth(current_style
, &v
);
3411 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
3412 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3415 hres
= IHTMLCurrentStyle_get_color(current_style
, &v
);
3416 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3417 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3420 hres
= IHTMLCurrentStyle_get_backgroundColor(current_style
, &v
);
3421 ok(hres
== S_OK
, "get_backgroundColor failed: %08x\n", hres
);
3422 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3425 hres
= IHTMLCurrentStyle_get_borderLeftColor(current_style
, &v
);
3426 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
3427 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3430 hres
= IHTMLCurrentStyle_get_borderTopColor(current_style
, &v
);
3431 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
3432 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3435 hres
= IHTMLCurrentStyle_get_borderRightColor(current_style
, &v
);
3436 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
3437 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3440 hres
= IHTMLCurrentStyle_get_borderBottomColor(current_style
, &v
);
3441 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
3442 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3445 hres
= IHTMLCurrentStyle_get_paddingTop(current_style
, &v
);
3446 ok(hres
== S_OK
, "get_paddingTop failed: %08x\n", hres
);
3447 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3450 hres
= IHTMLCurrentStyle_get_paddingRight(current_style
, &v
);
3451 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3452 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3455 hres
= IHTMLCurrentStyle_get_paddingBottom(current_style
, &v
);
3456 ok(hres
== S_OK
, "get_paddingRight failed: %08x\n", hres
);
3457 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3460 hres
= IHTMLCurrentStyle_get_letterSpacing(current_style
, &v
);
3461 ok(hres
== S_OK
, "get_letterSpacing failed: %08x\n", hres
);
3462 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3465 hres
= IHTMLCurrentStyle_get_marginTop(current_style
, &v
);
3466 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3467 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3470 hres
= IHTMLCurrentStyle_get_marginBottom(current_style
, &v
);
3471 ok(hres
== S_OK
, "get_marginBottom failed: %08x\n", hres
);
3472 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3475 hres
= IHTMLCurrentStyle_get_right(current_style
, &v
);
3476 ok(hres
== S_OK
, "get_Right failed: %08x\n", hres
);
3477 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3480 hres
= IHTMLCurrentStyle_get_bottom(current_style
, &v
);
3481 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
3482 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3485 hres
= IHTMLCurrentStyle_get_lineHeight(current_style
, &v
);
3486 ok(hres
== S_OK
, "get_lineHeight failed: %08x\n", hres
);
3487 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3490 hres
= IHTMLCurrentStyle_get_textIndent(current_style
, &v
);
3491 ok(hres
== S_OK
, "get_textIndent failed: %08x\n", hres
);
3492 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3496 static void test_style2(IHTMLStyle2
*style2
)
3502 str
= (void*)0xdeadbeef;
3503 hres
= IHTMLStyle2_get_position(style2
, &str
);
3504 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3505 ok(!str
, "str != NULL\n");
3507 str
= a2bstr("absolute");
3508 hres
= IHTMLStyle2_put_position(style2
, str
);
3509 ok(hres
== S_OK
, "put_position failed: %08x\n", hres
);
3513 hres
= IHTMLStyle2_get_position(style2
, &str
);
3514 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3515 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str
));
3519 V_VT(&v
) = VT_EMPTY
;
3520 hres
= IHTMLStyle2_get_right(style2
, &v
);
3521 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
3522 ok(V_VT(&v
) == VT_BSTR
, "V_VT(right)=%d\n", V_VT(&v
));
3523 ok(!V_BSTR(&v
), "V_BSTR(right) != NULL\n");
3527 V_BSTR(&v
) = a2bstr("3px");
3528 hres
= IHTMLStyle2_put_right(style2
, v
);
3529 ok(hres
== S_OK
, "put_right failed: %08x\n", hres
);
3532 V_VT(&v
) = VT_EMPTY
;
3533 hres
= IHTMLStyle2_get_right(style2
, &v
);
3534 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
3535 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3536 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3540 static void test_style3(IHTMLStyle3
*style3
)
3545 str
= (void*)0xdeadbeef;
3546 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3547 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3548 ok(!str
, "str != NULL\n");
3550 str
= a2bstr("break-word");
3551 hres
= IHTMLStyle3_put_wordWrap(style3
, str
);
3552 ok(hres
== S_OK
, "put_wordWrap failed: %08x\n", hres
);
3556 hres
= IHTMLStyle3_get_wordWrap(style3
, &str
);
3557 ok(hres
== S_OK
, "get_wordWrap failed: %08x\n", hres
);
3558 ok(!strcmp_wa(str
, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str
));
3562 static void test_style4(IHTMLStyle4
*style4
)
3568 hres
= IHTMLStyle4_get_minHeight(style4
, &vdefault
);
3569 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3572 V_BSTR(&v
) = a2bstr("10px");
3573 hres
= IHTMLStyle4_put_minHeight(style4
, v
);
3574 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3577 hres
= IHTMLStyle4_get_minHeight(style4
, &v
);
3578 ok(hres
== S_OK
, "get_minHeight failed: %08x\n", hres
);
3579 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
3580 ok( !strcmp_wa(V_BSTR(&v
), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
3582 hres
= IHTMLStyle4_put_minHeight(style4
, vdefault
);
3583 ok(hres
== S_OK
, "put_minHeight failed: %08x\n", hres
);
3584 VariantClear(&vdefault
);
3587 static void test_default_style(IHTMLStyle
*style
)
3589 IHTMLStyle2
*style2
;
3590 IHTMLStyle3
*style3
;
3591 IHTMLStyle4
*style4
;
3597 BSTR sOverflowDefault
;
3601 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
3602 test_ifaces((IUnknown
*)style
, style_iids
);
3604 test_style_csstext(style
, NULL
);
3606 hres
= IHTMLStyle_get_position(style
, &str
);
3607 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
3608 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
3611 hres
= IHTMLStyle_get_marginRight(style
, &v
);
3612 ok(hres
== S_OK
, "get_marginRight failed: %08x\n", hres
);
3613 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginRight) = %d\n", V_VT(&v
));
3614 ok(!V_BSTR(&v
), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3617 hres
= IHTMLStyle_get_marginLeft(style
, &v
);
3618 ok(hres
== S_OK
, "get_marginLeft failed: %08x\n", hres
);
3619 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginLeft) = %d\n", V_VT(&v
));
3620 ok(!V_BSTR(&v
), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3622 str
= (void*)0xdeadbeef;
3623 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
3624 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
3625 ok(!str
, "fontFamily = %s\n", wine_dbgstr_w(str
));
3627 str
= (void*)0xdeadbeef;
3628 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3629 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3630 ok(!str
, "fontWeight = %s\n", wine_dbgstr_w(str
));
3632 hres
= IHTMLStyle_get_fontWeight(style
, &sDefault
);
3633 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3635 str
= a2bstr("test");
3636 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3637 ok(hres
== E_INVALIDARG
, "put_fontWeight failed: %08x\n", hres
);
3640 str
= a2bstr("bold");
3641 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3642 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3645 str
= a2bstr("bolder");
3646 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3647 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3650 str
= a2bstr("lighter");
3651 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3652 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3655 str
= a2bstr("100");
3656 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3657 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3660 str
= a2bstr("200");
3661 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3662 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3665 str
= a2bstr("300");
3666 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3667 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3670 str
= a2bstr("400");
3671 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3672 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3675 str
= a2bstr("500");
3676 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3677 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3680 str
= a2bstr("600");
3681 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3682 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3685 str
= a2bstr("700");
3686 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3687 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3690 str
= a2bstr("800");
3691 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3692 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3695 str
= a2bstr("900");
3696 hres
= IHTMLStyle_put_fontWeight(style
, str
);
3697 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3700 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
3701 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
3702 ok(!strcmp_wa(str
, "900"), "str != style900\n");
3705 hres
= IHTMLStyle_put_fontWeight(style
, sDefault
);
3706 ok(hres
== S_OK
, "put_fontWeight failed: %08x\n", hres
);
3707 SysFreeString(sDefault
);
3710 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
3711 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
3713 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
3714 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
3716 str
= a2bstr("test");
3717 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3718 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
3721 str
= a2bstr("small-caps");
3722 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3723 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3726 str
= a2bstr("normal");
3727 hres
= IHTMLStyle_put_fontVariant(style
, str
);
3728 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3731 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
3732 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
3733 SysFreeString(sDefault
);
3735 str
= (void*)0xdeadbeef;
3736 hres
= IHTMLStyle_get_display(style
, &str
);
3737 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
3738 ok(!str
, "display = %s\n", wine_dbgstr_w(str
));
3740 str
= (void*)0xdeadbeef;
3741 hres
= IHTMLStyle_get_visibility(style
, &str
);
3742 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
3743 ok(!str
, "visibility = %s\n", wine_dbgstr_w(str
));
3746 hres
= IHTMLStyle_get_fontSize(style
, &v
);
3747 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
3748 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
3749 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3752 hres
= IHTMLStyle_get_color(style
, &v
);
3753 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
3754 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
3755 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3758 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3759 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3760 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3762 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_TRUE
);
3763 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3764 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
3766 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
3767 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
3768 ok(b
== VARIANT_TRUE
, "textDecorationUnderline = %x\n", b
);
3770 hres
= IHTMLStyle_put_textDecorationUnderline(style
, VARIANT_FALSE
);
3771 ok(hres
== S_OK
, "put_textDecorationUnderline failed: %08x\n", hres
);
3774 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3775 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3776 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3778 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_TRUE
);
3779 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3780 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
3782 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
3783 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
3784 ok(b
== VARIANT_TRUE
, "textDecorationLineThrough = %x\n", b
);
3786 hres
= IHTMLStyle_put_textDecorationLineThrough(style
, VARIANT_FALSE
);
3787 ok(hres
== S_OK
, "put_textDecorationLineThrough failed: %08x\n", hres
);
3790 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3791 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3792 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3794 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_TRUE
);
3795 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3796 ok(b
== VARIANT_FALSE
, "textDecorationNone = %x\n", b
);
3798 hres
= IHTMLStyle_get_textDecorationNone(style
, &b
);
3799 ok(hres
== S_OK
, "get_textDecorationNone failed: %08x\n", hres
);
3800 ok(b
== VARIANT_TRUE
, "textDecorationNone = %x\n", b
);
3802 hres
= IHTMLStyle_put_textDecorationNone(style
, VARIANT_FALSE
);
3803 ok(hres
== S_OK
, "put_textDecorationNone failed: %08x\n", hres
);
3806 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3807 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3808 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3810 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_TRUE
);
3811 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3812 ok(b
== VARIANT_FALSE
, "textDecorationOverline = %x\n", b
);
3814 hres
= IHTMLStyle_get_textDecorationOverline(style
, &b
);
3815 ok(hres
== S_OK
, "get_textDecorationOverline failed: %08x\n", hres
);
3816 ok(b
== VARIANT_TRUE
, "textDecorationOverline = %x\n", b
);
3818 hres
= IHTMLStyle_put_textDecorationOverline(style
, VARIANT_FALSE
);
3819 ok(hres
== S_OK
, "put_textDecorationOverline failed: %08x\n", hres
);
3822 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3823 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3824 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3826 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_TRUE
);
3827 ok(hres
== S_OK
, "put_textDecorationBlink failed: %08x\n", hres
);
3828 ok(b
== VARIANT_FALSE
, "textDecorationBlink = %x\n", b
);
3830 hres
= IHTMLStyle_get_textDecorationBlink(style
, &b
);
3831 ok(hres
== S_OK
, "get_textDecorationBlink failed: %08x\n", hres
);
3832 ok(b
== VARIANT_TRUE
, "textDecorationBlink = %x\n", b
);
3834 hres
= IHTMLStyle_put_textDecorationBlink(style
, VARIANT_FALSE
);
3835 ok(hres
== S_OK
, "textDecorationBlink failed: %08x\n", hres
);
3837 hres
= IHTMLStyle_get_textDecoration(style
, &sDefault
);
3838 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3840 str
= a2bstr("invalid");
3841 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3842 ok(hres
== E_INVALIDARG
, "put_textDecoration failed: %08x\n", hres
);
3845 str
= a2bstr("none");
3846 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3847 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3850 str
= a2bstr("underline");
3851 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3852 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3855 str
= a2bstr("overline");
3856 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3857 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3860 str
= a2bstr("line-through");
3861 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3862 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3865 str
= a2bstr("blink");
3866 hres
= IHTMLStyle_put_textDecoration(style
, str
);
3867 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3870 hres
= IHTMLStyle_get_textDecoration(style
, &str
);
3871 ok(hres
== S_OK
, "get_textDecoration failed: %08x\n", hres
);
3872 ok(!strcmp_wa(str
, "blink"), "str != blink\n");
3875 hres
= IHTMLStyle_put_textDecoration(style
, sDefault
);
3876 ok(hres
== S_OK
, "put_textDecoration failed: %08x\n", hres
);
3877 SysFreeString(sDefault
);
3879 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
3880 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
3882 hres
= IHTMLStyle_get_posWidth(style
, &f
);
3883 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
3884 ok(f
== 0.0f
, "f = %f\n", f
);
3886 V_VT(&v
) = VT_EMPTY
;
3887 hres
= IHTMLStyle_get_width(style
, &v
);
3888 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3889 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3890 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
3892 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
3893 ok(hres
== S_OK
, "put_posWidth failed: %08x\n", hres
);
3895 hres
= IHTMLStyle_get_posWidth(style
, &f
);
3896 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
3898 f
== 2.2f
, /* IE8 */
3902 V_BSTR(&v
) = a2bstr("auto");
3903 hres
= IHTMLStyle_put_width(style
, v
);
3904 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
3907 V_VT(&v
) = VT_EMPTY
;
3908 hres
= IHTMLStyle_get_width(style
, &v
);
3909 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3910 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3911 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
3916 hres
= IHTMLStyle_put_width(style
, v
);
3917 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
3919 V_VT(&v
) = VT_EMPTY
;
3920 hres
= IHTMLStyle_get_width(style
, &v
);
3921 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
3922 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3923 ok(!strcmp_wa(V_BSTR(&v
), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
3927 str
= (void*)0xdeadbeef;
3928 hres
= IHTMLStyle_get_margin(style
, &str
);
3929 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3930 ok(!str
, "margin = %s\n", wine_dbgstr_w(str
));
3933 hres
= IHTMLStyle_put_margin(style
, str
);
3934 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
3937 hres
= IHTMLStyle_get_margin(style
, &str
);
3938 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
3939 ok(!strcmp_wa(str
, "1px"), "margin = %s\n", wine_dbgstr_w(str
));
3941 hres
= IHTMLStyle_put_margin(style
, NULL
);
3942 ok(hres
== S_OK
, "put_margin failed: %08x\n", hres
);
3944 str
= (void*)0xdeadbeef;
3945 hres
= IHTMLStyle_get_marginTop(style
, &v
);
3946 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3947 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
3948 ok(!V_BSTR(&v
), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3951 V_BSTR(&v
) = a2bstr("6px");
3952 hres
= IHTMLStyle_put_marginTop(style
, v
);
3953 SysFreeString(V_BSTR(&v
));
3954 ok(hres
== S_OK
, "put_marginTop failed: %08x\n", hres
);
3956 str
= (void*)0xdeadbeef;
3957 hres
= IHTMLStyle_get_marginTop(style
, &v
);
3958 ok(hres
== S_OK
, "get_marginTop failed: %08x\n", hres
);
3959 ok(V_VT(&v
) == VT_BSTR
, "V_VT(marginTop) = %d\n", V_VT(&v
));
3960 ok(!strcmp_wa(V_BSTR(&v
), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
3963 hres
= IHTMLStyle_get_border(style
, &str
);
3964 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
3965 ok(!str
|| !*str
, "str is not empty\n");
3968 str
= a2bstr("1px");
3969 hres
= IHTMLStyle_put_border(style
, str
);
3970 ok(hres
== S_OK
, "put_border failed: %08x\n", hres
);
3973 V_VT(&v
) = VT_EMPTY
;
3974 hres
= IHTMLStyle_get_left(style
, &v
);
3975 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
3976 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
3977 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
3981 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
3982 ok(hres
== E_POINTER
, "get_posLeft failed: %08x\n", hres
);
3985 hres
= IHTMLStyle_get_posLeft(style
, &f
);
3986 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
3987 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
3989 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
3990 ok(hres
== S_OK
, "put_posLeft failed: %08x\n", hres
);
3992 hres
= IHTMLStyle_get_posLeft(style
, &f
);
3993 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
3995 f
== 4.9f
, /* IE8 */
3996 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
3998 /* Ensure left is updated correctly. */
3999 V_VT(&v
) = VT_EMPTY
;
4000 hres
= IHTMLStyle_get_left(style
, &v
);
4001 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4002 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4003 ok(!strcmp_wa(V_BSTR(&v
), "4px") ||
4004 !strcmp_wa(V_BSTR(&v
), "4.9px"), /* IE8 */
4005 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4010 V_BSTR(&v
) = a2bstr("3px");
4011 hres
= IHTMLStyle_put_left(style
, v
);
4012 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4015 hres
= IHTMLStyle_get_posLeft(style
, &f
);
4016 ok(hres
== S_OK
, "get_posLeft failed: %08x\n", hres
);
4017 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4019 V_VT(&v
) = VT_EMPTY
;
4020 hres
= IHTMLStyle_get_left(style
, &v
);
4021 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4022 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4023 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4027 hres
= IHTMLStyle_put_left(style
, v
);
4028 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
4030 V_VT(&v
) = VT_EMPTY
;
4031 hres
= IHTMLStyle_get_left(style
, &v
);
4032 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4033 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4034 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4037 V_VT(&v
) = VT_EMPTY
;
4038 hres
= IHTMLStyle_get_top(style
, &v
);
4039 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4040 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4041 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4045 hres
= IHTMLStyle_get_posTop(style
, NULL
);
4046 ok(hres
== E_POINTER
, "get_posTop failed: %08x\n", hres
);
4049 hres
= IHTMLStyle_get_posTop(style
, &f
);
4050 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4051 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4053 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
4054 ok(hres
== S_OK
, "put_posTop failed: %08x\n", hres
);
4056 hres
= IHTMLStyle_get_posTop(style
, &f
);
4057 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4059 f
== 4.9f
, /* IE8 */
4060 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4063 V_BSTR(&v
) = a2bstr("3px");
4064 hres
= IHTMLStyle_put_top(style
, v
);
4065 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4068 V_VT(&v
) = VT_EMPTY
;
4069 hres
= IHTMLStyle_get_top(style
, &v
);
4070 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4071 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4072 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4075 hres
= IHTMLStyle_get_posTop(style
, &f
);
4076 ok(hres
== S_OK
, "get_posTop failed: %08x\n", hres
);
4077 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
4080 hres
= IHTMLStyle_put_top(style
, v
);
4081 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
4083 V_VT(&v
) = VT_EMPTY
;
4084 hres
= IHTMLStyle_get_top(style
, &v
);
4085 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4086 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4087 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4090 /* Test posHeight */
4091 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
4092 ok(hres
== E_POINTER
, "get_posHeight failed: %08x\n", hres
);
4094 V_VT(&v
) = VT_EMPTY
;
4095 hres
= IHTMLStyle_get_height(style
, &v
);
4096 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4097 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4098 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4102 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4103 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4104 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
4106 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
4107 ok(hres
== S_OK
, "put_posHeight failed: %08x\n", hres
);
4109 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4110 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4112 f
== 4.9f
, /* IE8 */
4113 "expected 4.0 or 4.9 (IE8) got %f\n", f
);
4116 V_BSTR(&v
) = a2bstr("64px");
4117 hres
= IHTMLStyle_put_height(style
, v
);
4118 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
4121 V_VT(&v
) = VT_EMPTY
;
4122 hres
= IHTMLStyle_get_height(style
, &v
);
4123 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
4124 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4125 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4128 hres
= IHTMLStyle_get_posHeight(style
, &f
);
4129 ok(hres
== S_OK
, "get_posHeight failed: %08x\n", hres
);
4130 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
4132 str
= (void*)0xdeadbeef;
4133 hres
= IHTMLStyle_get_cursor(style
, &str
);
4134 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4135 ok(!str
, "get_cursor != NULL\n");
4138 str
= a2bstr("default");
4139 hres
= IHTMLStyle_put_cursor(style
, str
);
4140 ok(hres
== S_OK
, "put_cursor failed: %08x\n", hres
);
4144 hres
= IHTMLStyle_get_cursor(style
, &str
);
4145 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
4146 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str
));
4149 V_VT(&v
) = VT_EMPTY
;
4150 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4151 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
4152 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4153 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
4157 V_BSTR(&v
) = a2bstr("middle");
4158 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
4159 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
4162 V_VT(&v
) = VT_EMPTY
;
4163 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
4164 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
4165 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4166 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4169 str
= (void*)0xdeadbeef;
4170 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4171 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4172 ok(!str
, "textAlign != NULL\n");
4174 str
= a2bstr("center");
4175 hres
= IHTMLStyle_put_textAlign(style
, str
);
4176 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
4180 hres
= IHTMLStyle_get_textAlign(style
, &str
);
4181 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
4182 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4185 str
= (void*)0xdeadbeef;
4186 hres
= IHTMLStyle_get_filter(style
, &str
);
4187 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
4188 ok(!str
, "filter != NULL\n");
4190 str
= a2bstr("alpha(opacity=100)");
4191 hres
= IHTMLStyle_put_filter(style
, str
);
4192 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
4195 V_VT(&v
) = VT_EMPTY
;
4196 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4197 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4198 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4199 ok(!V_I4(&v
), "V_I4(v) != 0\n");
4203 V_BSTR(&v
) = a2bstr("1");
4204 hres
= IHTMLStyle_put_zIndex(style
, v
);
4205 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
4208 V_VT(&v
) = VT_EMPTY
;
4209 hres
= IHTMLStyle_get_zIndex(style
, &v
);
4210 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
4211 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
4212 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
4216 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
4217 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
4219 str
= a2bstr("test");
4220 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4221 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
4224 str
= a2bstr("italic");
4225 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4226 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4229 str
= a2bstr("oblique");
4230 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4231 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4234 str
= a2bstr("normal");
4235 hres
= IHTMLStyle_put_fontStyle(style
, str
);
4236 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4239 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
4240 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
4241 SysFreeString(sDefault
);
4244 hres
= IHTMLStyle_get_overflow(style
, NULL
);
4245 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
4247 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
4248 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4250 str
= a2bstr("test");
4251 hres
= IHTMLStyle_put_overflow(style
, str
);
4252 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
4255 str
= a2bstr("visible");
4256 hres
= IHTMLStyle_put_overflow(style
, str
);
4257 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4260 str
= a2bstr("scroll");
4261 hres
= IHTMLStyle_put_overflow(style
, str
);
4262 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4265 str
= a2bstr("hidden");
4266 hres
= IHTMLStyle_put_overflow(style
, str
);
4267 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4270 str
= a2bstr("auto");
4271 hres
= IHTMLStyle_put_overflow(style
, str
);
4272 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4275 hres
= IHTMLStyle_get_overflow(style
, &str
);
4276 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4277 ok(!strcmp_wa(str
, "auto"), "str=%s\n", wine_dbgstr_w(str
));
4281 hres
= IHTMLStyle_put_overflow(style
, str
);
4282 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4285 hres
= IHTMLStyle_get_overflow(style
, &str
);
4286 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
4287 ok(!str
, "str=%s\n", wine_dbgstr_w(str
));
4290 /* restore overflow default */
4291 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
4292 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
4293 SysFreeString(sOverflowDefault
);
4295 /* Attribute Tests*/
4296 hres
= IHTMLStyle_getAttribute(style
, NULL
, 1, &v
);
4297 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4299 str
= a2bstr("position");
4300 hres
= IHTMLStyle_getAttribute(style
, str
, 1, NULL
);
4301 ok(hres
== E_INVALIDARG
, "getAttribute failed: %08x\n", hres
);
4303 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4304 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4305 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4308 hres
= IHTMLStyle_setAttribute(style
, NULL
, v
, 1);
4309 ok(hres
== E_INVALIDARG
, "setAttribute failed: %08x\n", hres
);
4312 V_BSTR(&v
) = a2bstr("absolute");
4313 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4314 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4317 hres
= IHTMLStyle_getAttribute(style
, str
, 1, &v
);
4318 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
4319 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4320 ok(!strcmp_wa(V_BSTR(&v
), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4325 hres
= IHTMLStyle_setAttribute(style
, str
, v
, 1);
4326 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
4331 str
= a2bstr("borderLeftStyle");
4332 test_border_styles(style
, str
);
4335 str
= a2bstr("borderbottomstyle");
4336 test_border_styles(style
, str
);
4339 str
= a2bstr("borderrightstyle");
4340 test_border_styles(style
, str
);
4343 str
= a2bstr("bordertopstyle");
4344 test_border_styles(style
, str
);
4347 hres
= IHTMLStyle_get_borderStyle(style
, &sDefault
);
4348 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4350 str
= a2bstr("none dotted dashed solid");
4351 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4352 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4355 str
= a2bstr("none dotted dashed solid");
4356 hres
= IHTMLStyle_get_borderStyle(style
, &str
);
4357 ok(hres
== S_OK
, "get_borderStyle failed: %08x\n", hres
);
4358 ok(!strcmp_wa(str
, "none dotted dashed solid"),
4359 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v
)));
4362 str
= a2bstr("double groove ridge inset");
4363 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4364 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4367 str
= a2bstr("window-inset outset ridge inset");
4368 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4369 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4372 str
= a2bstr("window-inset");
4373 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4374 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4377 str
= a2bstr("none none none none none");
4378 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4379 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4382 str
= a2bstr("invalid none none none");
4383 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4384 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4387 str
= a2bstr("none invalid none none");
4388 hres
= IHTMLStyle_put_borderStyle(style
, str
);
4389 ok(hres
== E_INVALIDARG
, "put_borderStyle failed: %08x\n", hres
);
4392 hres
= IHTMLStyle_put_borderStyle(style
, sDefault
);
4393 ok(hres
== S_OK
, "put_borderStyle failed: %08x\n", hres
);
4394 SysFreeString(sDefault
);
4396 /* backgoundColor */
4397 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4398 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4399 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4400 ok(!V_BSTR(&v
), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4404 hres
= IHTMLStyle_get_paddingLeft(style
, &vDefault
);
4405 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4408 V_BSTR(&v
) = a2bstr("10");
4409 hres
= IHTMLStyle_put_paddingLeft(style
, v
);
4410 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4413 hres
= IHTMLStyle_get_paddingLeft(style
, &v
);
4414 ok(hres
== S_OK
, "get_paddingLeft: %08x\n", hres
);
4415 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4417 hres
= IHTMLStyle_put_paddingLeft(style
, vDefault
);
4418 ok(hres
== S_OK
, "put_paddingLeft: %08x\n", hres
);
4420 /* BackgroundRepeat */
4421 hres
= IHTMLStyle_get_backgroundRepeat(style
, &sDefault
);
4422 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4424 str
= a2bstr("invalid");
4425 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4426 ok(hres
== E_INVALIDARG
, "put_backgroundRepeat failed: %08x\n", hres
);
4429 str
= a2bstr("repeat");
4430 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4431 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4434 str
= a2bstr("no-repeat");
4435 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4436 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4439 str
= a2bstr("repeat-x");
4440 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4441 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4444 str
= a2bstr("repeat-y");
4445 hres
= IHTMLStyle_put_backgroundRepeat(style
, str
);
4446 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4449 hres
= IHTMLStyle_get_backgroundRepeat(style
, &str
);
4450 ok(hres
== S_OK
, "get_backgroundRepeat failed: %08x\n", hres
);
4451 ok(!strcmp_wa(str
, "repeat-y"), "str=%s\n", wine_dbgstr_w(str
));
4454 hres
= IHTMLStyle_put_backgroundRepeat(style
, sDefault
);
4455 ok(hres
== S_OK
, "put_backgroundRepeat failed: %08x\n", hres
);
4456 SysFreeString(sDefault
);
4459 hres
= IHTMLStyle_get_borderColor(style
, &sDefault
);
4460 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4462 str
= a2bstr("red green red blue");
4463 hres
= IHTMLStyle_put_borderColor(style
, str
);
4464 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4467 hres
= IHTMLStyle_get_borderColor(style
, &str
);
4468 ok(hres
== S_OK
, "get_borderColor failed: %08x\n", hres
);
4469 ok(!strcmp_wa(str
, "red green red blue"), "str=%s\n", wine_dbgstr_w(str
));
4472 hres
= IHTMLStyle_put_borderColor(style
, sDefault
);
4473 ok(hres
== S_OK
, "put_borderColor failed: %08x\n", hres
);
4474 SysFreeString(sDefault
);
4477 hres
= IHTMLStyle_get_borderRight(style
, &sDefault
);
4478 ok(hres
== S_OK
, "get_borderRight failed: %08x\n", hres
);
4480 str
= a2bstr("thick dotted red");
4481 hres
= IHTMLStyle_put_borderRight(style
, str
);
4482 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4485 /* IHTMLStyle_get_borderRight appears to have a bug where
4486 it returns the first letter of the color. So we check
4487 each style individually.
4490 hres
= IHTMLStyle_get_borderRightColor(style
, &v
);
4491 ok(hres
== S_OK
, "get_borderRightColor failed: %08x\n", hres
);
4492 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4496 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4497 ok(hres
== S_OK
, "get_borderRightWidth failed: %08x\n", hres
);
4498 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4501 hres
= IHTMLStyle_get_borderRightStyle(style
, &str
);
4502 ok(hres
== S_OK
, "get_borderRightStyle failed: %08x\n", hres
);
4503 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4506 hres
= IHTMLStyle_put_borderRight(style
, sDefault
);
4507 ok(hres
== S_OK
, "put_borderRight failed: %08x\n", hres
);
4508 SysFreeString(sDefault
);
4511 hres
= IHTMLStyle_get_borderTop(style
, &sDefault
);
4512 ok(hres
== S_OK
, "get_borderTop failed: %08x\n", hres
);
4514 str
= a2bstr("thick dotted red");
4515 hres
= IHTMLStyle_put_borderTop(style
, str
);
4516 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4519 /* IHTMLStyle_get_borderTop appears to have a bug where
4520 it returns the first letter of the color. So we check
4521 each style individually.
4524 hres
= IHTMLStyle_get_borderTopColor(style
, &v
);
4525 ok(hres
== S_OK
, "get_borderTopColor failed: %08x\n", hres
);
4526 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4530 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4531 ok(hres
== S_OK
, "get_borderTopWidth failed: %08x\n", hres
);
4532 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4535 hres
= IHTMLStyle_get_borderTopStyle(style
, &str
);
4536 ok(hres
== S_OK
, "get_borderTopStyle failed: %08x\n", hres
);
4537 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4540 hres
= IHTMLStyle_put_borderTop(style
, sDefault
);
4541 ok(hres
== S_OK
, "put_borderTop failed: %08x\n", hres
);
4542 SysFreeString(sDefault
);
4545 hres
= IHTMLStyle_get_borderBottom(style
, &sDefault
);
4546 ok(hres
== S_OK
, "get_borderBottom failed: %08x\n", hres
);
4548 str
= a2bstr("thick dotted red");
4549 hres
= IHTMLStyle_put_borderBottom(style
, str
);
4550 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4553 /* IHTMLStyle_get_borderBottom appears to have a bug where
4554 it returns the first letter of the color. So we check
4555 each style individually.
4558 hres
= IHTMLStyle_get_borderBottomColor(style
, &v
);
4559 ok(hres
== S_OK
, "get_borderBottomColor failed: %08x\n", hres
);
4560 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4564 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4565 ok(hres
== S_OK
, "get_borderBottomWidth failed: %08x\n", hres
);
4566 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4569 hres
= IHTMLStyle_get_borderBottomStyle(style
, &str
);
4570 ok(hres
== S_OK
, "get_borderBottomStyle failed: %08x\n", hres
);
4571 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4574 hres
= IHTMLStyle_put_borderBottom(style
, sDefault
);
4575 ok(hres
== S_OK
, "put_borderBottom failed: %08x\n", hres
);
4576 SysFreeString(sDefault
);
4579 hres
= IHTMLStyle_get_borderLeft(style
, &sDefault
);
4580 ok(hres
== S_OK
, "get_borderLeft failed: %08x\n", hres
);
4582 str
= a2bstr("thick dotted red");
4583 hres
= IHTMLStyle_put_borderLeft(style
, str
);
4584 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4587 /* IHTMLStyle_get_borderLeft appears to have a bug where
4588 it returns the first letter of the color. So we check
4589 each style individually.
4592 hres
= IHTMLStyle_get_borderLeftColor(style
, &v
);
4593 ok(hres
== S_OK
, "get_borderLeftColor failed: %08x\n", hres
);
4594 ok(!strcmp_wa(V_BSTR(&v
), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4598 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4599 ok(hres
== S_OK
, "get_borderLeftWidth failed: %08x\n", hres
);
4600 ok(!strcmp_wa(V_BSTR(&v
), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4603 hres
= IHTMLStyle_get_borderLeftStyle(style
, &str
);
4604 ok(hres
== S_OK
, "get_borderLeftStyle failed: %08x\n", hres
);
4605 ok(!strcmp_wa(str
, "dotted"), "str=%s\n", wine_dbgstr_w(str
));
4608 hres
= IHTMLStyle_put_borderLeft(style
, sDefault
);
4609 ok(hres
== S_OK
, "put_borderLeft failed: %08x\n", hres
);
4610 SysFreeString(sDefault
);
4612 /* backgroundPositionX */
4613 hres
= IHTMLStyle_get_backgroundPositionX(style
, &vDefault
);
4614 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4617 V_BSTR(&v
) = a2bstr("10px");
4618 hres
= IHTMLStyle_put_backgroundPositionX(style
, v
);
4619 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4622 hres
= IHTMLStyle_get_backgroundPositionX(style
, &v
);
4623 ok(hres
== S_OK
, "get_backgroundPositionX failed: %08x\n", hres
);
4624 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4627 hres
= IHTMLStyle_put_backgroundPositionX(style
, vDefault
);
4628 ok(hres
== S_OK
, "put_backgroundPositionX failed: %08x\n", hres
);
4629 VariantClear(&vDefault
);
4631 /* backgroundPositionY */
4632 hres
= IHTMLStyle_get_backgroundPositionY(style
, &vDefault
);
4633 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4636 V_BSTR(&v
) = a2bstr("10px");
4637 hres
= IHTMLStyle_put_backgroundPositionY(style
, v
);
4638 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4641 hres
= IHTMLStyle_get_backgroundPositionY(style
, &v
);
4642 ok(hres
== S_OK
, "get_backgroundPositionY failed: %08x\n", hres
);
4643 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4646 hres
= IHTMLStyle_put_backgroundPositionY(style
, vDefault
);
4647 ok(hres
== S_OK
, "put_backgroundPositionY failed: %08x\n", hres
);
4648 VariantClear(&vDefault
);
4650 /* borderTopWidth */
4651 hres
= IHTMLStyle_get_borderTopWidth(style
, &vDefault
);
4652 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4655 V_BSTR(&v
) = a2bstr("10px");
4656 hres
= IHTMLStyle_put_borderTopWidth(style
, v
);
4657 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4660 hres
= IHTMLStyle_get_borderTopWidth(style
, &v
);
4661 ok(hres
== S_OK
, "get_borderTopWidth: %08x\n", hres
);
4662 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4665 hres
= IHTMLStyle_put_borderTopWidth(style
, vDefault
);
4666 ok(hres
== S_OK
, "put_borderTopWidth: %08x\n", hres
);
4667 VariantClear(&vDefault
);
4669 /* borderRightWidth */
4670 hres
= IHTMLStyle_get_borderRightWidth(style
, &vDefault
);
4671 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4674 V_BSTR(&v
) = a2bstr("10");
4675 hres
= IHTMLStyle_put_borderRightWidth(style
, v
);
4676 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4679 hres
= IHTMLStyle_get_borderRightWidth(style
, &v
);
4680 ok(hres
== S_OK
, "get_borderRightWidth: %08x\n", hres
);
4681 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4684 hres
= IHTMLStyle_put_borderRightWidth(style
, vDefault
);
4685 ok(hres
== S_OK
, "put_borderRightWidth: %08x\n", hres
);
4686 VariantClear(&vDefault
);
4688 /* borderBottomWidth */
4689 hres
= IHTMLStyle_get_borderBottomWidth(style
, &vDefault
);
4690 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4693 V_BSTR(&v
) = a2bstr("10");
4694 hres
= IHTMLStyle_put_borderBottomWidth(style
, v
);
4695 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4698 hres
= IHTMLStyle_get_borderBottomWidth(style
, &v
);
4699 ok(hres
== S_OK
, "get_borderBottomWidth: %08x\n", hres
);
4700 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4703 hres
= IHTMLStyle_put_borderBottomWidth(style
, vDefault
);
4704 ok(hres
== S_OK
, "put_borderBottomWidth: %08x\n", hres
);
4705 VariantClear(&vDefault
);
4707 /* borderLeftWidth */
4708 hres
= IHTMLStyle_get_borderLeftWidth(style
, &vDefault
);
4709 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4712 V_BSTR(&v
) = a2bstr("10");
4713 hres
= IHTMLStyle_put_borderLeftWidth(style
, v
);
4714 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4717 hres
= IHTMLStyle_get_borderLeftWidth(style
, &v
);
4718 ok(hres
== S_OK
, "get_borderLeftWidth: %08x\n", hres
);
4719 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4722 hres
= IHTMLStyle_put_borderLeftWidth(style
, vDefault
);
4723 ok(hres
== S_OK
, "put_borderLeftWidth: %08x\n", hres
);
4724 VariantClear(&vDefault
);
4727 hres
= IHTMLStyle_get_wordSpacing(style
, &vDefault
);
4728 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4731 V_BSTR(&v
) = a2bstr("10");
4732 hres
= IHTMLStyle_put_wordSpacing(style
, v
);
4733 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4736 hres
= IHTMLStyle_get_wordSpacing(style
, &v
);
4737 ok(hres
== S_OK
, "get_wordSpacing: %08x\n", hres
);
4738 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4739 ok(!strcmp_wa(V_BSTR(&v
), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4742 hres
= IHTMLStyle_put_wordSpacing(style
, vDefault
);
4743 ok(hres
== S_OK
, "put_wordSpacing: %08x\n", hres
);
4744 VariantClear(&vDefault
);
4747 hres
= IHTMLStyle_get_letterSpacing(style
, &vDefault
);
4748 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4751 V_BSTR(&v
) = a2bstr("11");
4752 hres
= IHTMLStyle_put_letterSpacing(style
, v
);
4753 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4756 hres
= IHTMLStyle_get_letterSpacing(style
, &v
);
4757 ok(hres
== S_OK
, "get_letterSpacing: %08x\n", hres
);
4758 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
4759 ok(!strcmp_wa(V_BSTR(&v
), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
4762 hres
= IHTMLStyle_put_letterSpacing(style
, vDefault
);
4763 ok(hres
== S_OK
, "put_letterSpacing: %08x\n", hres
);
4764 VariantClear(&vDefault
);
4766 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
4767 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
4768 if(SUCCEEDED(hres
)) {
4769 test_style2(style2
);
4770 IHTMLStyle2_Release(style2
);
4773 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle3
, (void**)&style3
);
4774 ok(hres
== S_OK
, "Could not get IHTMLStyle3 iface: %08x\n", hres
);
4775 if(SUCCEEDED(hres
)) {
4776 test_style3(style3
);
4777 IHTMLStyle3_Release(style3
);
4780 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle4
, (void**)&style4
);
4781 ok(hres
== S_OK
, "Could not get IHTMLStyle4 iface: %08x\n", hres
);
4782 if(SUCCEEDED(hres
)) {
4783 test_style4(style4
);
4784 IHTMLStyle4_Release(style4
);
4788 static void test_set_csstext(IHTMLStyle
*style
)
4793 test_style_set_csstext(style
, "background-color: black;");
4795 hres
= IHTMLStyle_get_backgroundColor(style
, &v
);
4796 ok(hres
== S_OK
, "get_backgroundColor: %08x\n", hres
);
4797 ok(V_VT(&v
) == VT_BSTR
, "type failed: %d\n", V_VT(&v
));
4798 ok(!strcmp_wa(V_BSTR(&v
), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v
)));
4802 static void test_default_selection(IHTMLDocument2
*doc
)
4804 IHTMLSelectionObject
*selection
;
4805 IHTMLTxtRange
*range
;
4810 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4811 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
4813 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
4814 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4815 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
4818 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
4819 IHTMLSelectionObject_Release(selection
);
4820 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
4822 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
4823 IDispatch_Release(disp
);
4824 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
4826 test_range_text(range
, NULL
);
4827 IHTMLTxtRange_Release(range
);
4830 static void test_doc_elem(IHTMLDocument2
*doc
)
4832 IHTMLDocument2
*doc_node
, *owner_doc
;
4834 IHTMLDocument3
*doc3
;
4837 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4838 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
4840 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
4841 IHTMLDocument3_Release(doc3
);
4842 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
4844 test_node_name((IUnknown
*)elem
, "HTML");
4845 test_elem_tag((IUnknown
*)elem
, "HTML");
4847 doc_node
= get_doc_node(doc
);
4848 owner_doc
= get_owner_doc((IUnknown
*)elem
);
4849 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
4850 IHTMLDocument2_Release(owner_doc
);
4852 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
4853 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
4854 IHTMLDocument2_Release(doc_node
);
4856 test_elem_client_rect((IUnknown
*)elem
);
4858 IHTMLElement_Release(elem
);
4861 static void test_default_body(IHTMLBodyElement
*body
)
4868 bstr
= (void*)0xdeadbeef;
4869 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
4870 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
4871 ok(bstr
== NULL
, "bstr != NULL\n");
4873 l
= elem_get_scroll_height((IUnknown
*)body
);
4874 ok(l
!= -1, "scrollHeight == -1\n");
4875 l
= elem_get_scroll_width((IUnknown
*)body
);
4876 ok(l
!= -1, "scrollWidth == -1\n");
4877 l
= elem_get_scroll_top((IUnknown
*)body
);
4878 ok(!l
, "scrollTop = %d\n", l
);
4879 elem_get_scroll_left((IUnknown
*)body
);
4881 /* get_text tests */
4882 hres
= IHTMLBodyElement_get_text(body
, &v
);
4883 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4884 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4885 ok(bstr
== NULL
, "bstr != NULL\n");
4887 /* get_text - Invalid Text */
4889 V_BSTR(&v
) = a2bstr("Invalid");
4890 hres
= IHTMLBodyElement_put_text(body
, v
);
4891 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4895 hres
= IHTMLBodyElement_get_text(body
, &v
);
4896 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4897 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4898 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
4901 /* get_text - Valid Text */
4903 V_BSTR(&v
) = a2bstr("#FF0000");
4904 hres
= IHTMLBodyElement_put_text(body
, v
);
4905 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4909 hres
= IHTMLBodyElement_get_text(body
, &v
);
4910 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
4911 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
4912 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
4916 static void test_body_funs(IHTMLBodyElement
*body
)
4918 VARIANT vbg
, vDefaultbg
;
4921 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
4922 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4923 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
4924 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
4926 V_VT(&vbg
) = VT_BSTR
;
4927 V_BSTR(&vbg
) = a2bstr("red");
4928 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
4929 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4932 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
4933 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
4934 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
4935 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
4938 /* Restore Originial */
4939 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
4940 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
4941 VariantClear(&vDefaultbg
);
4944 static void test_window(IHTMLDocument2
*doc
)
4946 IHTMLWindow2
*window
, *window2
, *self
;
4947 IHTMLDocument2
*doc2
= NULL
;
4953 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
4954 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
4955 test_ifaces((IUnknown
*)window
, window_iids
);
4956 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
4958 hres
= IHTMLWindow2_get_document(window
, &doc2
);
4959 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4960 ok(doc2
!= NULL
, "doc2 == NULL\n");
4962 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
4963 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
4965 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
4966 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
4968 unk
= (void*)0xdeadbeef;
4969 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
4970 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
4971 ok(!unk
, "unk = %p\n", unk
);
4973 IHTMLDocument_Release(doc2
);
4975 hres
= IHTMLWindow2_get_window(window
, &window2
);
4976 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
4977 ok(window2
!= NULL
, "window2 == NULL\n");
4979 hres
= IHTMLWindow2_get_self(window
, &self
);
4980 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
4981 ok(window2
!= NULL
, "self == NULL\n");
4983 ok(self
== window2
, "self != window2\n");
4985 IHTMLWindow2_Release(window2
);
4986 IHTMLWindow2_Release(self
);
4989 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
4990 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
4991 ok(disp
== (void*)window
, "disp != window\n");
4992 IDispatch_Release(disp
);
4994 hres
= IHTMLWindow2_toString(window
, NULL
);
4995 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
4998 hres
= IHTMLWindow2_toString(window
, &str
);
4999 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5000 ok(!strcmp_wa(str
, "[object]"), "toString returned %s\n", wine_dbgstr_w(str
));
5003 test_window_name(window
, NULL
);
5004 set_window_name(window
, "test");
5005 test_window_length(window
, 0);
5006 test_screen(window
);
5008 IHTMLWindow2_Release(window
);
5011 static void test_defaults(IHTMLDocument2
*doc
)
5013 IHTMLStyleSheetsCollection
*stylesheetcol
;
5014 IHTMLCurrentStyle
*cstyle
;
5015 IHTMLBodyElement
*body
;
5016 IHTMLElement2
*elem2
;
5021 IHTMLElementCollection
*collection
;
5023 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5024 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5026 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5027 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5029 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5030 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5033 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5034 IHTMLElementCollection_Release(collection
);
5037 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5038 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5040 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5041 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5044 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5045 IHTMLElementCollection_Release(collection
);
5048 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5049 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5051 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5052 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5055 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5056 IHTMLElementCollection_Release(collection
);
5059 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5060 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5062 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5063 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5066 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5067 IHTMLElementCollection_Release(collection
);
5070 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5071 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5073 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5074 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5077 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5078 IHTMLElementCollection_Release(collection
);
5081 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5082 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5083 test_default_body(body
);
5084 test_body_funs(body
);
5085 IHTMLBodyElement_Release(body
);
5087 hres
= IHTMLElement_get_style(elem
, &style
);
5088 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5090 test_default_style(style
);
5092 test_compatmode(doc
);
5094 test_navigator(doc
);
5096 elem2
= get_elem2_iface((IUnknown
*)elem
);
5097 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5098 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5099 if(SUCCEEDED(hres
)) {
5100 test_current_style(cstyle
);
5101 IHTMLCurrentStyle_Release(cstyle
);
5103 IHTMLElement2_Release(elem2
);
5105 IHTMLElement_Release(elem
);
5107 test_set_csstext(style
);
5108 IHTMLStyle_Release(style
);
5110 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5111 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5114 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5115 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5116 ok(l
== 0, "length = %d\n", l
);
5118 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5120 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5121 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5123 test_default_selection(doc
);
5124 test_doc_title(doc
, "");
5127 static void test_tr_elem(IHTMLElement
*elem
)
5129 IHTMLElementCollection
*col
;
5133 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
5135 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
5136 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
5141 hres
= IHTMLTableRow_get_cells(row
, &col
);
5142 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
5143 ok(col
!= NULL
, "get_cells returned NULL\n");
5145 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
5146 IHTMLElementCollection_Release(col
);
5148 IHTMLTable_Release(row
);
5151 static void test_table_elem(IHTMLElement
*elem
)
5153 IHTMLElementCollection
*col
;
5158 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
5159 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
5161 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
5162 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
5167 hres
= IHTMLTable_get_rows(table
, &col
);
5168 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5169 ok(col
!= NULL
, "get_ros returned NULL\n");
5171 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
5172 IHTMLElementCollection_Release(col
);
5174 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5176 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
5177 test_elem_tag((IUnknown
*)node
, "TABLE");
5178 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
5179 IHTMLDOMNode_Release(node
);
5181 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
5182 test_elem_tag((IUnknown
*)node
, "TABLE");
5183 test_elem_all((IUnknown
*)node
, NULL
, 0);
5184 IHTMLDOMNode_Release(node
);
5186 IHTMLTable_Release(table
);
5189 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
5199 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
5200 SafeArrayAccessData(sa
, (void**)&var
);
5201 V_VT(var
) = VT_BSTR
;
5202 V_BSTR(var
) = str
= a2bstr(text
);
5203 SafeArrayUnaccessData(sa
);
5206 hres
= IHTMLDocument2_writeln(doc
, sa
);
5208 hres
= IHTMLDocument2_write(doc
, sa
);
5209 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
5212 SafeArrayDestroy(sa
);
5215 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
5217 IHTMLDocument2
*window_doc
, *elem_doc
;
5218 IHTMLFrameElement3
*frame_elem3
;
5219 IHTMLWindow2
*content_window
;
5222 content_window
= get_frame_content_window(frame_elem
);
5223 window_doc
= get_window_doc(content_window
);
5224 IHTMLWindow2_Release(content_window
);
5226 elem_doc
= get_elem_doc(frame_elem
);
5227 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
5230 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
5231 if(SUCCEEDED(hres
)) {
5232 IDispatch
*disp
= NULL
;
5234 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
5235 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
5236 ok(disp
!= NULL
, "contentDocument == NULL\n");
5237 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
5239 IDispatch_Release(disp
);
5240 IHTMLFrameElement3_Release(frame_elem3
);
5242 win_skip("IHTMLFrameElement3 not supported\n");
5246 IHTMLDocument2_Release(elem_doc
);
5247 IHTMLDocument2_Release(window_doc
);
5250 static void test_iframe_elem(IHTMLElement
*elem
)
5252 IHTMLDocument2
*content_doc
, *owner_doc
;
5253 IHTMLElementCollection
*col
;
5254 IHTMLWindow2
*content_window
;
5260 static const elem_type_t all_types
[] = {
5268 test_frame_doc((IUnknown
*)elem
, TRUE
);
5270 content_window
= get_frame_content_window((IUnknown
*)elem
);
5271 test_window_length(content_window
, 0);
5273 content_doc
= get_window_doc(content_window
);
5274 IHTMLWindow2_Release(content_window
);
5276 str
= a2bstr("text/html");
5277 V_VT(&errv
) = VT_ERROR
;
5279 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
5281 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
5282 ok(disp
!= NULL
, "disp == NULL\n");
5283 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
5284 IDispatch_Release(disp
);
5286 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head><body><br /></body>");
5287 doc_write(content_doc
, TRUE
, "</html>");
5289 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
5290 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5291 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5292 IHTMLElementCollection_Release(col
);
5294 hres
= IHTMLDocument2_close(content_doc
);
5295 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
5297 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
5298 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5300 IHTMLDocument2_Release(content_doc
);
5303 static void test_stylesheet(IDispatch
*disp
)
5305 IHTMLStyleSheetRulesCollection
*col
= NULL
;
5306 IHTMLStyleSheet
*stylesheet
;
5309 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
5310 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
5312 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
5313 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
5314 ok(col
!= NULL
, "col == NULL\n");
5316 IHTMLStyleSheetRulesCollection_Release(col
);
5317 IHTMLStyleSheet_Release(stylesheet
);
5320 static void test_stylesheets(IHTMLDocument2
*doc
)
5322 IHTMLStyleSheetsCollection
*col
= NULL
;
5327 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
5328 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5329 ok(col
!= NULL
, "col == NULL\n");
5331 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
5332 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5333 ok(len
== 1, "len=%d\n", len
);
5339 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5340 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5341 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
5342 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5343 test_stylesheet(V_DISPATCH(&res
));
5350 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
5351 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5352 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
5353 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
5356 IHTMLStyleSheetsCollection_Release(col
);
5359 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
5361 IDispatchEx
*dispex
;
5363 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
5371 static const WCHAR w0
[] = {'0',0};
5372 static const WCHAR w100
[] = {'1','0','0',0};
5374 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
5375 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
5377 bstr
= SysAllocString(w0
);
5378 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5379 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5380 SysFreeString(bstr
);
5383 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
5384 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
5385 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
5386 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
5387 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
5388 type
= get_node_type((IUnknown
*)node
);
5389 ok(type
== 3, "type=%d\n", type
);
5390 IHTMLDOMNode_Release(node
);
5393 bstr
= SysAllocString(w100
);
5394 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
5395 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
5396 SysFreeString(bstr
);
5398 IDispatchEx_Release(dispex
);
5403 static void test_elems(IHTMLDocument2
*doc
)
5405 IHTMLElementCollection
*col
;
5406 IHTMLDOMChildrenCollection
*child_col
;
5407 IHTMLElement
*elem
, *elem2
, *elem3
;
5408 IHTMLDOMNode
*node
, *node2
;
5409 IHTMLWindow2
*window
;
5413 IHTMLElementCollection
*collection
;
5414 IHTMLDocument3
*doc3
;
5417 static const elem_type_t all_types
[] = {
5443 static const elem_type_t item_types
[] = {
5449 hres
= IHTMLDocument2_get_all(doc
, &col
);
5450 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5451 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
5452 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
5453 IHTMLElementCollection_Release(col
);
5455 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5456 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5459 static const elem_type_t images_types
[] = {ET_IMG
};
5460 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5462 IHTMLElementCollection_Release(collection
);
5465 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5466 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5469 static const elem_type_t images_types
[] = {ET_A
};
5470 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
5472 IHTMLElementCollection_Release(collection
);
5475 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5476 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5479 static const elem_type_t anchor_types
[] = {ET_A
};
5480 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
5482 IHTMLElementCollection_Release(collection
);
5485 elem
= get_doc_elem(doc
);
5486 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
5487 IHTMLElement_Release(elem
);
5489 get_elem_by_id(doc
, "xxx", FALSE
);
5490 elem
= get_doc_elem_by_id(doc
, "xxx");
5491 ok(!elem
, "elem != NULL\n");
5493 elem
= get_doc_elem_by_id(doc
, "s");
5494 ok(elem
!= NULL
, "elem == NULL\n");
5496 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
5497 test_elem_attr(elem
, "xxx", NULL
);
5498 test_elem_attr(elem
, "id", "s");
5499 test_elem_class((IUnknown
*)elem
, NULL
);
5500 test_elem_set_class((IUnknown
*)elem
, "cl");
5501 test_elem_set_class((IUnknown
*)elem
, NULL
);
5502 test_elem_tabindex((IUnknown
*)elem
, 0);
5503 test_elem_set_tabindex((IUnknown
*)elem
, 1);
5504 test_elem_filters((IUnknown
*)elem
);
5506 node
= test_node_get_parent((IUnknown
*)elem
);
5507 ok(node
!= NULL
, "node == NULL\n");
5508 test_node_name((IUnknown
*)node
, "BODY");
5509 node2
= test_node_get_parent((IUnknown
*)node
);
5510 IHTMLDOMNode_Release(node
);
5511 ok(node2
!= NULL
, "node == NULL\n");
5512 test_node_name((IUnknown
*)node2
, "HTML");
5513 node
= test_node_get_parent((IUnknown
*)node2
);
5514 IHTMLDOMNode_Release(node2
);
5515 ok(node
!= NULL
, "node == NULL\n");
5518 test_node_name((IUnknown
*)node
, "#document");
5519 type
= get_node_type((IUnknown
*)node
);
5520 ok(type
== 9, "type=%d, expected 9\n", type
);
5521 node2
= test_node_get_parent((IUnknown
*)node
);
5522 IHTMLDOMNode_Release(node
);
5523 ok(node2
== NULL
, "node != NULL\n");
5526 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5527 ok(elem2
!= NULL
, "elem2 == NULL\n");
5528 test_node_name((IUnknown
*)elem2
, "BODY");
5529 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
5530 IHTMLElement_Release(elem2
);
5531 ok(elem3
!= NULL
, "elem3 == NULL\n");
5532 test_node_name((IUnknown
*)elem3
, "HTML");
5533 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
5534 IHTMLElement_Release(elem3
);
5535 ok(elem2
== NULL
, "elem2 != NULL\n");
5537 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
5538 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
5539 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
5541 test_elem_innertext(elem
, "opt1opt2");
5543 IHTMLElement_Release(elem
);
5546 elem
= get_elem_by_id(doc
, "s", TRUE
);
5548 IHTMLSelectElement
*select
;
5549 IHTMLDocument2
*doc_node
, *elem_doc
;
5551 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
5552 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
5554 test_select_elem(select
);
5556 test_elem_title((IUnknown
*)select
, NULL
);
5557 test_elem_set_title((IUnknown
*)select
, "Title");
5558 test_elem_title((IUnknown
*)select
, "Title");
5559 test_elem_offset((IUnknown
*)select
);
5561 node
= get_first_child((IUnknown
*)select
);
5562 ok(node
!= NULL
, "node == NULL\n");
5564 test_elem_type((IUnknown
*)node
, ET_OPTION
);
5565 IHTMLDOMNode_Release(node
);
5568 type
= get_node_type((IUnknown
*)select
);
5569 ok(type
== 1, "type=%d\n", type
);
5571 IHTMLSelectElement_Release(select
);
5573 elem_doc
= get_elem_doc((IUnknown
*)elem
);
5575 doc_node
= get_doc_node(doc
);
5576 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
5577 IHTMLDocument2_Release(doc_node
);
5578 IHTMLDocument2_Release(elem_doc
);
5580 IHTMLElement_Release(elem
);
5583 elem
= get_elem_by_id(doc
, "sc", TRUE
);
5585 IHTMLScriptElement
*script
;
5588 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
5589 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
5595 hres
= IHTMLScriptElement_get_type(script
, &type
);
5596 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5597 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
5598 SysFreeString(type
);
5601 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
5602 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5604 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
5605 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
5606 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
5608 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
5609 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
5612 IHTMLScriptElement_Release(script
);
5615 elem
= get_elem_by_id(doc
, "in", TRUE
);
5617 IHTMLInputElement
*input
;
5619 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
5620 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
5622 test_elem_id((IUnknown
*)elem
, "in");
5623 test_elem_put_id((IUnknown
*)elem
, "newin");
5624 test_input_get_disabled(input
, VARIANT_FALSE
);
5625 test_input_set_disabled(input
, VARIANT_TRUE
);
5626 test_input_set_disabled(input
, VARIANT_FALSE
);
5627 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
5628 test_input_get_disabled(input
, VARIANT_TRUE
);
5629 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
5630 test_input_get_disabled(input
, VARIANT_FALSE
);
5631 test_elem_client_size((IUnknown
*)elem
);
5633 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5634 test_node_put_value_str((IUnknown
*)elem
, "test");
5635 test_node_get_value_str((IUnknown
*)elem
, NULL
);
5636 test_input_value((IUnknown
*)elem
, NULL
);
5637 test_input_put_value((IUnknown
*)elem
, "test");
5638 test_input_value((IUnknown
*)elem
, NULL
);
5639 test_elem_class((IUnknown
*)elem
, "testclass");
5640 test_elem_tabindex((IUnknown
*)elem
, 2);
5641 test_elem_set_tabindex((IUnknown
*)elem
, 3);
5642 test_elem_title((IUnknown
*)elem
, "test title");
5644 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
5645 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
5646 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
5648 test_input_get_checked(input
, VARIANT_FALSE
);
5649 test_input_set_checked(input
, VARIANT_TRUE
);
5650 test_input_set_checked(input
, VARIANT_FALSE
);
5652 test_input_src(input
, NULL
);
5653 test_input_set_src(input
, "about:blank");
5655 IHTMLInputElement_Release(input
);
5656 IHTMLElement_Release(elem
);
5659 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
5661 test_img_src((IUnknown
*)elem
, "");
5662 test_img_set_src((IUnknown
*)elem
, "about:blank");
5663 test_img_alt((IUnknown
*)elem
, NULL
);
5664 test_img_set_alt((IUnknown
*)elem
, "alt test");
5665 test_img_name((IUnknown
*)elem
, "WineImg");
5666 IHTMLElement_Release(elem
);
5669 elem
= get_doc_elem_by_id(doc
, "tbl");
5670 ok(elem
!= NULL
, "elem == NULL\n");
5672 test_table_elem(elem
);
5673 IHTMLElement_Release(elem
);
5676 elem
= get_doc_elem_by_id(doc
, "row2");
5677 ok(elem
!= NULL
, "elem == NULL\n");
5680 IHTMLElement_Release(elem
);
5683 elem
= get_doc_elem_by_id(doc
, "ifr");
5684 ok(elem
!= NULL
, "elem == NULL\n");
5686 test_iframe_elem(elem
);
5687 IHTMLElement_Release(elem
);
5690 elem
= get_elem_by_id(doc
, "a", TRUE
);
5692 test_anchor_href((IUnknown
*)elem
, "http://test/");
5693 IHTMLElement_Release(elem
);
5696 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5697 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5699 node
= get_first_child((IUnknown
*)elem
);
5700 ok(node
!= NULL
, "node == NULL\n");
5702 test_ifaces((IUnknown
*)node
, text_iids
);
5703 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5705 node2
= get_first_child((IUnknown
*)node
);
5706 ok(!node2
, "node2 != NULL\n");
5708 type
= get_node_type((IUnknown
*)node
);
5709 ok(type
== 3, "type=%d\n", type
);
5711 test_node_get_value_str((IUnknown
*)node
, "text test");
5712 test_node_put_value_str((IUnknown
*)elem
, "test text");
5713 test_node_get_value_str((IUnknown
*)node
, "text test");
5715 IHTMLDOMNode_Release(node
);
5718 child_col
= get_child_nodes((IUnknown
*)elem
);
5719 ok(child_col
!= NULL
, "child_coll == NULL\n");
5723 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
5725 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
5726 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5727 ok(length
, "length=0\n");
5730 node
= get_child_item(child_col
, 0);
5731 ok(node
!= NULL
, "node == NULL\n");
5733 type
= get_node_type((IUnknown
*)node
);
5734 ok(type
== 3, "type=%d\n", type
);
5735 node2
= node_get_next((IUnknown
*)node
);
5736 IHTMLDOMNode_Release(node
);
5739 node
= get_child_item(child_col
, 1);
5740 ok(node
!= NULL
, "node == NULL\n");
5742 type
= get_node_type((IUnknown
*)node
);
5743 ok(type
== 8, "type=%d\n", type
);
5745 test_elem_id((IUnknown
*)node
, NULL
);
5746 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
5747 IHTMLDOMNode_Release(node2
);
5748 IHTMLDOMNode_Release(node
);
5751 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
5752 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5754 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
5755 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
5757 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
5758 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5760 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
5761 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5763 test_child_col_disp(child_col
);
5765 IHTMLDOMChildrenCollection_Release(child_col
);
5768 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5769 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
5770 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
5772 IHTMLElement_Release(elem
);
5774 test_stylesheets(doc
);
5775 test_create_option_elem(doc
);
5776 test_create_img_elem(doc
);
5778 elem
= get_doc_elem_by_id(doc
, "tbl");
5779 ok(elem
!= NULL
, "elem = NULL\n");
5780 test_elem_set_innertext(elem
, "inner text");
5781 IHTMLElement_Release(elem
);
5783 test_doc_title(doc
, "test");
5784 test_doc_set_title(doc
, "test title");
5785 test_doc_title(doc
, "test title");
5788 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5789 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5792 IDispatchEx
*dispex
;
5793 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
5794 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
5798 BSTR str
= a2bstr("Testing");
5799 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
5800 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
5801 ok(pid
!= -1, "pid == -1\n");
5803 IDispatchEx_Release(dispex
);
5806 IDispatch_Release(disp
);
5808 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5809 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5811 str
= a2bstr("img");
5812 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
5813 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
5817 static const elem_type_t img_types
[] = { ET_IMG
};
5819 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
5820 IHTMLElementCollection_Release(col
);
5823 elem
= get_doc_elem_by_id(doc
, "y");
5824 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
5825 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
5826 test_elem_set_innerhtml((IUnknown
*)elem
, "");
5827 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
5828 node
= node_get_next((IUnknown
*)elem
);
5829 ok(!node
, "node = %p\n", node
);
5831 elem2
= get_doc_elem_by_id(doc
, "x");
5832 test_elem_tag((IUnknown
*)elem2
, "A");
5833 node
= node_get_next((IUnknown
*)elem2
);
5834 IHTMLDOMNode_Release(node
);
5835 IHTMLElement_Release(elem2
);
5836 IHTMLElement_Release(elem
);
5838 IHTMLDocument3_Release(doc3
);
5840 window
= get_doc_window(doc
);
5841 test_window_name(window
, NULL
);
5842 set_window_name(window
, "test name");
5843 test_window_length(window
, 1);
5844 IHTMLWindow2_Release(window
);
5847 static void test_elems2(IHTMLDocument2
*doc
)
5849 IHTMLElement
*elem
, *elem2
;
5851 static const elem_type_t outer_types
[] = {
5856 elem
= get_doc_elem_by_id(doc
, "divid");
5858 test_elem_set_innerhtml((IUnknown
*)elem
, "<div id=\"innerid\"></div>");
5859 elem2
= get_doc_elem_by_id(doc
, "innerid");
5860 ok(elem2
!= NULL
, "elem2 == NULL\n");
5861 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5862 test_elem_all((IUnknown
*)elem
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
5863 IHTMLElement_Release(elem2
);
5865 elem2
= get_doc_elem_by_id(doc
, "aid");
5866 ok(elem2
!= NULL
, "elem2 == NULL\n");
5867 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
5868 test_elem_all((IUnknown
*)elem
, outer_types
, 1);
5869 IHTMLElement_Release(elem2
);
5871 IHTMLElement_Release(elem
);
5874 static void test_create_elems(IHTMLDocument2
*doc
)
5876 IHTMLElement
*elem
, *body
, *elem2
;
5877 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
5878 IHTMLDocument5
*doc5
;
5885 static const elem_type_t types1
[] = { ET_TESTG
};
5887 elem
= test_create_elem(doc
, "TEST");
5888 test_elem_tag((IUnknown
*)elem
, "TEST");
5889 type
= get_node_type((IUnknown
*)elem
);
5890 ok(type
== 1, "type=%d\n", type
);
5891 test_ifaces((IUnknown
*)elem
, elem_iids
);
5892 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
5894 hres
= IHTMLDocument2_get_body(doc
, &body
);
5895 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5896 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5898 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
5899 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
5900 elem2
= get_elem_iface((IUnknown
*)node
);
5901 IHTMLElement_Release(elem2
);
5903 hres
= IHTMLElement_get_all(body
, &disp
);
5904 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5905 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
5906 IDispatch_Release(disp
);
5908 test_node_remove_child((IUnknown
*)body
, node
);
5910 hres
= IHTMLElement_get_all(body
, &disp
);
5911 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5912 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
5913 IDispatch_Release(disp
);
5914 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
5916 IHTMLElement_Release(elem
);
5917 IHTMLDOMNode_Release(node
);
5919 node
= test_create_text(doc
, "test");
5920 test_ifaces((IUnknown
*)node
, text_iids
);
5921 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
5922 test_text_length((IUnknown
*)node
, 4);
5924 V_VT(&var
) = VT_NULL
;
5925 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5926 IHTMLDOMNode_Release(node
);
5928 node
= test_create_text(doc
, "insert ");
5930 V_VT(&var
) = VT_DISPATCH
;
5931 V_DISPATCH(&var
) = (IDispatch
*)node2
;
5932 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
5933 IHTMLDOMNode_Release(node
);
5934 IHTMLDOMNode_Release(node2
);
5935 IHTMLDOMNode_Release(node3
);
5937 test_elem_innertext(body
, "insert test");
5938 test_elem_innerhtml((IUnknown
*)body
, "insert test");
5940 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
5943 str
= a2bstr("testing");
5944 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
5946 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
5949 type
= get_node_type((IUnknown
*)comment
);
5950 ok(type
== 8, "type=%d, expected 8\n", type
);
5952 test_node_get_value_str((IUnknown
*)comment
, "testing");
5953 test_elem_title((IUnknown
*)comment
, NULL
);
5954 test_elem_set_title((IUnknown
*)comment
, "comment title");
5955 test_elem_title((IUnknown
*)comment
, "comment title");
5956 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
5957 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
5959 IHTMLDOMNode_Release(comment
);
5962 IHTMLDocument5_Release(doc5
);
5965 IHTMLElement_Release(body
);
5968 static void test_null_write(IHTMLDocument2
*doc
)
5972 doc_write(doc
, FALSE
, NULL
);
5973 doc_write(doc
, TRUE
, NULL
);
5975 hres
= IHTMLDocument2_write(doc
, NULL
);
5977 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
5979 hres
= IHTMLDocument2_writeln(doc
, NULL
);
5981 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
5984 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
5986 IOleCommandTarget
*cmdtrg
;
5989 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
5990 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
5992 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
5993 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
5995 IOleCommandTarget_Release(cmdtrg
);
5998 static void test_indent(IHTMLDocument2
*doc
)
6000 IHTMLElementCollection
*col
;
6001 IHTMLTxtRange
*range
;
6004 static const elem_type_t all_types
[] = {
6013 static const elem_type_t indent_types
[] = {
6024 hres
= IHTMLDocument2_get_all(doc
, &col
);
6025 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6026 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6027 IHTMLElementCollection_Release(col
);
6029 range
= test_create_body_range(doc
);
6030 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
6031 IHTMLTxtRange_Release(range
);
6033 hres
= IHTMLDocument2_get_all(doc
, &col
);
6034 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6035 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
6036 IHTMLElementCollection_Release(col
);
6039 static void test_cond_comment(IHTMLDocument2
*doc
)
6041 IHTMLElementCollection
*col
;
6044 static const elem_type_t all_types
[] = {
6052 hres
= IHTMLDocument2_get_all(doc
, &col
);
6053 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6054 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6055 IHTMLElementCollection_Release(col
);
6058 static void test_frame(IDispatch
*disp
, const char *exp_id
)
6060 IHTMLWindow2
*frame2
, *parent
, *top
;
6061 IHTMLDocument2
*parent_doc
, *top_doc
;
6062 IHTMLWindow4
*frame
;
6063 IHTMLFrameBase
*frame_elem
;
6066 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
6067 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
6071 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
6072 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
6073 IHTMLWindow4_Release(frame
);
6077 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
6078 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
6079 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
6080 IHTMLElement_Release(frame_elem
);
6082 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
6083 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
6087 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
6088 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
6090 IHTMLWindow2_Release(frame2
);
6094 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
6095 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6096 IHTMLWindow2_Release(parent
);
6098 IHTMLWindow2_Release(frame2
);
6102 test_doc_title(parent_doc
, "frameset test");
6103 IHTMLDocument2_Release(parent_doc
);
6106 hres
= IHTMLWindow2_get_top(frame2
, &top
);
6107 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
6108 IHTMLWindow2_Release(frame2
);
6112 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
6113 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
6114 IHTMLWindow2_Release(top
);
6118 test_doc_title(top_doc
, "frameset test");
6119 IHTMLDocument2_Release(top_doc
);
6122 static void test_frameset(IHTMLDocument2
*doc
)
6124 IHTMLWindow2
*window
;
6125 IHTMLFramesCollection2
*frames
;
6127 IHTMLFrameBase
*fbase
;
6129 VARIANT index_var
, result_var
;
6133 window
= get_doc_window(doc
);
6135 /* test using IHTMLFramesCollection object */
6137 hres
= IHTMLWindow2_get_frames(window
, &frames
);
6138 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
6139 IHTMLWindow2_Release(window
);
6143 /* test result length */
6144 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
6145 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
6146 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
6148 /* test first frame */
6149 V_VT(&index_var
) = VT_I4
;
6150 V_I4(&index_var
) = 0;
6151 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6152 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6153 if(SUCCEEDED(hres
)) {
6154 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6155 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6157 VariantClear(&result_var
);
6159 /* test second frame */
6160 V_I4(&index_var
) = 1;
6161 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6162 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6163 if(SUCCEEDED(hres
)) {
6164 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6165 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6167 VariantClear(&result_var
);
6169 /* fail on next frame */
6170 V_I4(&index_var
) = 3;
6171 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6172 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
6173 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6174 VariantClear(&result_var
);
6176 /* string argument (element id lookup) */
6177 V_VT(&index_var
) = VT_BSTR
;
6178 V_BSTR(&index_var
) = a2bstr("fr1");
6179 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6180 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
6181 if(SUCCEEDED(hres
)) {
6182 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6183 test_frame(V_DISPATCH(&result_var
), "fr1");
6185 VariantClear(&result_var
);
6186 VariantClear(&index_var
);
6188 /* invalid argument */
6189 V_VT(&index_var
) = VT_BOOL
;
6190 V_BOOL(&index_var
) = VARIANT_TRUE
;
6191 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
6192 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
6193 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6194 VariantClear(&result_var
);
6196 IHTMLFramesCollection2_Release(frames
);
6198 /* test using IHTMLWindow2 inheritance */
6200 /* test result length */
6201 hres
= IHTMLWindow2_get_length(window
, &length
);
6202 ok(hres
== S_OK
, "IHTMLWindow2_get_length failed: 0x%08x\n", hres
);
6203 ok(length
== 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length
);
6205 /* test first frame */
6206 V_VT(&index_var
) = VT_I4
;
6207 V_I4(&index_var
) = 0;
6208 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6209 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6210 if(SUCCEEDED(hres
)) {
6211 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6212 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
6214 VariantClear(&result_var
);
6216 /* test second frame */
6217 V_I4(&index_var
) = 1;
6218 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6219 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6220 if(SUCCEEDED(hres
)) {
6221 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6222 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6224 VariantClear(&result_var
);
6226 /* fail on next frame */
6227 V_I4(&index_var
) = 3;
6228 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6229 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLWindow2_item should have"
6230 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
6231 VariantClear(&result_var
);
6233 /* string argument (element id lookup) */
6234 V_VT(&index_var
) = VT_BSTR
;
6235 V_BSTR(&index_var
) = a2bstr("fr2");
6236 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6237 ok(hres
== S_OK
, "IHTMLWindow2_item failed: 0x%08x\n", hres
);
6238 if(SUCCEEDED(hres
)) {
6239 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
6240 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
6242 VariantClear(&result_var
);
6243 VariantClear(&index_var
);
6245 /* invalid argument */
6246 V_VT(&index_var
) = VT_BOOL
;
6247 V_BOOL(&index_var
) = VARIANT_TRUE
;
6248 hres
= IHTMLWindow2_item(window
, &index_var
, &result_var
);
6249 ok(hres
== E_INVALIDARG
, "IHTMLWindow2_item should have"
6250 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
6251 VariantClear(&result_var
);
6253 /* getElementById with node name attributes */
6254 elem
= get_doc_elem_by_id(doc
, "nm1");
6255 test_elem_id((IUnknown
*)elem
, "fr1");
6257 /* get/put scrolling */
6258 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6259 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6261 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6262 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6263 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6267 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6268 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6271 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6272 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6273 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6276 str
= a2bstr("junk");
6277 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6278 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6279 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6282 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6283 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6284 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6288 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6289 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6290 ok(!strcmp_wa(str
, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str
));
6293 IHTMLFrameBase_Release(fbase
);
6294 IHTMLElement_Release(elem
);
6296 /* get_name with no name attr */
6297 elem
= get_doc_elem_by_id(doc
, "fr3");
6298 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6299 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6301 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6302 ok(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6303 ok(str
== NULL
, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str
));
6306 IHTMLFrameBase_Release(fbase
);
6307 IHTMLElement_Release(elem
);
6310 static IHTMLDocument2
*notif_doc
;
6311 static BOOL doc_complete
;
6313 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
6314 REFIID riid
, void**ppv
)
6316 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
6321 ok(0, "unexpected call\n");
6322 return E_NOINTERFACE
;
6325 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
6330 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
6335 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
6337 if(dispID
== DISPID_READYSTATE
){
6341 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
6342 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
6344 if(!strcmp_wa(state
, "complete"))
6345 doc_complete
= TRUE
;
6347 SysFreeString(state
);
6353 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
6355 ok(0, "unexpected call\n");
6359 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
6360 PropertyNotifySink_QueryInterface
,
6361 PropertyNotifySink_AddRef
,
6362 PropertyNotifySink_Release
,
6363 PropertyNotifySink_OnChanged
,
6364 PropertyNotifySink_OnRequestEdit
6367 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
6369 static IHTMLDocument2
*create_doc_with_string(const char *str
)
6371 IPersistStreamInit
*init
;
6373 IHTMLDocument2
*doc
;
6377 notif_doc
= doc
= create_document();
6381 doc_complete
= FALSE
;
6383 mem
= GlobalAlloc(0, len
);
6384 memcpy(mem
, str
, len
);
6385 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
6387 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
6389 IPersistStreamInit_Load(init
, stream
);
6390 IPersistStreamInit_Release(init
);
6391 IStream_Release(stream
);
6396 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
6398 IConnectionPointContainer
*container
;
6399 IConnectionPoint
*cp
;
6403 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
6404 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
6406 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
6407 IConnectionPointContainer_Release(container
);
6408 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
6410 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
6411 IConnectionPoint_Release(cp
);
6412 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
6415 typedef void (*domtest_t
)(IHTMLDocument2
*);
6417 static void run_domtest(const char *str
, domtest_t test
)
6419 IHTMLDocument2
*doc
;
6423 doc
= create_doc_with_string(str
);
6427 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
6429 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
6430 TranslateMessage(&msg
);
6431 DispatchMessage(&msg
);
6436 ref
= IHTMLDocument2_Release(doc
);
6438 ref
== 1, /* Vista */
6446 run_domtest(doc_str1
, test_doc_elem
);
6447 run_domtest(doc_str1
, test_get_set_attr
);
6448 run_domtest(range_test_str
, test_txtrange
);
6449 run_domtest(range_test2_str
, test_txtrange2
);
6450 if (winetest_interactive
|| ! is_ie_hardened()) {
6451 run_domtest(elem_test_str
, test_elems
);
6453 skip("IE running in Enhanced Security Configuration\n");
6455 run_domtest(elem_test2_str
, test_elems2
);
6456 run_domtest(doc_blank
, test_create_elems
);
6457 run_domtest(doc_blank
, test_defaults
);
6458 run_domtest(doc_blank
, test_null_write
);
6459 run_domtest(indent_test_str
, test_indent
);
6460 run_domtest(cond_comment_str
, test_cond_comment
);
6461 run_domtest(frameset_str
, test_frameset
);