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_node_iface(u) _get_node_iface(__LINE__,u)
380 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
385 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
386 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLDOMNode: %08x\n", hres
);
390 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
391 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
397 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
398 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLNode) failed: %08x\n", hres
);
400 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
401 IHTMLDOMNode_Release(node
);
402 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
403 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", dbgstr_w(name
), exname
);
408 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
409 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
411 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
415 hres
= IHTMLElement_get_tagName(elem
, &tag
);
416 IHTMLElement_Release(elem
);
417 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
418 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", dbgstr_w(tag
), extag
);
423 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
424 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
426 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
427 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
429 if(elem_type_infos
[type
].dispiid
)
430 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
);
433 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
434 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, LPCWSTR name
, LPCWSTR exval
)
442 tmp
= SysAllocString(name
);
443 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
445 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
448 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
449 ok_(__FILE__
,line
) (!lstrcmpW(exval
, V_BSTR(&value
)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value
)));
451 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
454 VariantClear(&value
);
457 static void test_doc_elem(IHTMLDocument2
*doc
)
460 IHTMLDocument3
*doc3
;
463 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
464 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
466 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
467 IHTMLDocument3_Release(doc3
);
468 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
470 test_node_name((IUnknown
*)elem
, "HTML");
471 test_elem_tag((IUnknown
*)elem
, "HTML");
473 IHTMLElement_Release(elem
);
476 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
477 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
480 IHTMLDocument3
*doc3
;
483 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
484 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
485 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
486 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
487 IHTMLDocument3_Release(doc3
);
492 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
493 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
498 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
499 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
500 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", dbgstr_w(bstr
));
504 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
505 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
511 hres
= IHTMLOptionElement_put_text(option
, bstr
);
513 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
515 _test_option_text(line
, option
, text
);
518 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
519 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
524 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
525 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
526 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", dbgstr_w(bstr
));
530 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
531 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
536 bstr
= a2bstr(value
);
537 hres
= IHTMLOptionElement_put_value(option
, bstr
);
539 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
541 _test_option_value(line
, option
, value
);
544 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
545 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
546 const char *txt
, const char *val
)
548 IHTMLOptionElementFactory
*factory
;
549 IHTMLOptionElement
*option
;
550 IHTMLWindow2
*window
;
551 VARIANT text
, value
, empty
;
554 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
555 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
557 hres
= IHTMLWindow2_get_Option(window
, &factory
);
558 IHTMLWindow2_Release(window
);
559 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
561 V_VT(&text
) = VT_BSTR
;
562 V_BSTR(&text
) = a2bstr(txt
);
563 V_VT(&value
) = VT_BSTR
;
564 V_BSTR(&value
) = a2bstr(val
);
565 V_VT(&empty
) = VT_EMPTY
;
567 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
568 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
570 IHTMLOptionElementFactory_Release(factory
);
572 VariantClear(&value
);
574 _test_option_text(line
, option
, txt
);
575 _test_option_value(line
, option
, val
);
580 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
581 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, long length
)
583 long len
= 0xdeadbeef;
586 hres
= IHTMLSelectElement_get_length(select
, &len
);
587 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
588 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
591 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
592 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
594 long idx
= 0xdeadbeef;
597 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
598 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
599 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
602 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
603 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
607 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
608 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
609 _test_select_selidx(line
, select
, index
);
612 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
613 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
618 hres
= IHTMLTxtRange_get_text(range
, &text
);
619 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
622 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
623 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text
), extext
);
625 ok_(__FILE__
, line
) (text
== NULL
, "text=\"%s\", expected NULL\n", dbgstr_w(text
));
632 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
633 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
637 hres
= IHTMLTxtRange_collapse(range
, b
);
638 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
639 _test_range_text(line
, range
, NULL
);
642 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
643 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
644 VARIANT_BOOL exb
, const char *extext
)
646 VARIANT_BOOL b
= 0xe0e0;
649 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
650 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
651 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
652 _test_range_text(line
, range
, extext
);
655 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
656 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
661 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
662 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
663 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
664 _test_range_text(line
, range
, NULL
);
667 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
668 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
669 LPWSTR unit
, long cnt
, long excnt
)
674 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
675 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
676 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
679 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
680 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
685 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
686 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
687 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
690 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
691 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
694 BSTR bstr
= a2bstr(text
);
696 hres
= IHTMLTxtRange_put_text(range
, bstr
);
697 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
699 _test_range_text(line
, range
, NULL
);
702 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
703 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
709 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
710 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
711 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
714 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
715 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
721 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
722 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
723 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
726 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
727 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
728 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
731 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
732 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
736 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
737 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
742 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
743 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
745 _test_elem_type(line
, (IUnknown
*)elem
, type
);
747 IHTMLElement_Release(elem
);
750 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
751 static void _test_elem_collection(unsigned line
, IHTMLElementCollection
*col
,
752 const elem_type_t
*elem_types
, long exlen
)
760 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
);
762 hres
= IHTMLElementCollection_get_length(col
, &len
);
763 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
764 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
769 V_VT(&index
) = VT_EMPTY
;
772 for(i
=0; i
<len
; i
++) {
774 disp
= (void*)0xdeadbeef;
775 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
776 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
777 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
778 if(FAILED(hres
) || !disp
)
781 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
782 IDispatch_Release(disp
);
786 disp
= (void*)0xdeadbeef;
787 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
788 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
789 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
792 disp
= (void*)0xdeadbeef;
793 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
794 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
795 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
798 #define get_first_child(n) _get_first_child(__LINE__,n)
799 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
801 IHTMLDOMNode
*node
, *child
= NULL
;
804 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
805 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
809 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
810 IHTMLDOMNode_Release(node
);
811 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
816 #define get_node_type(n) _get_node_type(__LINE__,n)
817 static long _get_node_type(unsigned line
, IUnknown
*unk
)
823 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
824 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
826 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
827 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
829 IHTMLDOMNode_Release(node
);
834 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
835 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
837 VARIANT_BOOL disabled
= 100;
840 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
841 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
842 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
845 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
846 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
848 IHTMLDOMChildrenCollection
*col
= NULL
;
853 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
854 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
858 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
859 IHTMLDOMNode_Release(node
);
860 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
864 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
865 IDispatch_Release(disp
);
866 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
871 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
872 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, long idx
)
874 IHTMLDOMNode
*node
= NULL
;
878 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
879 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
881 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMNode
, (void**)&node
);
882 IDispatch_Release(disp
);
883 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
888 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
889 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
891 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
892 BSTR id
= (void*)0xdeadbeef;
895 hres
= IHTMLElement_get_id(elem
, &id
);
896 IHTMLElement_Release(elem
);
897 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
900 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", dbgstr_w(id
));
902 ok_(__FILE__
,line
) (!id
, "id=%s\n", dbgstr_w(id
));
907 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
908 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
910 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
911 BSTR tmp
= a2bstr(new_id
);
914 hres
= IHTMLElement_put_id(elem
, tmp
);
915 IHTMLElement_Release(elem
);
917 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
919 _test_elem_id(line
, unk
, new_id
);
922 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
923 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
925 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
929 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
930 IHTMLDOMNode_Release(node
);
931 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
934 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
935 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", dbgstr_w(V_BSTR(&var
)));
937 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
943 static void test_elem_col_item(IHTMLElementCollection
*col
, LPCWSTR n
,
944 const elem_type_t
*elem_types
, long len
)
946 IHTMLElementCollection
*elcol
;
952 V_VT(&index
) = VT_EMPTY
;
953 V_VT(&name
) = VT_BSTR
;
954 V_BSTR(&name
) = SysAllocString(n
);
956 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
957 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
959 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&elcol
);
960 IDispatch_Release(disp
);
961 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
965 test_elem_collection(elcol
, elem_types
, len
);
966 IHTMLElementCollection_Release(elcol
);
968 V_VT(&index
) = VT_I4
;
970 for(i
=0; i
<len
; i
++) {
972 disp
= (void*)0xdeadbeef;
973 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
974 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
975 ok(disp
!= NULL
, "disp == NULL\n");
976 if(FAILED(hres
) || !disp
)
979 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
981 IDispatch_Release(disp
);
985 disp
= (void*)0xdeadbeef;
986 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
987 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
988 ok(disp
== NULL
, "disp != NULL\n");
991 disp
= (void*)0xdeadbeef;
992 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
993 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
994 ok(disp
== NULL
, "disp != NULL\n");
997 SysFreeString(V_BSTR(&name
));
1000 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
, BOOL expect_success
)
1002 IHTMLElementCollection
*col
;
1004 IDispatch
*disp
= (void*)0xdeadbeef;
1005 VARIANT name
, index
;
1008 hres
= IHTMLDocument2_get_all(doc
, &col
);
1009 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1010 ok(col
!= NULL
, "col == NULL\n");
1011 if(FAILED(hres
) || !col
)
1014 V_VT(&index
) = VT_EMPTY
;
1015 V_VT(&name
) = VT_BSTR
;
1016 V_BSTR(&name
) = SysAllocString(id
);
1018 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1019 IHTMLElementCollection_Release(col
);
1020 SysFreeString(V_BSTR(&name
));
1021 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1022 if(!expect_success
) {
1023 ok(disp
== NULL
, "disp != NULL\n");
1027 ok(disp
!= NULL
, "disp == NULL\n");
1031 elem
= get_elem_iface((IUnknown
*)disp
);
1032 IDispatch_Release(disp
);
1037 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
)
1039 IHTMLDocument3
*doc3
;
1044 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1045 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
1047 tmp
= SysAllocString(id
);
1048 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
1050 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", dbgstr_w(id
), hres
);
1052 IHTMLDocument3_Release(doc3
);
1057 static void test_select_elem(IHTMLSelectElement
*select
)
1059 test_select_length(select
, 2);
1060 test_select_selidx(select
, 0);
1061 test_select_put_selidx(select
, 1);
1064 static void test_create_option_elem(IHTMLDocument2
*doc
)
1066 IHTMLOptionElement
*option
;
1068 option
= create_option_elem(doc
, "test text", "test value");
1070 test_option_put_text(option
, "new text");
1071 test_option_put_value(option
, "new value");
1073 IHTMLOptionElement_Release(option
);
1076 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
1078 IHTMLBodyElement
*body
;
1079 IHTMLTxtRange
*range
;
1083 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1084 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1086 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1087 IHTMLElement_Release(elem
);
1089 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
1090 IHTMLBodyElement_Release(body
);
1091 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
1096 static void test_txtrange(IHTMLDocument2
*doc
)
1098 IHTMLTxtRange
*body_range
, *range
, *range2
;
1099 IHTMLSelectionObject
*selection
;
1100 IDispatch
*disp_range
;
1103 body_range
= test_create_body_range(doc
);
1105 test_range_text(body_range
, "test abc 123\r\nit's text");
1107 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1108 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1110 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
1111 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1112 test_range_isequal(range
, range2
, VARIANT_TRUE
);
1114 test_range_text(range
, "test abc 123\r\nit's text");
1115 test_range_text(body_range
, "test abc 123\r\nit's text");
1117 test_range_collapse(range
, TRUE
);
1118 test_range_isequal(range
, range2
, VARIANT_FALSE
);
1119 test_range_inrange(range
, range2
, VARIANT_FALSE
);
1120 test_range_inrange(range2
, range
, VARIANT_TRUE
);
1121 IHTMLTxtRange_Release(range2
);
1123 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1124 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
1125 test_range_move(range
, characterW
, 2, 2);
1126 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1128 test_range_collapse(range
, FALSE
);
1129 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
1131 test_range_collapse(range
, FALSE
);
1132 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1133 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
1134 test_range_move(range
, characterW
, 2, 2);
1135 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1136 test_range_moveend(range
, characterW
, -5, -5);
1137 test_range_text(range
, NULL
);
1138 test_range_moveend(range
, characterW
, 3, 3);
1139 test_range_text(range
, "c 1");
1140 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
1141 test_range_collapse(range
, TRUE
);
1142 test_range_move(range
, characterW
, 4, 4);
1143 test_range_moveend(range
, characterW
, 1, 1);
1144 test_range_text(range
, " ");
1145 test_range_move(range
, wordW
, 1, 1);
1146 test_range_moveend(range
, characterW
, 2, 2);
1147 test_range_text(range
, "ab");
1149 IHTMLTxtRange_Release(range
);
1151 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1152 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1154 test_range_text(range
, "test abc 123\r\nit's text");
1155 test_range_move(range
, characterW
, 3, 3);
1156 test_range_moveend(range
, characterW
, 1, 1);
1157 test_range_text(range
, "t");
1158 test_range_moveend(range
, characterW
, 3, 3);
1159 test_range_text(range
, "t ab");
1160 test_range_moveend(range
, characterW
, -2, -2);
1161 test_range_text(range
, "t ");
1162 test_range_move(range
, characterW
, 6, 6);
1163 test_range_moveend(range
, characterW
, 3, 3);
1164 test_range_text(range
, "123");
1165 test_range_moveend(range
, characterW
, 2, 2);
1166 test_range_text(range
, "123\r\ni");
1168 IHTMLTxtRange_Release(range
);
1170 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1171 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1173 test_range_move(range
, wordW
, 1, 1);
1174 test_range_moveend(range
, characterW
, 2, 2);
1175 test_range_text(range
, "ab");
1177 test_range_move(range
, characterW
, -2, -2);
1178 test_range_moveend(range
, characterW
, 2, 2);
1179 test_range_text(range
, "t ");
1181 test_range_move(range
, wordW
, 3, 3);
1182 test_range_move(range
, wordW
, -2, -2);
1183 test_range_moveend(range
, characterW
, 2, 2);
1184 test_range_text(range
, "ab");
1186 test_range_move(range
, characterW
, -6, -5);
1187 test_range_moveend(range
, characterW
, -1, 0);
1188 test_range_moveend(range
, characterW
, -6, 0);
1189 test_range_move(range
, characterW
, 2, 2);
1190 test_range_moveend(range
, characterW
, 2, 2);
1191 test_range_text(range
, "st");
1192 test_range_moveend(range
, characterW
, -6, -4);
1193 test_range_moveend(range
, characterW
, 2, 2);
1195 IHTMLTxtRange_Release(range
);
1197 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1198 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1200 test_range_move(range
, wordW
, 2, 2);
1201 test_range_moveend(range
, characterW
, 2, 2);
1202 test_range_text(range
, "12");
1204 test_range_move(range
, characterW
, 15, 14);
1205 test_range_move(range
, characterW
, -2, -2);
1206 test_range_moveend(range
, characterW
, 3, 2);
1207 test_range_text(range
, "t");
1208 test_range_moveend(range
, characterW
, -1, -1);
1209 test_range_text(range
, "t");
1210 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
1211 test_range_move(range
, characterW
, -2, -2);
1212 test_range_moveend(range
, characterW
, 2, 2);
1213 test_range_text(range
, "s ");
1214 test_range_move(range
, characterW
, 100, 7);
1215 test_range_move(range
, wordW
, 1, 0);
1216 test_range_move(range
, characterW
, -2, -2);
1217 test_range_moveend(range
, characterW
, 3, 2);
1218 test_range_text(range
, "t");
1220 IHTMLTxtRange_Release(range
);
1222 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1223 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1225 test_range_collapse(range
, TRUE
);
1226 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1227 test_range_put_text(range
, "word");
1228 test_range_text(body_range
, "wordabc 123\r\nit's text");
1229 test_range_text(range
, NULL
);
1230 test_range_moveend(range
, characterW
, 3, 3);
1231 test_range_text(range
, "abc");
1232 test_range_movestart(range
, characterW
, -2, -2);
1233 test_range_text(range
, "rdabc");
1234 test_range_movestart(range
, characterW
, 3, 3);
1235 test_range_text(range
, "bc");
1236 test_range_movestart(range
, characterW
, 4, 4);
1237 test_range_text(range
, NULL
);
1238 test_range_movestart(range
, characterW
, -3, -3);
1239 test_range_text(range
, "c 1");
1240 test_range_movestart(range
, characterW
, -7, -6);
1241 test_range_text(range
, "wordabc 1");
1242 test_range_movestart(range
, characterW
, 100, 22);
1243 test_range_text(range
, NULL
);
1245 IHTMLTxtRange_Release(range
);
1246 IHTMLTxtRange_Release(body_range
);
1248 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1249 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
1251 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
1252 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
1253 IHTMLSelectionObject_Release(selection
);
1255 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
1256 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
1257 IDispatch_Release(disp_range
);
1259 test_range_text(range
, NULL
);
1260 test_range_moveend(range
, characterW
, 3, 3);
1261 test_range_text(range
, "wor");
1262 test_range_parent(range
, ET_BODY
);
1263 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1264 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
1265 test_range_move(range
, characterW
, 3, 3);
1266 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
1267 test_range_moveend(range
, characterW
, -4, -4);
1268 test_range_put_text(range
, "abc def ");
1269 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
1270 test_range_move(range
, wordW
, 1, 1);
1271 test_range_movestart(range
, characterW
, -1, -1);
1272 test_range_text(range
, " ");
1273 test_range_move(range
, wordW
, 1, 1);
1274 test_range_moveend(range
, characterW
, 3, 3);
1275 test_range_text(range
, "def");
1276 test_range_put_text(range
, "xyz");
1277 test_range_moveend(range
, characterW
, 1, 1);
1278 test_range_move(range
, wordW
, 1, 1);
1279 test_range_moveend(range
, characterW
, 2, 2);
1280 test_range_text(range
, "ab");
1282 IHTMLTxtRange_Release(range
);
1285 static void test_txtrange2(IHTMLDocument2
*doc
)
1287 IHTMLTxtRange
*range
;
1289 range
= test_create_body_range(doc
);
1291 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
1292 test_range_move(range
, characterW
, 5, 5);
1293 test_range_moveend(range
, characterW
, 1, 1);
1294 test_range_text(range
, "2");
1295 test_range_move(range
, characterW
, -3, -3);
1296 test_range_moveend(range
, characterW
, 3, 3);
1297 test_range_text(range
, "c\r\n\r\n1");
1298 test_range_collapse(range
, VARIANT_FALSE
);
1299 test_range_moveend(range
, characterW
, 4, 4);
1300 test_range_text(range
, "23");
1301 test_range_moveend(range
, characterW
, 1, 1);
1302 test_range_text(range
, "23\r\n\r\n\r\nd");
1303 test_range_moveend(range
, characterW
, -1, -1);
1304 test_range_text(range
, "23");
1305 test_range_moveend(range
, characterW
, -1, -1);
1306 test_range_text(range
, "23");
1307 test_range_moveend(range
, characterW
, -2, -2);
1308 test_range_text(range
, "2");
1310 IHTMLTxtRange_Release(range
);
1313 static void test_compatmode(IHTMLDocument2
*doc
)
1315 IHTMLDocument5
*doc5
;
1319 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
1320 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
1324 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
1325 IHTMLDocument5_Release(doc5
);
1326 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
1327 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode
));
1328 SysFreeString(mode
);
1331 static void test_location(IHTMLDocument2
*doc
)
1333 IHTMLLocation
*location
, *location2
;
1337 hres
= IHTMLDocument2_get_location(doc
, &location
);
1338 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1340 hres
= IHTMLDocument2_get_location(doc
, &location2
);
1341 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
1343 ok(location
== location2
, "location != location2\n");
1345 test_ifaces((IUnknown
*)location
, location_iids
);
1347 IHTMLLocation_Release(location2
);
1348 ref
= IHTMLLocation_Release(location
);
1349 ok(!ref
, "location chould be destroyed here\n");
1352 static void test_navigator(IHTMLDocument2
*doc
)
1354 IHTMLWindow2
*window
;
1355 IOmNavigator
*navigator
, *navigator2
;
1359 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1360 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
1362 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
1363 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1364 ok(navigator
!= NULL
, "navigator == NULL\n");
1365 test_disp((IUnknown
*)navigator
, &IID_IOmNavigator
);
1367 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
1368 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
1369 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
1371 IHTMLWindow2_Release(window
);
1372 IOmNavigator_Release(navigator2
);
1373 ref
= IOmNavigator_Release(navigator
);
1374 ok(!ref
, "navigator should be destroyed here\n");
1377 static void test_default_style(IHTMLStyle
*style
)
1384 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
);
1386 str
= (void*)0xdeadbeef;
1387 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
1388 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
1389 ok(!str
, "fontFamily = %s\n", dbgstr_w(str
));
1391 str
= (void*)0xdeadbeef;
1392 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
1393 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
1394 ok(!str
, "fontWeight = %s\n", dbgstr_w(str
));
1396 str
= (void*)0xdeadbeef;
1397 hres
= IHTMLStyle_get_display(style
, &str
);
1398 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
1399 ok(!str
, "display = %s\n", dbgstr_w(str
));
1401 str
= (void*)0xdeadbeef;
1402 hres
= IHTMLStyle_get_visibility(style
, &str
);
1403 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
1404 ok(!str
, "visibility = %s\n", dbgstr_w(str
));
1407 hres
= IHTMLStyle_get_fontSize(style
, &v
);
1408 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
1409 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
1410 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v
)));
1413 hres
= IHTMLStyle_get_color(style
, &v
);
1414 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
1415 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
1416 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v
)));
1419 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
1420 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
1421 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
1424 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
1425 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
1426 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
1429 static void test_default_selection(IHTMLDocument2
*doc
)
1431 IHTMLSelectionObject
*selection
;
1432 IHTMLTxtRange
*range
;
1437 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
1438 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
1440 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
1441 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1442 ok(!lstrcmpW(str
, noneW
), "type = %s\n", dbgstr_w(str
));
1445 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
1446 IHTMLSelectionObject_Release(selection
);
1447 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
1449 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
1450 IDispatch_Release(disp
);
1451 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
1453 test_range_text(range
, NULL
);
1454 IHTMLTxtRange_Release(range
);
1457 static void test_default_body(IHTMLBodyElement
*body
)
1462 bstr
= (void*)0xdeadbeef;
1463 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
1464 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
1465 ok(bstr
== NULL
, "bstr != NULL\n");
1468 static void test_window(IHTMLDocument2
*doc
)
1470 IHTMLWindow2
*window
;
1471 IHTMLDocument2
*doc2
= NULL
;
1474 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1475 ok(hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1476 test_ifaces((IUnknown
*)window
, window_iids
);
1477 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
);
1479 hres
= IHTMLWindow2_get_document(window
, &doc2
);
1480 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1481 ok(doc2
!= NULL
, "doc2 == NULL\n");
1483 IHTMLDocument_Release(doc2
);
1484 IHTMLWindow2_Release(window
);
1487 static void test_defaults(IHTMLDocument2
*doc
)
1489 IHTMLStyleSheetsCollection
*stylesheetcol
;
1490 IHTMLBodyElement
*body
;
1496 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1497 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1499 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1500 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
1501 test_default_body(body
);
1502 IHTMLBodyElement_Release(body
);
1504 hres
= IHTMLElement_get_style(elem
, &style
);
1505 IHTMLElement_Release(elem
);
1506 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
1508 test_default_style(style
);
1510 test_compatmode(doc
);
1512 test_navigator(doc
);
1514 IHTMLStyle_Release(style
);
1516 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
1517 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1520 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
1521 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1522 ok(l
== 0, "length = %ld\n", l
);
1524 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
1526 test_default_selection(doc
);
1529 static void test_stylesheet(IDispatch
*disp
)
1531 IHTMLStyleSheetRulesCollection
*col
= NULL
;
1532 IHTMLStyleSheet
*stylesheet
;
1535 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
1536 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
1538 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
1539 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
1540 ok(col
!= NULL
, "col == NULL\n");
1542 IHTMLStyleSheetRulesCollection_Release(col
);
1543 IHTMLStyleSheet_Release(stylesheet
);
1546 static void test_stylesheets(IHTMLDocument2
*doc
)
1548 IHTMLStyleSheetsCollection
*col
= NULL
;
1553 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
1554 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
1555 ok(col
!= NULL
, "col == NULL\n");
1557 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
1558 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1559 ok(len
== 1, "len=%ld\n", len
);
1565 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
1566 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1567 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
1568 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
1569 test_stylesheet(V_DISPATCH(&res
));
1576 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
1577 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1578 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
1579 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
1582 IHTMLStyleSheetsCollection_Release(col
);
1585 static void test_elems(IHTMLDocument2
*doc
)
1587 IHTMLElementCollection
*col
;
1588 IHTMLDOMChildrenCollection
*child_col
;
1590 IHTMLDOMNode
*node
, *node2
;
1595 static const WCHAR inW
[] = {'i','n',0};
1596 static const WCHAR xW
[] = {'x',0};
1597 static const WCHAR sW
[] = {'s',0};
1598 static const WCHAR scW
[] = {'s','c',0};
1599 static const WCHAR xxxW
[] = {'x','x','x',0};
1601 static const elem_type_t all_types
[] = {
1621 static const elem_type_t item_types
[] = {
1627 hres
= IHTMLDocument2_get_all(doc
, &col
);
1628 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1629 test_elem_collection(col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
1630 test_elem_col_item(col
, xW
, item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
1631 IHTMLElementCollection_Release(col
);
1633 elem
= get_doc_elem(doc
);
1634 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1635 hres
= IHTMLElement_get_all(elem
, &disp
);
1636 IHTMLElement_Release(elem
);
1637 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1639 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&col
);
1640 IDispatch_Release(disp
);
1641 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1642 test_elem_collection(col
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
1643 IHTMLElementCollection_Release(col
);
1645 get_elem_by_id(doc
, xxxW
, FALSE
);
1646 elem
= get_doc_elem_by_id(doc
, xxxW
);
1647 ok(!elem
, "elem != NULL\n");
1649 elem
= get_doc_elem_by_id(doc
, sW
);
1650 ok(elem
!= NULL
, "elem == NULL\n");
1652 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
1653 test_elem_attr(elem
, xxxW
, NULL
);
1654 test_elem_attr(elem
, idW
, sW
);
1655 IHTMLElement_Release(elem
);
1658 elem
= get_elem_by_id(doc
, sW
, TRUE
);
1660 IHTMLSelectElement
*select
;
1662 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
1663 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
1665 test_select_elem(select
);
1667 node
= get_first_child((IUnknown
*)select
);
1668 ok(node
!= NULL
, "node == NULL\n");
1670 test_elem_type((IUnknown
*)node
, ET_OPTION
);
1671 IHTMLDOMNode_Release(node
);
1674 type
= get_node_type((IUnknown
*)select
);
1675 ok(type
== 1, "type=%ld\n", type
);
1677 IHTMLSelectElement_Release(select
);
1678 IHTMLElement_Release(elem
);
1681 elem
= get_elem_by_id(doc
, scW
, TRUE
);
1683 IHTMLScriptElement
*script
;
1686 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
1687 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
1689 hres
= IHTMLScriptElement_get_type(script
, &type
);
1690 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1691 ok(!lstrcmpW(type
, text_javascriptW
), "Unexpected type %s\n", dbgstr_w(type
));
1692 SysFreeString(type
);
1694 IHTMLScriptElement_Release(script
);
1697 elem
= get_elem_by_id(doc
, inW
, TRUE
);
1699 IHTMLInputElement
*input
;
1701 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
1702 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1704 test_elem_id((IUnknown
*)elem
, "in");
1705 test_elem_put_id((IUnknown
*)elem
, "newin");
1706 test_input_get_disabled(input
, VARIANT_FALSE
);
1708 test_node_get_value_str((IUnknown
*)elem
, NULL
);
1710 IHTMLInputElement_Release(input
);
1711 IHTMLElement_Release(elem
);
1714 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1715 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1717 node
= get_first_child((IUnknown
*)elem
);
1718 ok(node
!= NULL
, "node == NULL\n");
1720 test_ifaces((IUnknown
*)node
, text_iids
);
1721 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
1723 node2
= get_first_child((IUnknown
*)node
);
1724 ok(!node2
, "node2 != NULL\n");
1726 type
= get_node_type((IUnknown
*)node
);
1727 ok(type
== 3, "type=%ld\n", type
);
1729 test_node_get_value_str((IUnknown
*)node
, "text test");
1731 IHTMLDOMNode_Release(node
);
1734 child_col
= get_child_nodes((IUnknown
*)elem
);
1735 ok(child_col
!= NULL
, "child_coll == NULL\n");
1739 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
);
1741 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
1742 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1743 ok(length
, "length=0\n");
1745 node
= get_child_item(child_col
, 0);
1746 ok(node
!= NULL
, "node == NULL\n");
1748 type
= get_node_type((IUnknown
*)node
);
1749 ok(type
== 3, "type=%ld\n", type
);
1750 IHTMLDOMNode_Release(node
);
1753 node
= get_child_item(child_col
, 1);
1754 ok(node
!= NULL
, "node == NULL\n");
1756 type
= get_node_type((IUnknown
*)node
);
1757 ok(type
== 8, "type=%ld\n", type
);
1759 test_elem_id((IUnknown
*)node
, NULL
);
1760 IHTMLDOMNode_Release(node
);
1763 disp
= (void*)0xdeadbeef;
1764 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
1765 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1766 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
1768 IHTMLDOMChildrenCollection_Release(child_col
);
1771 IHTMLElement_Release(elem
);
1773 test_stylesheets(doc
);
1774 test_create_option_elem(doc
);
1777 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
1779 IOleCommandTarget
*cmdtrg
;
1782 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1783 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
1785 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
1786 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
1788 IOleCommandTarget_Release(cmdtrg
);
1791 static void test_indent(IHTMLDocument2
*doc
)
1793 IHTMLElementCollection
*col
;
1794 IHTMLTxtRange
*range
;
1797 static const elem_type_t all_types
[] = {
1806 static const elem_type_t indent_types
[] = {
1817 hres
= IHTMLDocument2_get_all(doc
, &col
);
1818 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1819 test_elem_collection(col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
1820 IHTMLElementCollection_Release(col
);
1822 range
= test_create_body_range(doc
);
1823 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
1824 IHTMLTxtRange_Release(range
);
1826 hres
= IHTMLDocument2_get_all(doc
, &col
);
1827 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1828 test_elem_collection(col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
1829 IHTMLElementCollection_Release(col
);
1832 static IHTMLDocument2
*notif_doc
;
1833 static BOOL doc_complete
;
1835 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
1836 REFIID riid
, void**ppv
)
1838 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
1843 ok(0, "unexpected call\n");
1844 return E_NOINTERFACE
;
1847 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1852 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1857 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1859 if(dispID
== DISPID_READYSTATE
){
1863 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
1865 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
1866 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
1868 if(!lstrcmpW(state
, completeW
))
1869 doc_complete
= TRUE
;
1871 SysFreeString(state
);
1877 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1879 ok(0, "unexpected call\n");
1883 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1884 PropertyNotifySink_QueryInterface
,
1885 PropertyNotifySink_AddRef
,
1886 PropertyNotifySink_Release
,
1887 PropertyNotifySink_OnChanged
,
1888 PropertyNotifySink_OnRequestEdit
1891 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
1893 static IHTMLDocument2
*create_doc_with_string(const char *str
)
1895 IPersistStreamInit
*init
;
1897 IHTMLDocument2
*doc
;
1901 notif_doc
= doc
= create_document();
1905 doc_complete
= FALSE
;
1907 mem
= GlobalAlloc(0, len
);
1908 memcpy(mem
, str
, len
);
1909 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1911 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1913 IPersistStreamInit_Load(init
, stream
);
1914 IPersistStreamInit_Release(init
);
1915 IStream_Release(stream
);
1920 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
1922 IConnectionPointContainer
*container
;
1923 IConnectionPoint
*cp
;
1927 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
1928 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1930 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1931 IConnectionPointContainer_Release(container
);
1932 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1934 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1935 IConnectionPoint_Release(cp
);
1936 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1939 typedef void (*domtest_t
)(IHTMLDocument2
*);
1941 static void run_domtest(const char *str
, domtest_t test
)
1943 IHTMLDocument2
*doc
;
1944 IHTMLElement
*body
= NULL
;
1949 doc
= create_doc_with_string(str
);
1950 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1952 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
1953 TranslateMessage(&msg
);
1954 DispatchMessage(&msg
);
1957 hres
= IHTMLDocument2_get_body(doc
, &body
);
1958 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1961 IHTMLElement_Release(body
);
1964 skip("Could not get document body. Assuming no Gecko installed.\n");
1967 ref
= IHTMLDocument2_Release(doc
);
1968 ok(!ref
, "ref = %d\n", ref
);
1971 static void gecko_installer_workaround(BOOL disable
)
1976 static BOOL has_url
= FALSE
;
1977 static char url
[2048];
1979 if(!disable
&& !has_url
)
1982 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
1983 if(res
!= ERROR_SUCCESS
)
1987 DWORD type
, size
= sizeof(url
);
1989 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
1990 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
1993 RegDeleteValue(hkey
, "GeckoUrl");
1995 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
2003 gecko_installer_workaround(TRUE
);
2006 run_domtest(doc_str1
, test_doc_elem
);
2007 run_domtest(range_test_str
, test_txtrange
);
2008 run_domtest(range_test2_str
, test_txtrange2
);
2009 run_domtest(elem_test_str
, test_elems
);
2010 run_domtest(doc_blank
, test_defaults
);
2011 run_domtest(indent_test_str
, test_indent
);
2014 gecko_installer_workaround(FALSE
);