2 * Copyright 2007 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>
35 static const char doc_blank
[] = "<html></html>";
36 static const char doc_str1
[] = "<html><body>test</body></html>";
37 static const char range_test_str
[] =
38 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
39 static const char range_test2_str
[] =
40 "<html><body>abc<hr />123<br /><hr />def</body></html>";
41 static const char elem_test_str
[] =
42 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
43 "<body>text test<!-- a comment -->"
44 "<a href=\"http://test\" name=\"x\">link</a>"
46 "<select id=\"s\"><option id=\"x\">opt1</option><option id=\"y\">opt2</option></select>"
47 "<textarea id=\"X\">text text</textarea>"
48 "<table><tbody></tbody></table>"
49 "<script id=\"sc\" type=\"text/javascript\"></script>"
53 static const char indent_test_str
[] =
54 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
56 static const WCHAR noneW
[] = {'N','o','n','e',0};
58 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
59 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
60 static WCHAR wordW
[] = {'w','o','r','d',0};
62 static const WCHAR text_javascriptW
[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0};
64 static const WCHAR idW
[] = {'i','d',0};
89 static REFIID
const none_iids
[] = {
94 static REFIID
const elem_iids
[] = {
100 &IID_IConnectionPointContainer
,
104 static REFIID
const body_iids
[] = {
109 &IID_IHTMLTextContainer
,
110 &IID_IHTMLBodyElement
,
112 &IID_IConnectionPointContainer
,
116 static REFIID
const anchor_iids
[] = {
121 &IID_IHTMLAnchorElement
,
123 &IID_IConnectionPointContainer
,
127 static REFIID
const input_iids
[] = {
132 &IID_IHTMLInputElement
,
133 &IID_IHTMLInputTextElement
,
135 &IID_IConnectionPointContainer
,
139 static REFIID
const select_iids
[] = {
144 &IID_IHTMLSelectElement
,
146 &IID_IConnectionPointContainer
,
150 static REFIID
const textarea_iids
[] = {
155 &IID_IHTMLTextAreaElement
,
157 &IID_IConnectionPointContainer
,
161 static REFIID
const option_iids
[] = {
166 &IID_IHTMLOptionElement
,
168 &IID_IConnectionPointContainer
,
172 static REFIID
const table_iids
[] = {
179 &IID_IConnectionPointContainer
,
183 static REFIID
const script_iids
[] = {
188 &IID_IHTMLScriptElement
,
190 &IID_IConnectionPointContainer
,
194 static REFIID
const text_iids
[] = {
197 &IID_IHTMLDOMTextNode
,
201 static REFIID
const location_iids
[] = {
207 static REFIID
const window_iids
[] = {
215 static REFIID
const comment_iids
[] = {
220 &IID_IHTMLCommentElement
,
222 &IID_IConnectionPointContainer
,
226 static REFIID
const img_iids
[] = {
232 &IID_IHTMLImgElement
,
233 &IID_IConnectionPointContainer
,
243 static const elem_type_info_t elem_type_infos
[] = {
244 {"", none_iids
, NULL
},
245 {"HTML", elem_iids
, NULL
},
246 {"HEAD", elem_iids
, NULL
},
247 {"TITLE", elem_iids
, NULL
},
248 {"BODY", body_iids
, NULL
},
249 {"A", anchor_iids
, NULL
},
250 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
251 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
252 {"TEXTAREA", textarea_iids
, NULL
},
253 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
254 {"STYLE", elem_iids
, NULL
},
255 {"BLOCKQUOTE",elem_iids
, NULL
},
256 {"P", elem_iids
, NULL
},
257 {"BR", elem_iids
, NULL
},
258 {"TABLE", table_iids
, NULL
},
259 {"TBODY", elem_iids
, NULL
},
260 {"SCRIPT", script_iids
, NULL
},
261 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
262 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
263 {"IMG", img_iids
, &DIID_DispHTMLImg
}
266 static const char *dbgstr_w(LPCWSTR str
)
268 static char buf
[512];
271 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
275 static const char *dbgstr_guid(REFIID riid
)
279 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
280 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
281 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
282 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
287 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
290 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
291 return lstrcmpW(strw
, buf
);
294 static BSTR
a2bstr(const char *str
)
299 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
300 ret
= SysAllocStringLen(NULL
, len
);
301 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
306 static IHTMLDocument2
*create_document(void)
311 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
312 &IID_IHTMLDocument2
, (void**)&doc
);
313 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
318 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
319 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
321 const IID
* const *piid
;
325 for(piid
= iids
; *piid
; piid
++) {
326 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
327 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
329 IUnknown_Release(unk
);
333 #define test_disp(u,id) _test_disp(__LINE__,u,id)
334 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
)
341 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
342 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
347 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
348 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
349 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
351 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
352 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
354 if(SUCCEEDED(hres
)) {
357 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
358 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
359 ok_(__FILE__
,line
) (IsEqualGUID(&type_attr
->guid
, diid
), "unexpected guid %s\n", dbgstr_guid(&type_attr
->guid
));
361 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
362 ITypeInfo_Release(typeinfo
);
365 IDispatchEx_Release(dispex
);
368 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
369 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
374 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
375 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement: %08x\n", hres
);
379 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
380 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
385 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
386 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement2: %08x\n", hres
);
390 #define get_node_iface(u) _get_node_iface(__LINE__,u)
391 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
396 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
397 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLDOMNode: %08x\n", hres
);
401 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
402 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
404 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
408 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
409 IHTMLDOMNode_Release(node
);
410 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
411 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", dbgstr_w(name
), exname
);
416 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
417 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
419 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
423 hres
= IHTMLElement_get_tagName(elem
, &tag
);
424 IHTMLElement_Release(elem
);
425 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
426 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", dbgstr_w(tag
), extag
);
431 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
432 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
434 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
435 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
437 if(elem_type_infos
[type
].dispiid
)
438 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
);
441 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
442 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, LPCWSTR name
, LPCWSTR exval
)
450 tmp
= SysAllocString(name
);
451 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
453 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
456 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
457 ok_(__FILE__
,line
) (!lstrcmpW(exval
, V_BSTR(&value
)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value
)));
459 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
462 VariantClear(&value
);
465 static void test_doc_elem(IHTMLDocument2
*doc
)
468 IHTMLDocument3
*doc3
;
471 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
472 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
474 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
475 IHTMLDocument3_Release(doc3
);
476 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
478 test_node_name((IUnknown
*)elem
, "HTML");
479 test_elem_tag((IUnknown
*)elem
, "HTML");
481 IHTMLElement_Release(elem
);
484 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
485 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
488 IHTMLDocument3
*doc3
;
491 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
492 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
493 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
494 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
495 IHTMLDocument3_Release(doc3
);
500 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
501 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
506 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
507 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
508 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", dbgstr_w(bstr
));
512 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
513 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
519 hres
= IHTMLOptionElement_put_text(option
, bstr
);
521 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
523 _test_option_text(line
, option
, text
);
526 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
527 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
532 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
533 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
534 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", dbgstr_w(bstr
));
538 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
539 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
544 bstr
= a2bstr(value
);
545 hres
= IHTMLOptionElement_put_value(option
, bstr
);
547 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
549 _test_option_value(line
, option
, value
);
552 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
553 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
554 const char *txt
, const char *val
)
556 IHTMLOptionElementFactory
*factory
;
557 IHTMLOptionElement
*option
;
558 IHTMLWindow2
*window
;
559 VARIANT text
, value
, empty
;
562 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
563 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
565 hres
= IHTMLWindow2_get_Option(window
, &factory
);
566 IHTMLWindow2_Release(window
);
567 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
569 V_VT(&text
) = VT_BSTR
;
570 V_BSTR(&text
) = a2bstr(txt
);
571 V_VT(&value
) = VT_BSTR
;
572 V_BSTR(&value
) = a2bstr(val
);
573 V_VT(&empty
) = VT_EMPTY
;
575 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
576 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
578 IHTMLOptionElementFactory_Release(factory
);
580 VariantClear(&value
);
582 _test_option_text(line
, option
, txt
);
583 _test_option_value(line
, option
, val
);
588 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
589 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, long length
)
591 long len
= 0xdeadbeef;
594 hres
= IHTMLSelectElement_get_length(select
, &len
);
595 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
596 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
599 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
600 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
602 long idx
= 0xdeadbeef;
605 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
606 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
607 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
610 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
611 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
615 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
616 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
617 _test_select_selidx(line
, select
, index
);
620 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
621 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
626 hres
= IHTMLTxtRange_get_text(range
, &text
);
627 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
630 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
631 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text
), extext
);
633 ok_(__FILE__
, line
) (text
== NULL
, "text=\"%s\", expected NULL\n", dbgstr_w(text
));
640 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
641 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
645 hres
= IHTMLTxtRange_collapse(range
, b
);
646 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
647 _test_range_text(line
, range
, NULL
);
650 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
651 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
652 VARIANT_BOOL exb
, const char *extext
)
654 VARIANT_BOOL b
= 0xe0e0;
657 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
658 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
659 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
660 _test_range_text(line
, range
, extext
);
663 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
664 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
669 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
670 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
671 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
672 _test_range_text(line
, range
, NULL
);
675 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
676 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
677 LPWSTR unit
, long cnt
, long excnt
)
682 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
683 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
684 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
687 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
688 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
693 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
694 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
695 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
698 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
699 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
702 BSTR bstr
= a2bstr(text
);
704 hres
= IHTMLTxtRange_put_text(range
, bstr
);
705 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
707 _test_range_text(line
, range
, NULL
);
710 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
711 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
717 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
718 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
719 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
722 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
723 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
729 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
730 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
731 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
734 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
735 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
736 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
739 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
740 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
744 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
745 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
750 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
751 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
753 _test_elem_type(line
, (IUnknown
*)elem
, type
);
755 IHTMLElement_Release(elem
);
758 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
759 static void _test_elem_collection(unsigned line
, IHTMLElementCollection
*col
,
760 const elem_type_t
*elem_types
, long exlen
)
768 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
);
770 hres
= IHTMLElementCollection_get_length(col
, &len
);
771 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
772 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
777 V_VT(&index
) = VT_EMPTY
;
780 for(i
=0; i
<len
; i
++) {
782 disp
= (void*)0xdeadbeef;
783 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
784 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
785 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
786 if(FAILED(hres
) || !disp
)
789 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
790 IDispatch_Release(disp
);
794 disp
= (void*)0xdeadbeef;
795 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
796 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
797 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
800 disp
= (void*)0xdeadbeef;
801 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
802 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
803 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
806 #define get_first_child(n) _get_first_child(__LINE__,n)
807 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
809 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
810 IHTMLDOMNode
*child
= NULL
;
813 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
814 IHTMLDOMNode_Release(node
);
815 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
820 #define get_node_type(n) _get_node_type(__LINE__,n)
821 static long _get_node_type(unsigned line
, IUnknown
*unk
)
823 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
827 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
828 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
830 IHTMLDOMNode_Release(node
);
835 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
836 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
838 VARIANT_BOOL disabled
= 100;
841 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
842 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
843 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
846 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
847 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
849 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
850 IHTMLDOMChildrenCollection
*col
= NULL
;
854 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
855 IHTMLDOMNode_Release(node
);
856 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
860 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
861 IDispatch_Release(disp
);
862 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
867 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
868 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, long idx
)
870 IHTMLDOMNode
*node
= NULL
;
874 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
875 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
877 node
= _get_node_iface(line
, (IUnknown
*)disp
);
878 IDispatch_Release(disp
);
883 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
884 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
886 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
887 BSTR id
= (void*)0xdeadbeef;
890 hres
= IHTMLElement_get_id(elem
, &id
);
891 IHTMLElement_Release(elem
);
892 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
895 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", dbgstr_w(id
));
897 ok_(__FILE__
,line
) (!id
, "id=%s\n", dbgstr_w(id
));
902 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
903 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
905 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
906 BSTR tmp
= a2bstr(new_id
);
909 hres
= IHTMLElement_put_id(elem
, tmp
);
910 IHTMLElement_Release(elem
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
914 _test_elem_id(line
, unk
, new_id
);
917 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
918 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
920 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
924 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
925 IHTMLDOMNode_Release(node
);
926 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
929 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
930 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", dbgstr_w(V_BSTR(&var
)));
932 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
938 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
939 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
941 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
945 V_VT(&var
) = VT_BSTR
;
946 V_BSTR(&var
) = a2bstr(val
);
948 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
949 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
950 IHTMLDOMNode_Release(node
);
954 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
955 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
957 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
961 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
962 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
963 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
964 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
966 IHTMLElement2_Release(elem
);
969 static void test_elem_col_item(IHTMLElementCollection
*col
, LPCWSTR n
,
970 const elem_type_t
*elem_types
, long len
)
972 IHTMLElementCollection
*elcol
;
978 V_VT(&index
) = VT_EMPTY
;
979 V_VT(&name
) = VT_BSTR
;
980 V_BSTR(&name
) = SysAllocString(n
);
982 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
983 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
985 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&elcol
);
986 IDispatch_Release(disp
);
987 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
991 test_elem_collection(elcol
, elem_types
, len
);
992 IHTMLElementCollection_Release(elcol
);
994 V_VT(&index
) = VT_I4
;
996 for(i
=0; i
<len
; i
++) {
998 disp
= (void*)0xdeadbeef;
999 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1000 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1001 ok(disp
!= NULL
, "disp == NULL\n");
1002 if(FAILED(hres
) || !disp
)
1005 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
1007 IDispatch_Release(disp
);
1011 disp
= (void*)0xdeadbeef;
1012 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1013 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1014 ok(disp
== NULL
, "disp != NULL\n");
1017 disp
= (void*)0xdeadbeef;
1018 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1019 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1020 ok(disp
== NULL
, "disp != NULL\n");
1023 SysFreeString(V_BSTR(&name
));
1026 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
, BOOL expect_success
)
1028 IHTMLElementCollection
*col
;
1030 IDispatch
*disp
= (void*)0xdeadbeef;
1031 VARIANT name
, index
;
1034 hres
= IHTMLDocument2_get_all(doc
, &col
);
1035 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1036 ok(col
!= NULL
, "col == NULL\n");
1037 if(FAILED(hres
) || !col
)
1040 V_VT(&index
) = VT_EMPTY
;
1041 V_VT(&name
) = VT_BSTR
;
1042 V_BSTR(&name
) = SysAllocString(id
);
1044 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1045 IHTMLElementCollection_Release(col
);
1046 SysFreeString(V_BSTR(&name
));
1047 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1048 if(!expect_success
) {
1049 ok(disp
== NULL
, "disp != NULL\n");
1053 ok(disp
!= NULL
, "disp == NULL\n");
1057 elem
= get_elem_iface((IUnknown
*)disp
);
1058 IDispatch_Release(disp
);
1063 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
)
1065 IHTMLDocument3
*doc3
;
1070 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1071 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
1073 tmp
= SysAllocString(id
);
1074 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
1076 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", dbgstr_w(id
), hres
);
1078 IHTMLDocument3_Release(doc3
);
1083 static void test_select_elem(IHTMLSelectElement
*select
)
1085 test_select_length(select
, 2);
1086 test_select_selidx(select
, 0);
1087 test_select_put_selidx(select
, 1);
1090 static void test_create_option_elem(IHTMLDocument2
*doc
)
1092 IHTMLOptionElement
*option
;
1094 option
= create_option_elem(doc
, "test text", "test value");
1096 test_option_put_text(option
, "new text");
1097 test_option_put_value(option
, "new value");
1099 IHTMLOptionElement_Release(option
);
1102 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
1104 IHTMLBodyElement
*body
;
1105 IHTMLTxtRange
*range
;
1109 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1110 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1112 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1113 IHTMLElement_Release(elem
);
1115 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
1116 IHTMLBodyElement_Release(body
);
1117 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
1122 static void test_txtrange(IHTMLDocument2
*doc
)
1124 IHTMLTxtRange
*body_range
, *range
, *range2
;
1125 IHTMLSelectionObject
*selection
;
1126 IDispatch
*disp_range
;
1129 body_range
= test_create_body_range(doc
);
1131 test_range_text(body_range
, "test abc 123\r\nit's text");
1133 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1134 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1136 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
1137 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1138 test_range_isequal(range
, range2
, VARIANT_TRUE
);
1140 test_range_text(range
, "test abc 123\r\nit's text");
1141 test_range_text(body_range
, "test abc 123\r\nit's text");
1143 test_range_collapse(range
, TRUE
);
1144 test_range_isequal(range
, range2
, VARIANT_FALSE
);
1145 test_range_inrange(range
, range2
, VARIANT_FALSE
);
1146 test_range_inrange(range2
, range
, VARIANT_TRUE
);
1147 IHTMLTxtRange_Release(range2
);
1149 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1150 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
1151 test_range_move(range
, characterW
, 2, 2);
1152 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1154 test_range_collapse(range
, FALSE
);
1155 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
1157 test_range_collapse(range
, FALSE
);
1158 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1159 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
1160 test_range_move(range
, characterW
, 2, 2);
1161 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1162 test_range_moveend(range
, characterW
, -5, -5);
1163 test_range_text(range
, NULL
);
1164 test_range_moveend(range
, characterW
, 3, 3);
1165 test_range_text(range
, "c 1");
1166 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
1167 test_range_collapse(range
, TRUE
);
1168 test_range_move(range
, characterW
, 4, 4);
1169 test_range_moveend(range
, characterW
, 1, 1);
1170 test_range_text(range
, " ");
1171 test_range_move(range
, wordW
, 1, 1);
1172 test_range_moveend(range
, characterW
, 2, 2);
1173 test_range_text(range
, "ab");
1175 IHTMLTxtRange_Release(range
);
1177 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1178 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1180 test_range_text(range
, "test abc 123\r\nit's text");
1181 test_range_move(range
, characterW
, 3, 3);
1182 test_range_moveend(range
, characterW
, 1, 1);
1183 test_range_text(range
, "t");
1184 test_range_moveend(range
, characterW
, 3, 3);
1185 test_range_text(range
, "t ab");
1186 test_range_moveend(range
, characterW
, -2, -2);
1187 test_range_text(range
, "t ");
1188 test_range_move(range
, characterW
, 6, 6);
1189 test_range_moveend(range
, characterW
, 3, 3);
1190 test_range_text(range
, "123");
1191 test_range_moveend(range
, characterW
, 2, 2);
1192 test_range_text(range
, "123\r\ni");
1194 IHTMLTxtRange_Release(range
);
1196 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1197 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1199 test_range_move(range
, wordW
, 1, 1);
1200 test_range_moveend(range
, characterW
, 2, 2);
1201 test_range_text(range
, "ab");
1203 test_range_move(range
, characterW
, -2, -2);
1204 test_range_moveend(range
, characterW
, 2, 2);
1205 test_range_text(range
, "t ");
1207 test_range_move(range
, wordW
, 3, 3);
1208 test_range_move(range
, wordW
, -2, -2);
1209 test_range_moveend(range
, characterW
, 2, 2);
1210 test_range_text(range
, "ab");
1212 test_range_move(range
, characterW
, -6, -5);
1213 test_range_moveend(range
, characterW
, -1, 0);
1214 test_range_moveend(range
, characterW
, -6, 0);
1215 test_range_move(range
, characterW
, 2, 2);
1216 test_range_moveend(range
, characterW
, 2, 2);
1217 test_range_text(range
, "st");
1218 test_range_moveend(range
, characterW
, -6, -4);
1219 test_range_moveend(range
, characterW
, 2, 2);
1221 IHTMLTxtRange_Release(range
);
1223 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1224 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1226 test_range_move(range
, wordW
, 2, 2);
1227 test_range_moveend(range
, characterW
, 2, 2);
1228 test_range_text(range
, "12");
1230 test_range_move(range
, characterW
, 15, 14);
1231 test_range_move(range
, characterW
, -2, -2);
1232 test_range_moveend(range
, characterW
, 3, 2);
1233 test_range_text(range
, "t");
1234 test_range_moveend(range
, characterW
, -1, -1);
1235 test_range_text(range
, "t");
1236 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
1237 test_range_move(range
, characterW
, -2, -2);
1238 test_range_moveend(range
, characterW
, 2, 2);
1239 test_range_text(range
, "s ");
1240 test_range_move(range
, characterW
, 100, 7);
1241 test_range_move(range
, wordW
, 1, 0);
1242 test_range_move(range
, characterW
, -2, -2);
1243 test_range_moveend(range
, characterW
, 3, 2);
1244 test_range_text(range
, "t");
1246 IHTMLTxtRange_Release(range
);
1248 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1249 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1251 test_range_collapse(range
, TRUE
);
1252 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1253 test_range_put_text(range
, "word");
1254 test_range_text(body_range
, "wordabc 123\r\nit's text");
1255 test_range_text(range
, NULL
);
1256 test_range_moveend(range
, characterW
, 3, 3);
1257 test_range_text(range
, "abc");
1258 test_range_movestart(range
, characterW
, -2, -2);
1259 test_range_text(range
, "rdabc");
1260 test_range_movestart(range
, characterW
, 3, 3);
1261 test_range_text(range
, "bc");
1262 test_range_movestart(range
, characterW
, 4, 4);
1263 test_range_text(range
, NULL
);
1264 test_range_movestart(range
, characterW
, -3, -3);
1265 test_range_text(range
, "c 1");
1266 test_range_movestart(range
, characterW
, -7, -6);
1267 test_range_text(range
, "wordabc 1");
1268 test_range_movestart(range
, characterW
, 100, 22);
1269 test_range_text(range
, NULL
);
1271 IHTMLTxtRange_Release(range
);
1272 IHTMLTxtRange_Release(body_range
);
1274 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1275 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
1277 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
1278 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
1279 IHTMLSelectionObject_Release(selection
);
1281 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
1282 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
1283 IDispatch_Release(disp_range
);
1285 test_range_text(range
, NULL
);
1286 test_range_moveend(range
, characterW
, 3, 3);
1287 test_range_text(range
, "wor");
1288 test_range_parent(range
, ET_BODY
);
1289 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1290 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1291 test_range_move(range
, characterW
, 3, 3);
1292 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
1293 test_range_moveend(range
, characterW
, -4, -4);
1294 test_range_put_text(range
, "abc def ");
1295 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
1296 test_range_move(range
, wordW
, 1, 1);
1297 test_range_movestart(range
, characterW
, -1, -1);
1298 test_range_text(range
, " ");
1299 test_range_move(range
, wordW
, 1, 1);
1300 test_range_moveend(range
, characterW
, 3, 3);
1301 test_range_text(range
, "def");
1302 test_range_put_text(range
, "xyz");
1303 test_range_moveend(range
, characterW
, 1, 1);
1304 test_range_move(range
, wordW
, 1, 1);
1305 test_range_moveend(range
, characterW
, 2, 2);
1306 test_range_text(range
, "ab");
1308 IHTMLTxtRange_Release(range
);
1311 static void test_txtrange2(IHTMLDocument2
*doc
)
1313 IHTMLTxtRange
*range
;
1315 range
= test_create_body_range(doc
);
1317 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
1318 test_range_move(range
, characterW
, 5, 5);
1319 test_range_moveend(range
, characterW
, 1, 1);
1320 test_range_text(range
, "2");
1321 test_range_move(range
, characterW
, -3, -3);
1322 test_range_moveend(range
, characterW
, 3, 3);
1323 test_range_text(range
, "c\r\n\r\n1");
1324 test_range_collapse(range
, VARIANT_FALSE
);
1325 test_range_moveend(range
, characterW
, 4, 4);
1326 test_range_text(range
, "23");
1327 test_range_moveend(range
, characterW
, 1, 1);
1328 test_range_text(range
, "23\r\n\r\n\r\nd");
1329 test_range_moveend(range
, characterW
, -1, -1);
1330 test_range_text(range
, "23");
1331 test_range_moveend(range
, characterW
, -1, -1);
1332 test_range_text(range
, "23");
1333 test_range_moveend(range
, characterW
, -2, -2);
1334 test_range_text(range
, "2");
1336 IHTMLTxtRange_Release(range
);
1339 static void test_compatmode(IHTMLDocument2
*doc
)
1341 IHTMLDocument5
*doc5
;
1345 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
1346 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
1350 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
1351 IHTMLDocument5_Release(doc5
);
1352 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
1353 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode
));
1354 SysFreeString(mode
);
1357 static void test_location(IHTMLDocument2
*doc
)
1359 IHTMLLocation
*location
, *location2
;
1363 hres
= IHTMLDocument2_get_location(doc
, &location
);
1364 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1366 hres
= IHTMLDocument2_get_location(doc
, &location2
);
1367 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1369 ok(location
== location2
, "location != location2\n");
1371 test_ifaces((IUnknown
*)location
, location_iids
);
1373 IHTMLLocation_Release(location2
);
1374 ref
= IHTMLLocation_Release(location
);
1375 ok(!ref
, "location chould be destroyed here\n");
1378 static void test_navigator(IHTMLDocument2
*doc
)
1380 IHTMLWindow2
*window
;
1381 IOmNavigator
*navigator
, *navigator2
;
1385 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1386 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
1388 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
1389 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1390 ok(navigator
!= NULL
, "navigator == NULL\n");
1391 test_disp((IUnknown
*)navigator
, &IID_IOmNavigator
);
1393 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
1394 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1395 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
1397 IHTMLWindow2_Release(window
);
1398 IOmNavigator_Release(navigator2
);
1399 ref
= IOmNavigator_Release(navigator
);
1400 ok(!ref
, "navigator should be destroyed here\n");
1403 static void test_default_style(IHTMLStyle
*style
)
1410 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
);
1412 str
= (void*)0xdeadbeef;
1413 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
1414 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
1415 ok(!str
, "fontFamily = %s\n", dbgstr_w(str
));
1417 str
= (void*)0xdeadbeef;
1418 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
1419 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
1420 ok(!str
, "fontWeight = %s\n", dbgstr_w(str
));
1422 str
= (void*)0xdeadbeef;
1423 hres
= IHTMLStyle_get_display(style
, &str
);
1424 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
1425 ok(!str
, "display = %s\n", dbgstr_w(str
));
1427 str
= (void*)0xdeadbeef;
1428 hres
= IHTMLStyle_get_visibility(style
, &str
);
1429 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
1430 ok(!str
, "visibility = %s\n", dbgstr_w(str
));
1433 hres
= IHTMLStyle_get_fontSize(style
, &v
);
1434 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
1435 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
1436 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v
)));
1439 hres
= IHTMLStyle_get_color(style
, &v
);
1440 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
1441 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
1442 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v
)));
1445 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
1446 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
1447 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
1450 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
1451 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
1452 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
1455 static void test_default_selection(IHTMLDocument2
*doc
)
1457 IHTMLSelectionObject
*selection
;
1458 IHTMLTxtRange
*range
;
1463 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1464 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
1466 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
1467 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1468 ok(!lstrcmpW(str
, noneW
), "type = %s\n", dbgstr_w(str
));
1471 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
1472 IHTMLSelectionObject_Release(selection
);
1473 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
1475 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
1476 IDispatch_Release(disp
);
1477 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
1479 test_range_text(range
, NULL
);
1480 IHTMLTxtRange_Release(range
);
1483 static void test_default_body(IHTMLBodyElement
*body
)
1488 bstr
= (void*)0xdeadbeef;
1489 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
1490 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
1491 ok(bstr
== NULL
, "bstr != NULL\n");
1494 static void test_window(IHTMLDocument2
*doc
)
1496 IHTMLWindow2
*window
;
1497 IHTMLDocument2
*doc2
= NULL
;
1500 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1501 ok(hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1502 test_ifaces((IUnknown
*)window
, window_iids
);
1503 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
);
1505 hres
= IHTMLWindow2_get_document(window
, &doc2
);
1506 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1507 ok(doc2
!= NULL
, "doc2 == NULL\n");
1509 IHTMLDocument_Release(doc2
);
1510 IHTMLWindow2_Release(window
);
1513 static void test_defaults(IHTMLDocument2
*doc
)
1515 IHTMLStyleSheetsCollection
*stylesheetcol
;
1516 IHTMLBodyElement
*body
;
1522 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1523 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1525 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1526 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
1527 test_default_body(body
);
1528 IHTMLBodyElement_Release(body
);
1530 hres
= IHTMLElement_get_style(elem
, &style
);
1531 IHTMLElement_Release(elem
);
1532 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
1534 test_default_style(style
);
1536 test_compatmode(doc
);
1538 test_navigator(doc
);
1540 IHTMLStyle_Release(style
);
1542 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
1543 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1546 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
1547 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1548 ok(l
== 0, "length = %ld\n", l
);
1550 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
1552 test_default_selection(doc
);
1555 static void test_stylesheet(IDispatch
*disp
)
1557 IHTMLStyleSheetRulesCollection
*col
= NULL
;
1558 IHTMLStyleSheet
*stylesheet
;
1561 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
1562 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
1564 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
1565 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
1566 ok(col
!= NULL
, "col == NULL\n");
1568 IHTMLStyleSheetRulesCollection_Release(col
);
1569 IHTMLStyleSheet_Release(stylesheet
);
1572 static void test_stylesheets(IHTMLDocument2
*doc
)
1574 IHTMLStyleSheetsCollection
*col
= NULL
;
1579 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
1580 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1581 ok(col
!= NULL
, "col == NULL\n");
1583 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
1584 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1585 ok(len
== 1, "len=%ld\n", len
);
1591 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
1592 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1593 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
1594 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
1595 test_stylesheet(V_DISPATCH(&res
));
1602 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
1603 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1604 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
1605 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
1608 IHTMLStyleSheetsCollection_Release(col
);
1611 static void test_elems(IHTMLDocument2
*doc
)
1613 IHTMLElementCollection
*col
;
1614 IHTMLDOMChildrenCollection
*child_col
;
1616 IHTMLDOMNode
*node
, *node2
;
1621 static const WCHAR inW
[] = {'i','n',0};
1622 static const WCHAR xW
[] = {'x',0};
1623 static const WCHAR sW
[] = {'s',0};
1624 static const WCHAR scW
[] = {'s','c',0};
1625 static const WCHAR xxxW
[] = {'x','x','x',0};
1627 static const elem_type_t all_types
[] = {
1647 static const elem_type_t item_types
[] = {
1653 hres
= IHTMLDocument2_get_all(doc
, &col
);
1654 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1655 test_elem_collection(col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
1656 test_elem_col_item(col
, xW
, item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
1657 IHTMLElementCollection_Release(col
);
1659 elem
= get_doc_elem(doc
);
1660 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1661 hres
= IHTMLElement_get_all(elem
, &disp
);
1662 IHTMLElement_Release(elem
);
1663 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1665 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&col
);
1666 IDispatch_Release(disp
);
1667 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1668 test_elem_collection(col
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
1669 IHTMLElementCollection_Release(col
);
1671 get_elem_by_id(doc
, xxxW
, FALSE
);
1672 elem
= get_doc_elem_by_id(doc
, xxxW
);
1673 ok(!elem
, "elem != NULL\n");
1675 elem
= get_doc_elem_by_id(doc
, sW
);
1676 ok(elem
!= NULL
, "elem == NULL\n");
1678 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
1679 test_elem_attr(elem
, xxxW
, NULL
);
1680 test_elem_attr(elem
, idW
, sW
);
1681 IHTMLElement_Release(elem
);
1684 elem
= get_elem_by_id(doc
, sW
, TRUE
);
1686 IHTMLSelectElement
*select
;
1688 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
1689 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
1691 test_select_elem(select
);
1693 node
= get_first_child((IUnknown
*)select
);
1694 ok(node
!= NULL
, "node == NULL\n");
1696 test_elem_type((IUnknown
*)node
, ET_OPTION
);
1697 IHTMLDOMNode_Release(node
);
1700 type
= get_node_type((IUnknown
*)select
);
1701 ok(type
== 1, "type=%ld\n", type
);
1703 IHTMLSelectElement_Release(select
);
1704 IHTMLElement_Release(elem
);
1707 elem
= get_elem_by_id(doc
, scW
, TRUE
);
1709 IHTMLScriptElement
*script
;
1712 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
1713 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
1715 hres
= IHTMLScriptElement_get_type(script
, &type
);
1716 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1717 ok(!lstrcmpW(type
, text_javascriptW
), "Unexpected type %s\n", dbgstr_w(type
));
1718 SysFreeString(type
);
1720 IHTMLScriptElement_Release(script
);
1723 elem
= get_elem_by_id(doc
, inW
, TRUE
);
1725 IHTMLInputElement
*input
;
1727 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
1728 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1730 test_elem_id((IUnknown
*)elem
, "in");
1731 test_elem_put_id((IUnknown
*)elem
, "newin");
1732 test_input_get_disabled(input
, VARIANT_FALSE
);
1733 test_elem_client_size((IUnknown
*)elem
);
1735 test_node_get_value_str((IUnknown
*)elem
, NULL
);
1736 test_node_put_value_str((IUnknown
*)elem
, "test");
1737 test_node_get_value_str((IUnknown
*)elem
, NULL
);
1739 IHTMLInputElement_Release(input
);
1740 IHTMLElement_Release(elem
);
1743 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1744 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1746 node
= get_first_child((IUnknown
*)elem
);
1747 ok(node
!= NULL
, "node == NULL\n");
1749 test_ifaces((IUnknown
*)node
, text_iids
);
1750 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
1752 node2
= get_first_child((IUnknown
*)node
);
1753 ok(!node2
, "node2 != NULL\n");
1755 type
= get_node_type((IUnknown
*)node
);
1756 ok(type
== 3, "type=%ld\n", type
);
1758 test_node_get_value_str((IUnknown
*)node
, "text test");
1759 test_node_put_value_str((IUnknown
*)elem
, "test text");
1760 test_node_get_value_str((IUnknown
*)node
, "text test");
1762 IHTMLDOMNode_Release(node
);
1765 child_col
= get_child_nodes((IUnknown
*)elem
);
1766 ok(child_col
!= NULL
, "child_coll == NULL\n");
1770 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
);
1772 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
1773 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1774 ok(length
, "length=0\n");
1776 node
= get_child_item(child_col
, 0);
1777 ok(node
!= NULL
, "node == NULL\n");
1779 type
= get_node_type((IUnknown
*)node
);
1780 ok(type
== 3, "type=%ld\n", type
);
1781 IHTMLDOMNode_Release(node
);
1784 node
= get_child_item(child_col
, 1);
1785 ok(node
!= NULL
, "node == NULL\n");
1787 type
= get_node_type((IUnknown
*)node
);
1788 ok(type
== 8, "type=%ld\n", type
);
1790 test_elem_id((IUnknown
*)node
, NULL
);
1791 IHTMLDOMNode_Release(node
);
1794 disp
= (void*)0xdeadbeef;
1795 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
1796 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1797 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
1799 IHTMLDOMChildrenCollection_Release(child_col
);
1802 IHTMLElement_Release(elem
);
1804 test_stylesheets(doc
);
1805 test_create_option_elem(doc
);
1808 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
1810 IOleCommandTarget
*cmdtrg
;
1813 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1814 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
1816 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
1817 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
1819 IOleCommandTarget_Release(cmdtrg
);
1822 static void test_indent(IHTMLDocument2
*doc
)
1824 IHTMLElementCollection
*col
;
1825 IHTMLTxtRange
*range
;
1828 static const elem_type_t all_types
[] = {
1837 static const elem_type_t indent_types
[] = {
1848 hres
= IHTMLDocument2_get_all(doc
, &col
);
1849 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1850 test_elem_collection(col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
1851 IHTMLElementCollection_Release(col
);
1853 range
= test_create_body_range(doc
);
1854 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
1855 IHTMLTxtRange_Release(range
);
1857 hres
= IHTMLDocument2_get_all(doc
, &col
);
1858 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1859 test_elem_collection(col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
1860 IHTMLElementCollection_Release(col
);
1863 static IHTMLDocument2
*notif_doc
;
1864 static BOOL doc_complete
;
1866 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
1867 REFIID riid
, void**ppv
)
1869 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
1874 ok(0, "unexpected call\n");
1875 return E_NOINTERFACE
;
1878 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1883 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1888 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1890 if(dispID
== DISPID_READYSTATE
){
1894 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
1896 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
1897 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
1899 if(!lstrcmpW(state
, completeW
))
1900 doc_complete
= TRUE
;
1902 SysFreeString(state
);
1908 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1910 ok(0, "unexpected call\n");
1914 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1915 PropertyNotifySink_QueryInterface
,
1916 PropertyNotifySink_AddRef
,
1917 PropertyNotifySink_Release
,
1918 PropertyNotifySink_OnChanged
,
1919 PropertyNotifySink_OnRequestEdit
1922 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
1924 static IHTMLDocument2
*create_doc_with_string(const char *str
)
1926 IPersistStreamInit
*init
;
1928 IHTMLDocument2
*doc
;
1932 notif_doc
= doc
= create_document();
1936 doc_complete
= FALSE
;
1938 mem
= GlobalAlloc(0, len
);
1939 memcpy(mem
, str
, len
);
1940 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1942 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1944 IPersistStreamInit_Load(init
, stream
);
1945 IPersistStreamInit_Release(init
);
1946 IStream_Release(stream
);
1951 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
1953 IConnectionPointContainer
*container
;
1954 IConnectionPoint
*cp
;
1958 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
1959 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1961 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1962 IConnectionPointContainer_Release(container
);
1963 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1965 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1966 IConnectionPoint_Release(cp
);
1967 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1970 typedef void (*domtest_t
)(IHTMLDocument2
*);
1972 static void run_domtest(const char *str
, domtest_t test
)
1974 IHTMLDocument2
*doc
;
1975 IHTMLElement
*body
= NULL
;
1980 doc
= create_doc_with_string(str
);
1981 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1983 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
1984 TranslateMessage(&msg
);
1985 DispatchMessage(&msg
);
1988 hres
= IHTMLDocument2_get_body(doc
, &body
);
1989 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1992 IHTMLElement_Release(body
);
1995 skip("Could not get document body. Assuming no Gecko installed.\n");
1998 ref
= IHTMLDocument2_Release(doc
);
1999 ok(!ref
, "ref = %d\n", ref
);
2002 static void gecko_installer_workaround(BOOL disable
)
2007 static BOOL has_url
= FALSE
;
2008 static char url
[2048];
2010 if(!disable
&& !has_url
)
2013 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
2014 if(res
!= ERROR_SUCCESS
)
2018 DWORD type
, size
= sizeof(url
);
2020 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
2021 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
2024 RegDeleteValue(hkey
, "GeckoUrl");
2026 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
2034 gecko_installer_workaround(TRUE
);
2037 run_domtest(doc_str1
, test_doc_elem
);
2038 run_domtest(range_test_str
, test_txtrange
);
2039 run_domtest(range_test2_str
, test_txtrange2
);
2040 run_domtest(elem_test_str
, test_elems
);
2041 run_domtest(doc_blank
, test_defaults
);
2042 run_domtest(indent_test_str
, test_indent
);
2045 gecko_installer_workaround(FALSE
);