push f47c376d7304fae45f226e699c8842fac9cae4ef
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blobdba424b786257ae953c208b66fb49064bb835b2b
1 /*
2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "mshtml.h"
30 #include "mshtmcid.h"
31 #include "mshtmhst.h"
32 #include "docobj.h"
33 #include "dispex.h"
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test />"
52 "<img id=\"imgid\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "</body></html>";
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
60 "</body></html>";
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
66 typedef enum {
67 ET_NONE,
68 ET_HTML,
69 ET_HEAD,
70 ET_TITLE,
71 ET_BODY,
72 ET_A,
73 ET_INPUT,
74 ET_SELECT,
75 ET_TEXTAREA,
76 ET_OPTION,
77 ET_STYLE,
78 ET_BLOCKQUOTE,
79 ET_P,
80 ET_BR,
81 ET_TABLE,
82 ET_TBODY,
83 ET_SCRIPT,
84 ET_TEST,
85 ET_TESTG,
86 ET_COMMENT,
87 ET_IMG,
88 ET_TR,
89 ET_TD,
90 ET_IFRAME
91 } elem_type_t;
93 static const IID * const none_iids[] = {
94 &IID_IUnknown,
95 NULL
98 static const IID * const doc_node_iids[] = {
99 &IID_IHTMLDOMNode,
100 &IID_IHTMLDOMNode2,
101 &IID_IHTMLDocument,
102 &IID_IHTMLDocument2,
103 &IID_IHTMLDocument3,
104 &IID_IHTMLDocument4,
105 &IID_IHTMLDocument5,
106 &IID_IDispatchEx,
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
109 NULL
112 static const IID * const doc_obj_iids[] = {
113 &IID_IHTMLDocument,
114 &IID_IHTMLDocument2,
115 &IID_IHTMLDocument3,
116 &IID_IHTMLDocument4,
117 &IID_IHTMLDocument5,
118 &IID_IDispatchEx,
119 &IID_IConnectionPointContainer,
120 &IID_ICustomDoc,
121 NULL
124 static const IID * const elem_iids[] = {
125 &IID_IHTMLDOMNode,
126 &IID_IHTMLDOMNode2,
127 &IID_IHTMLElement,
128 &IID_IHTMLElement2,
129 &IID_IHTMLElement3,
130 &IID_IDispatchEx,
131 &IID_IConnectionPointContainer,
132 NULL
135 static const IID * const body_iids[] = {
136 &IID_IHTMLDOMNode,
137 &IID_IHTMLDOMNode2,
138 &IID_IHTMLElement,
139 &IID_IHTMLElement2,
140 &IID_IHTMLElement3,
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
143 &IID_IDispatchEx,
144 &IID_IConnectionPointContainer,
145 NULL
148 static const IID * const anchor_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IHTMLAnchorElement,
155 &IID_IDispatchEx,
156 &IID_IConnectionPointContainer,
157 NULL
160 static const IID * const input_iids[] = {
161 &IID_IHTMLDOMNode,
162 &IID_IHTMLDOMNode2,
163 &IID_IHTMLElement,
164 &IID_IHTMLElement2,
165 &IID_IHTMLElement3,
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
168 &IID_IDispatchEx,
169 &IID_IConnectionPointContainer,
170 NULL
173 static const IID * const select_iids[] = {
174 &IID_IHTMLDOMNode,
175 &IID_IHTMLDOMNode2,
176 &IID_IHTMLElement,
177 &IID_IHTMLElement2,
178 &IID_IHTMLElement3,
179 &IID_IHTMLSelectElement,
180 &IID_IDispatchEx,
181 &IID_IConnectionPointContainer,
182 NULL
185 static const IID * const textarea_iids[] = {
186 &IID_IHTMLDOMNode,
187 &IID_IHTMLDOMNode2,
188 &IID_IHTMLElement,
189 &IID_IHTMLElement2,
190 &IID_IHTMLElement3,
191 &IID_IHTMLTextAreaElement,
192 &IID_IDispatchEx,
193 &IID_IConnectionPointContainer,
194 NULL
197 static const IID * const option_iids[] = {
198 &IID_IHTMLDOMNode,
199 &IID_IHTMLDOMNode2,
200 &IID_IHTMLElement,
201 &IID_IHTMLElement2,
202 &IID_IHTMLElement3,
203 &IID_IHTMLOptionElement,
204 &IID_IDispatchEx,
205 &IID_IConnectionPointContainer,
206 NULL
209 static const IID * const table_iids[] = {
210 &IID_IHTMLDOMNode,
211 &IID_IHTMLDOMNode2,
212 &IID_IHTMLElement,
213 &IID_IHTMLElement2,
214 &IID_IHTMLElement3,
215 &IID_IHTMLTable,
216 &IID_IDispatchEx,
217 &IID_IConnectionPointContainer,
218 NULL
221 static const IID * const script_iids[] = {
222 &IID_IHTMLDOMNode,
223 &IID_IHTMLDOMNode2,
224 &IID_IHTMLElement,
225 &IID_IHTMLElement2,
226 &IID_IHTMLElement3,
227 &IID_IHTMLScriptElement,
228 &IID_IDispatchEx,
229 &IID_IConnectionPointContainer,
230 NULL
233 static const IID * const text_iids[] = {
234 &IID_IHTMLDOMNode,
235 &IID_IHTMLDOMNode2,
236 &IID_IHTMLDOMTextNode,
237 NULL
240 static const IID * const location_iids[] = {
241 &IID_IDispatch,
242 &IID_IHTMLLocation,
243 NULL
246 static const IID * const window_iids[] = {
247 &IID_IDispatch,
248 &IID_IHTMLWindow2,
249 &IID_IHTMLWindow3,
250 &IID_IDispatchEx,
251 NULL
254 static const IID * const comment_iids[] = {
255 &IID_IHTMLDOMNode,
256 &IID_IHTMLDOMNode2,
257 &IID_IHTMLElement,
258 &IID_IHTMLElement2,
259 &IID_IHTMLElement3,
260 &IID_IHTMLCommentElement,
261 &IID_IDispatchEx,
262 &IID_IConnectionPointContainer,
263 NULL
266 static const IID * const img_iids[] = {
267 &IID_IHTMLDOMNode,
268 &IID_IHTMLDOMNode2,
269 &IID_IHTMLElement,
270 &IID_IHTMLElement2,
271 &IID_IHTMLElement3,
272 &IID_IDispatchEx,
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
275 NULL
278 static const IID * const tr_iids[] = {
279 &IID_IHTMLDOMNode,
280 &IID_IHTMLDOMNode2,
281 &IID_IHTMLElement,
282 &IID_IHTMLElement2,
283 &IID_IHTMLElement3,
284 &IID_IDispatchEx,
285 &IID_IHTMLTableRow,
286 &IID_IConnectionPointContainer,
287 NULL
290 static const IID * const td_iids[] = {
291 &IID_IHTMLDOMNode,
292 &IID_IHTMLDOMNode2,
293 &IID_IHTMLElement,
294 &IID_IHTMLElement2,
295 &IID_IHTMLElement3,
296 &IID_IDispatchEx,
297 &IID_IConnectionPointContainer,
298 NULL
301 static const IID * const iframe_iids[] = {
302 &IID_IHTMLDOMNode,
303 &IID_IHTMLDOMNode2,
304 &IID_IHTMLElement,
305 &IID_IHTMLElement2,
306 &IID_IHTMLElement3,
307 &IID_IHTMLFrameBase2,
308 &IID_IDispatchEx,
309 &IID_IConnectionPointContainer,
310 NULL
313 static const IID * const generic_iids[] = {
314 &IID_IHTMLDOMNode,
315 &IID_IHTMLDOMNode2,
316 &IID_IHTMLElement,
317 &IID_IHTMLElement2,
318 &IID_IHTMLElement3,
319 &IID_IHTMLGenericElement,
320 &IID_IDispatchEx,
321 &IID_IConnectionPointContainer,
322 NULL
325 static const IID * const style_iids[] = {
326 &IID_IUnknown,
327 &IID_IDispatch,
328 &IID_IDispatchEx,
329 &IID_IHTMLStyle,
330 &IID_IHTMLStyle2,
331 &IID_IHTMLStyle3,
332 &IID_IHTMLStyle4,
333 NULL
336 static const IID * const cstyle_iids[] = {
337 &IID_IUnknown,
338 &IID_IDispatch,
339 &IID_IDispatchEx,
340 &IID_IHTMLCurrentStyle,
341 NULL
344 typedef struct {
345 const char *tag;
346 REFIID *iids;
347 const IID *dispiid;
348 } elem_type_info_t;
350 static const elem_type_info_t elem_type_infos[] = {
351 {"", none_iids, NULL},
352 {"HTML", elem_iids, NULL},
353 {"HEAD", elem_iids, NULL},
354 {"TITLE", elem_iids, NULL},
355 {"BODY", body_iids, &DIID_DispHTMLBody},
356 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
357 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
358 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
359 {"TEXTAREA", textarea_iids, NULL},
360 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
361 {"STYLE", elem_iids, NULL},
362 {"BLOCKQUOTE",elem_iids, NULL},
363 {"P", elem_iids, NULL},
364 {"BR", elem_iids, NULL},
365 {"TABLE", table_iids, &DIID_DispHTMLTable},
366 {"TBODY", elem_iids, NULL},
367 {"SCRIPT", script_iids, NULL},
368 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
369 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
370 {"!", comment_iids, &DIID_DispHTMLCommentElement},
371 {"IMG", img_iids, &DIID_DispHTMLImg},
372 {"TR", tr_iids, &DIID_DispHTMLTableRow},
373 {"TD", td_iids, NULL},
374 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
377 static const char *dbgstr_guid(REFIID riid)
379 static char buf[50];
381 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
382 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
383 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
384 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
386 return buf;
389 static int strcmp_wa(LPCWSTR strw, const char *stra)
391 CHAR buf[512];
392 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
393 return lstrcmpA(stra, buf);
396 static BSTR a2bstr(const char *str)
398 BSTR ret;
399 int len;
401 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
402 ret = SysAllocStringLen(NULL, len);
403 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
405 return ret;
408 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
410 IUnknown *unk1, *unk2;
412 if(iface1 == iface2)
413 return TRUE;
415 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
416 IUnknown_Release(unk1);
417 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
418 IUnknown_Release(unk2);
420 return unk1 == unk2;
423 static IHTMLDocument2 *create_document(void)
425 IHTMLDocument2 *doc;
426 IHTMLDocument5 *doc5;
427 HRESULT hres;
429 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
430 &IID_IHTMLDocument2, (void**)&doc);
431 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
433 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
434 if(FAILED(hres)) {
435 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
436 IHTMLDocument2_Release(doc);
437 return NULL;
440 IHTMLDocument5_Release(doc5);
441 return doc;
444 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
445 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
447 const IID * const *piid;
448 IUnknown *unk;
449 HRESULT hres;
451 for(piid = iids; *piid; piid++) {
452 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
453 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
454 if(SUCCEEDED(hres))
455 IUnknown_Release(unk);
459 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
460 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
462 IDispatchEx *dispex;
463 ITypeInfo *typeinfo;
464 BOOL ret = FALSE;
465 UINT ticnt;
466 HRESULT hres;
468 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
469 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
470 if(FAILED(hres))
471 return FALSE;
473 ticnt = 0xdeadbeef;
474 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
475 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
476 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
478 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
479 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
481 if(SUCCEEDED(hres)) {
482 TYPEATTR *type_attr;
484 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
485 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
486 if(hres == S_OK) {
487 *iid = type_attr->guid;
488 ret = TRUE;
491 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
492 ITypeInfo_Release(typeinfo);
495 IDispatchEx_Release(dispex);
496 return ret;
499 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
500 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
502 DISPPARAMS dp = {NULL,NULL,0,0};
503 IDispatchEx *dispex;
504 EXCEPINFO ei;
505 VARIANT var;
506 HRESULT hres;
508 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
509 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
510 if(FAILED(hres))
511 return;
513 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
514 IDispatchEx_Release(dispex);
515 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
517 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
518 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
519 VariantClear(&var);
522 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
523 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
525 IID iid;
527 if(_test_get_dispid(line, unk, &iid))
528 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
530 if(val)
531 _test_disp_value(line, unk, val);
534 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
535 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
537 IID iid;
539 if(_test_get_dispid(line, unk, &iid))
540 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
541 "unexpected guid %s\n", dbgstr_guid(&iid));
543 if(val)
544 _test_disp_value(line, unk, val);
547 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
548 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
550 IHTMLElement *elem;
551 HRESULT hres;
553 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
554 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
555 return elem;
558 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
559 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
561 IHTMLElement2 *elem;
562 HRESULT hres;
564 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
565 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
566 return elem;
569 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
570 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
572 IHTMLElement3 *elem;
573 HRESULT hres;
575 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
576 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
577 return elem;
580 #define get_node_iface(u) _get_node_iface(__LINE__,u)
581 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
583 IHTMLDOMNode *node;
584 HRESULT hres;
586 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
587 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
588 return node;
591 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
592 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
594 IHTMLDOMNode2 *node;
595 HRESULT hres;
597 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
598 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
599 return node;
602 #define get_img_iface(u) _get_img_iface(__LINE__,u)
603 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
605 IHTMLImgElement *img;
606 HRESULT hres;
608 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
609 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
610 return img;
613 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
614 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
616 IHTMLAnchorElement *anchor;
617 HRESULT hres;
619 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
620 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
621 return anchor;
624 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
625 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
627 IHTMLDOMNode *node = _get_node_iface(line, unk);
628 BSTR name;
629 HRESULT hres;
631 hres = IHTMLDOMNode_get_nodeName(node, &name);
632 IHTMLDOMNode_Release(node);
633 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
634 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
636 SysFreeString(name);
639 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
640 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
642 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
643 IDispatch *disp = (void*)0xdeadbeef;
644 IHTMLDocument2 *doc;
645 HRESULT hres;
647 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
648 IHTMLDOMNode2_Release(node);
649 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
650 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
652 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
653 IDispatch_Release(disp);
654 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
656 return doc;
659 #define clone_node(n,d) _clone_node(__LINE__,n,d)
660 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
662 IHTMLDOMNode *node = _get_node_iface(line, unk);
663 IHTMLDOMNode *ret = NULL;
664 HRESULT hres;
666 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
667 IHTMLDOMNode_Release(node);
668 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
669 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
671 return ret;
675 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
676 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
678 IHTMLElement *elem = _get_elem_iface(line, unk);
679 BSTR tag;
680 HRESULT hres;
682 hres = IHTMLElement_get_tagName(elem, &tag);
683 IHTMLElement_Release(elem);
684 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
685 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
687 SysFreeString(tag);
690 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
691 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
693 _test_elem_tag(line, unk, elem_type_infos[type].tag);
694 _test_ifaces(line, unk, elem_type_infos[type].iids);
696 if(elem_type_infos[type].dispiid && type != ET_A)
697 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
700 #define get_node_type(n) _get_node_type(__LINE__,n)
701 static LONG _get_node_type(unsigned line, IUnknown *unk)
703 IHTMLDOMNode *node = _get_node_iface(line, unk);
704 LONG type = -1;
705 HRESULT hres;
707 hres = IHTMLDOMNode_get_nodeType(node, &type);
708 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
710 IHTMLDOMNode_Release(node);
712 return type;
715 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
716 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
718 IHTMLDOMNode *node = _get_node_iface(line, unk);
719 IHTMLDOMChildrenCollection *col = NULL;
720 IDispatch *disp;
721 HRESULT hres;
723 hres = IHTMLDOMNode_get_childNodes(node, &disp);
724 IHTMLDOMNode_Release(node);
725 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
726 if(FAILED(hres))
727 return NULL;
729 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
730 IDispatch_Release(disp);
731 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
733 return col;
736 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
737 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
739 IHTMLDOMNode *node = NULL;
740 IDispatch *disp;
741 HRESULT hres;
743 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
744 ok(hres == S_OK, "item failed: %08x\n", hres);
746 node = _get_node_iface(line, (IUnknown*)disp);
747 IDispatch_Release(disp);
749 return node;
752 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
753 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
755 VARIANT value;
756 BSTR tmp;
757 HRESULT hres;
759 VariantInit(&value);
761 tmp = a2bstr(name);
762 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
763 SysFreeString(tmp);
764 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
766 if(exval) {
767 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
768 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
769 }else {
770 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
773 VariantClear(&value);
776 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
777 static void _test_elem_offset(unsigned line, IUnknown *unk)
779 IHTMLElement *elem = _get_elem_iface(line, unk);
780 LONG l;
781 HRESULT hres;
783 hres = IHTMLElement_get_offsetTop(elem, &l);
784 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
786 hres = IHTMLElement_get_offsetHeight(elem, &l);
787 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
789 hres = IHTMLElement_get_offsetWidth(elem, &l);
790 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
792 IHTMLElement_Release(elem);
795 #define get_doc_node(d) _get_doc_node(__LINE__,d)
796 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
798 IHTMLWindow2 *window;
799 IHTMLDocument2 *ret;
800 HRESULT hres;
802 hres = IHTMLDocument2_get_parentWindow(doc, &window);
803 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
805 hres = IHTMLWindow2_get_document(window, &ret);
806 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
807 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
809 return ret;
812 static void test_doc_elem(IHTMLDocument2 *doc)
814 IHTMLDocument2 *doc_node, *owner_doc;
815 IHTMLElement *elem;
816 IHTMLDocument3 *doc3;
817 HRESULT hres;
819 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
820 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
822 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
823 IHTMLDocument3_Release(doc3);
824 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
826 test_node_name((IUnknown*)elem, "HTML");
827 test_elem_tag((IUnknown*)elem, "HTML");
829 doc_node = get_doc_node(doc);
830 owner_doc = get_owner_doc((IUnknown*)elem);
831 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
832 IHTMLDocument2_Release(doc_node);
833 IHTMLDocument2_Release(owner_doc);
835 IHTMLElement_Release(elem);
838 static void test_get_set_attr(IHTMLDocument2 *doc)
840 IHTMLElement *elem;
841 IHTMLDocument3 *doc3;
842 HRESULT hres;
843 BSTR bstr;
844 VARIANT val;
846 /* grab an element to test with */
847 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
848 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
850 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
851 IHTMLDocument3_Release(doc3);
852 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
854 /* get a non-present attribute */
855 bstr = a2bstr("notAnAttribute");
856 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
857 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
858 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
859 VariantClear(&val);
860 SysFreeString(bstr);
862 /* get a present attribute */
863 bstr = a2bstr("scrollHeight");
864 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
865 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
866 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
867 VariantClear(&val);
868 SysFreeString(bstr);
870 /* create a new BSTR attribute */
871 bstr = a2bstr("newAttribute");
873 V_VT(&val) = VT_BSTR;
874 V_BSTR(&val) = a2bstr("the value");
875 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
876 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
877 VariantClear(&val);
879 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
880 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
881 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
882 ok(strcmp_wa(V_BSTR(&val), "the value") == 0, "variant value should have been L\"the value\", was %s\n", wine_dbgstr_w(V_BSTR(&val)));
883 VariantClear(&val);
885 /* overwrite the attribute with a BOOL */
886 V_VT(&val) = VT_BOOL;
887 V_BOOL(&val) = VARIANT_TRUE;
888 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
889 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
890 VariantClear(&val);
892 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
893 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
894 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
895 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
896 VariantClear(&val);
898 SysFreeString(bstr);
900 /* case-insensitive */
901 bstr = a2bstr("newattribute");
902 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
903 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
904 todo_wine ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
905 todo_wine ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
906 VariantClear(&val);
907 SysFreeString(bstr);
909 IHTMLElement_Release(elem);
912 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
913 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
915 IHTMLElement *elem;
916 IHTMLDocument3 *doc3;
917 HRESULT hres;
919 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
920 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
921 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
922 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
923 IHTMLDocument3_Release(doc3);
925 return elem;
928 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
929 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
931 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
932 BSTR str;
933 HRESULT hres;
935 hres = IHTMLAnchorElement_get_href(anchor, &str);
936 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
937 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
938 SysFreeString(str);
940 _test_disp_value(line, unk, exhref);
943 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
944 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
946 BSTR bstr;
947 HRESULT hres;
949 hres = IHTMLOptionElement_get_text(option, &bstr);
950 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
951 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
952 SysFreeString(bstr);
955 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
956 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
958 BSTR bstr;
959 HRESULT hres;
961 bstr = a2bstr(text);
962 hres = IHTMLOptionElement_put_text(option, bstr);
963 SysFreeString(bstr);
964 ok(hres == S_OK, "put_text failed: %08x\n", hres);
966 _test_option_text(line, option, text);
969 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
970 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
972 BSTR bstr;
973 HRESULT hres;
975 hres = IHTMLOptionElement_get_value(option, &bstr);
976 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
977 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
978 SysFreeString(bstr);
981 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
982 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
984 BSTR bstr;
985 HRESULT hres;
987 bstr = a2bstr(value);
988 hres = IHTMLOptionElement_put_value(option, bstr);
989 SysFreeString(bstr);
990 ok(hres == S_OK, "put_value failed: %08x\n", hres);
992 _test_option_value(line, option, value);
995 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
996 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
997 const char *txt, const char *val)
999 IHTMLOptionElementFactory *factory;
1000 IHTMLOptionElement *option;
1001 IHTMLWindow2 *window;
1002 VARIANT text, value, empty;
1003 HRESULT hres;
1005 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1006 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1008 hres = IHTMLWindow2_get_Option(window, &factory);
1009 IHTMLWindow2_Release(window);
1010 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1012 V_VT(&text) = VT_BSTR;
1013 V_BSTR(&text) = a2bstr(txt);
1014 V_VT(&value) = VT_BSTR;
1015 V_BSTR(&value) = a2bstr(val);
1016 V_VT(&empty) = VT_EMPTY;
1018 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1019 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1021 IHTMLOptionElementFactory_Release(factory);
1022 VariantClear(&text);
1023 VariantClear(&value);
1025 _test_option_text(line, option, txt);
1026 _test_option_value(line, option, val);
1028 return option;
1031 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1032 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1034 LONG len = 0xdeadbeef;
1035 HRESULT hres;
1037 hres = IHTMLSelectElement_get_length(select, &len);
1038 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1039 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1042 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1043 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1045 LONG idx = 0xdeadbeef;
1046 HRESULT hres;
1048 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1049 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1050 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1053 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1054 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1056 HRESULT hres;
1058 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1059 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1060 _test_select_selidx(line, select, index);
1063 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1064 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1066 BSTR val;
1067 HRESULT hres;
1069 hres = IHTMLSelectElement_get_value(select, &val);
1070 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1071 if(exval)
1072 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1073 else
1074 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1077 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1078 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1080 BSTR bstr;
1081 HRESULT hres;
1083 bstr = a2bstr(val);
1084 hres = IHTMLSelectElement_put_value(select, bstr);
1085 SysFreeString(bstr);
1086 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1089 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1090 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1092 BSTR type;
1093 HRESULT hres;
1095 hres = IHTMLSelectElement_get_type(select, &type);
1096 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1097 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1100 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1101 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1103 BSTR text;
1104 HRESULT hres;
1106 hres = IHTMLTxtRange_get_text(range, &text);
1107 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1109 if(extext) {
1110 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1111 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1112 }else {
1113 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1116 SysFreeString(text);
1120 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1121 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1123 HRESULT hres;
1125 hres = IHTMLTxtRange_collapse(range, b);
1126 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1127 _test_range_text(line, range, NULL);
1130 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1131 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1132 VARIANT_BOOL exb, const char *extext)
1134 VARIANT_BOOL b = 0xe0e0;
1135 HRESULT hres;
1137 hres = IHTMLTxtRange_expand(range, unit, &b);
1138 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1139 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1140 _test_range_text(line, range, extext);
1143 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1144 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1146 LONG c = 0xdeadbeef;
1147 HRESULT hres;
1149 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1150 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1151 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1152 _test_range_text(line, range, NULL);
1155 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1156 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1157 LPWSTR unit, LONG cnt, LONG excnt)
1159 LONG c = 0xdeadbeef;
1160 HRESULT hres;
1162 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1163 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1164 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1167 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1168 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1170 LONG c = 0xdeadbeef;
1171 HRESULT hres;
1173 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1174 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1175 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1178 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1179 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1181 HRESULT hres;
1182 BSTR bstr = a2bstr(text);
1184 hres = IHTMLTxtRange_put_text(range, bstr);
1185 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1186 SysFreeString(bstr);
1187 _test_range_text(line, range, NULL);
1190 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1191 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1193 VARIANT_BOOL b;
1194 HRESULT hres;
1196 b = 0xe0e0;
1197 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1198 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1199 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1202 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1203 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1205 VARIANT_BOOL b;
1206 HRESULT hres;
1208 b = 0xe0e0;
1209 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1210 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1211 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1213 b = 0xe0e0;
1214 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1215 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1216 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1218 if(exb) {
1219 test_range_inrange(range1, range2, VARIANT_TRUE);
1220 test_range_inrange(range2, range1, VARIANT_TRUE);
1224 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1225 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1227 IHTMLElement *elem;
1228 HRESULT hres;
1230 hres = IHTMLTxtRange_parentElement(range, &elem);
1231 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1233 _test_elem_type(line, (IUnknown*)elem, type);
1235 IHTMLElement_Release(elem);
1238 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1239 static void _test_elem_collection(unsigned line, IUnknown *unk,
1240 const elem_type_t *elem_types, LONG exlen)
1242 IHTMLElementCollection *col;
1243 LONG len;
1244 DWORD i;
1245 VARIANT name, index;
1246 IDispatch *disp, *disp2;
1247 HRESULT hres;
1249 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1250 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1252 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1254 hres = IHTMLElementCollection_get_length(col, &len);
1255 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1256 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1258 if(len > exlen)
1259 len = exlen;
1261 V_VT(&index) = VT_EMPTY;
1263 for(i=0; i<len; i++) {
1264 V_VT(&name) = VT_I4;
1265 V_I4(&name) = i;
1266 disp = (void*)0xdeadbeef;
1267 hres = IHTMLElementCollection_item(col, name, index, &disp);
1268 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1269 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1270 if(FAILED(hres) || !disp)
1271 continue;
1273 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1275 if(!i) {
1276 V_VT(&name) = VT_UINT;
1277 V_I4(&name) = 0;
1278 disp2 = (void*)0xdeadbeef;
1279 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1280 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1281 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1282 if(disp2)
1283 IDispatch_Release(disp2);
1286 IDispatch_Release(disp);
1289 V_VT(&name) = VT_I4;
1290 V_I4(&name) = len;
1291 disp = (void*)0xdeadbeef;
1292 hres = IHTMLElementCollection_item(col, name, index, &disp);
1293 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1294 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1296 V_VT(&name) = VT_I4;
1297 V_I4(&name) = -1;
1298 disp = (void*)0xdeadbeef;
1299 hres = IHTMLElementCollection_item(col, name, index, &disp);
1300 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1301 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1303 IHTMLElementCollection_Release(col);
1306 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1307 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1309 IHTMLElement *elem = _get_elem_iface(line, unk);
1310 IDispatch *disp;
1311 HRESULT hres;
1313 hres = IHTMLElement_get_all(elem, &disp);
1314 IHTMLElement_Release(elem);
1315 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1317 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1318 IDispatch_Release(disp);
1321 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1322 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1324 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1325 IHTMLElementCollection *col = NULL;
1326 elem_type_t *types = NULL;
1327 BSTR tmp;
1328 int i;
1329 HRESULT hres;
1331 tmp = a2bstr(elem_type_infos[type].tag);
1332 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1333 SysFreeString(tmp);
1334 IHTMLElement2_Release(elem);
1335 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1336 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1338 if(exlen) {
1339 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1340 for(i=0; i<exlen; i++)
1341 types[i] = type;
1344 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1346 HeapFree(GetProcessHeap(), 0, types);
1349 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1350 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1352 BSTR text = NULL;
1353 HRESULT hres;
1355 hres = IHTMLElement_get_innerText(elem, &text);
1356 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1357 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1358 wine_dbgstr_w(text), extext);
1359 SysFreeString(text);
1362 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1363 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1365 IHTMLDOMChildrenCollection *col;
1366 BSTR str;
1367 HRESULT hres;
1369 str = a2bstr(text);
1370 hres = IHTMLElement_put_innerText(elem, str);
1371 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1372 SysFreeString(str);
1374 _test_elem_innertext(line, elem, text);
1377 col = _get_child_nodes(line, (IUnknown*)elem);
1378 ok(col != NULL, "col == NULL\n");
1379 if(col) {
1380 LONG length = 0, type;
1381 IHTMLDOMNode *node;
1383 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1384 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1385 ok(length == 1, "length = %d\n", length);
1387 node = _get_child_item(line, col, 0);
1388 ok(node != NULL, "node == NULL\n");
1389 if(node) {
1390 type = _get_node_type(line, (IUnknown*)node);
1391 ok(type == 3, "type=%d\n", type);
1392 IHTMLDOMNode_Release(node);
1395 IHTMLDOMChildrenCollection_Release(col);
1400 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1401 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1403 IHTMLElement *elem = _get_elem_iface(line, unk);
1404 BSTR html;
1405 HRESULT hres;
1407 hres = IHTMLElement_get_innerHTML(elem, &html);
1408 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1409 if(inner_html)
1410 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1411 else
1412 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1414 IHTMLElement_Release(elem);
1415 SysFreeString(html);
1418 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1419 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1421 IHTMLElement *elem = _get_elem_iface(line, unk);
1422 BSTR html;
1423 HRESULT hres;
1425 html = a2bstr(inner_html);
1426 hres = IHTMLElement_put_innerHTML(elem, html);
1427 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1429 IHTMLElement_Release(elem);
1430 SysFreeString(html);
1433 #define get_first_child(n) _get_first_child(__LINE__,n)
1434 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1436 IHTMLDOMNode *node = _get_node_iface(line, unk);
1437 IHTMLDOMNode *child = NULL;
1438 HRESULT hres;
1440 hres = IHTMLDOMNode_get_firstChild(node, &child);
1441 IHTMLDOMNode_Release(node);
1442 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1444 return child;
1447 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1448 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1450 IHTMLDOMNode *node = _get_node_iface(line, unk);
1451 VARIANT_BOOL b = 0xdead;
1452 HRESULT hres;
1454 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1455 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1456 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1458 IHTMLDOMNode_Release(node);
1461 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1462 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1464 IHTMLDOMNode *node = _get_node_iface(line, unk);
1465 IHTMLDOMNode *parent;
1466 HRESULT hres;
1468 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1469 IHTMLDOMNode_Release(node);
1470 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1472 return parent;
1475 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1476 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1478 IHTMLElement *elem = _get_elem_iface(line, unk);
1479 IHTMLElement *parent;
1480 HRESULT hres;
1482 hres = IHTMLElement_get_parentElement(elem, &parent);
1483 IHTMLElement_Release(elem);
1484 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1486 return parent;
1489 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1490 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1492 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1493 VARIANT_BOOL disabled = 100;
1494 HRESULT hres;
1496 if (!elem3) return;
1497 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1498 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1499 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1500 IHTMLElement3_Release(elem3);
1503 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1504 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1506 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1507 HRESULT hres;
1509 if (!elem3) return;
1510 hres = IHTMLElement3_put_disabled(elem3, b);
1511 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1513 IHTMLElement3_Release(elem3);
1514 _test_elem3_get_disabled(line, unk, b);
1517 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1518 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1520 VARIANT_BOOL disabled = 100;
1521 HRESULT hres;
1523 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1524 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1525 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1527 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1530 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1531 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1533 HRESULT hres;
1535 hres = IHTMLSelectElement_put_disabled(select, b);
1536 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1538 _test_select_get_disabled(line, select, b);
1541 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1542 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1544 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1545 IHTMLTextContainer *txtcont;
1546 LONG l = -1, l2 = -1;
1547 HRESULT hres;
1549 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1550 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1551 IHTMLElement2_Release(elem);
1553 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1554 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1556 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1557 IHTMLTextContainer_Release(txtcont);
1558 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1559 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1561 return l;
1564 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1565 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1567 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1568 IHTMLTextContainer *txtcont;
1569 LONG l = -1, l2 = -1;
1570 HRESULT hres;
1572 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1573 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1574 IHTMLElement2_Release(elem);
1576 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1577 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1579 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1580 IHTMLTextContainer_Release(txtcont);
1581 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1582 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1584 return l;
1587 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1588 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1590 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1591 IHTMLTextContainer *txtcont;
1592 LONG l = -1, l2 = -1;
1593 HRESULT hres;
1595 hres = IHTMLElement2_get_scrollTop(elem, &l);
1596 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1597 IHTMLElement2_Release(elem);
1599 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1600 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1602 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1603 IHTMLTextContainer_Release(txtcont);
1604 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1605 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1607 return l;
1610 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1611 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1613 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1614 IHTMLTextContainer *txtcont;
1615 LONG l = -1, l2 = -1;
1616 HRESULT hres;
1618 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1619 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1621 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1622 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1623 IHTMLElement2_Release(elem);
1625 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1626 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1628 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1629 IHTMLTextContainer_Release(txtcont);
1630 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1631 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1634 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1635 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1637 IHTMLImgElement *img = _get_img_iface(line, unk);
1638 BSTR src;
1639 HRESULT hres;
1641 hres = IHTMLImgElement_get_src(img, &src);
1642 IHTMLImgElement_Release(img);
1643 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1644 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1645 SysFreeString(src);
1648 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1649 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1651 IHTMLImgElement *img = _get_img_iface(line, unk);
1652 BSTR tmp;
1653 HRESULT hres;
1655 tmp = a2bstr(src);
1656 hres = IHTMLImgElement_put_src(img, tmp);
1657 IHTMLImgElement_Release(img);
1658 SysFreeString(tmp);
1659 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1661 _test_img_src(line, unk, src);
1664 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1665 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1667 IHTMLImgElement *img = _get_img_iface(line, unk);
1668 BSTR alt;
1669 HRESULT hres;
1671 hres = IHTMLImgElement_get_alt(img, &alt);
1672 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1673 if(exalt)
1674 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1675 else
1676 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1677 SysFreeString(alt);
1680 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1681 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1683 IHTMLImgElement *img = _get_img_iface(line, unk);
1684 BSTR tmp;
1685 HRESULT hres;
1687 tmp = a2bstr(alt);
1688 hres = IHTMLImgElement_put_alt(img, tmp);
1689 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1690 SysFreeString(tmp);
1692 _test_img_alt(line, unk, alt);
1695 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1696 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1698 VARIANT_BOOL disabled = 100;
1699 HRESULT hres;
1701 hres = IHTMLInputElement_get_disabled(input, &disabled);
1702 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1703 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1705 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1708 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1709 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1711 HRESULT hres;
1713 hres = IHTMLInputElement_put_disabled(input, b);
1714 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1716 _test_input_get_disabled(line, input, b);
1719 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1720 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1722 VARIANT_BOOL checked = 100;
1723 HRESULT hres;
1725 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1726 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1727 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1730 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1731 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1733 HRESULT hres;
1735 hres = IHTMLInputElement_put_defaultChecked(input, b);
1736 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1738 _test_input_get_defaultchecked(line, input, b);
1741 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1742 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1744 VARIANT_BOOL checked = 100;
1745 HRESULT hres;
1747 hres = IHTMLInputElement_get_checked(input, &checked);
1748 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1749 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1752 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1753 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1755 HRESULT hres;
1757 hres = IHTMLInputElement_put_checked(input, b);
1758 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1760 _test_input_get_checked(line, input, b);
1763 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1764 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1766 IHTMLInputElement *input;
1767 BSTR bstr;
1768 HRESULT hres;
1770 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1771 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1772 if(FAILED(hres))
1773 return;
1775 hres = IHTMLInputElement_get_value(input, &bstr);
1776 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1777 if(exval)
1778 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1779 else
1780 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1781 SysFreeString(bstr);
1782 IHTMLInputElement_Release(input);
1785 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1786 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1788 IHTMLInputElement *input;
1789 BSTR bstr;
1790 HRESULT hres;
1792 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1793 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1794 if(FAILED(hres))
1795 return;
1797 bstr = a2bstr(val);
1798 hres = IHTMLInputElement_get_value(input, &bstr);
1799 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1800 SysFreeString(bstr);
1801 IHTMLInputElement_Release(input);
1804 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1805 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1807 BSTR src;
1808 HRESULT hres;
1810 hres = IHTMLInputElement_get_src(input, &src);
1811 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1812 if(exsrc)
1813 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1814 else
1815 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1816 SysFreeString(src);
1819 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1820 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1822 BSTR tmp;
1823 HRESULT hres;
1825 tmp = a2bstr(src);
1826 hres = IHTMLInputElement_put_src(input, tmp);
1827 SysFreeString(tmp);
1828 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1830 _test_input_src(line, input, src);
1833 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1834 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1836 IHTMLElement *elem = _get_elem_iface(line, unk);
1837 BSTR class = (void*)0xdeadbeef;
1838 HRESULT hres;
1840 hres = IHTMLElement_get_className(elem, &class);
1841 IHTMLElement_Release(elem);
1842 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1843 if(exclass)
1844 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1845 else
1846 ok_(__FILE__,line) (!class, "class != NULL\n");
1847 SysFreeString(class);
1850 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1851 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1853 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1854 short index = -3;
1855 HRESULT hres;
1857 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1858 IHTMLElement2_Release(elem2);
1859 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1860 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1863 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1864 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1866 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1867 HRESULT hres;
1869 hres = IHTMLElement2_put_tabIndex(elem2, index);
1870 IHTMLElement2_Release(elem2);
1871 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1873 _test_elem_tabindex(line, unk, index);
1876 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1877 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1879 IHTMLElement *elem = _get_elem_iface(line, unk);
1880 BSTR tmp;
1881 HRESULT hres;
1883 tmp = class ? a2bstr(class) : NULL;
1884 hres = IHTMLElement_put_className(elem, tmp);
1885 IHTMLElement_Release(elem);
1886 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1887 SysFreeString(tmp);
1889 _test_elem_class(line, unk, class);
1892 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1893 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1895 IHTMLElement *elem = _get_elem_iface(line, unk);
1896 BSTR id = (void*)0xdeadbeef;
1897 HRESULT hres;
1899 hres = IHTMLElement_get_id(elem, &id);
1900 IHTMLElement_Release(elem);
1901 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1903 if(exid)
1904 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1905 else
1906 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1908 SysFreeString(id);
1911 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1912 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1914 IHTMLElement *elem = _get_elem_iface(line, unk);
1915 BSTR tmp = a2bstr(new_id);
1916 HRESULT hres;
1918 hres = IHTMLElement_put_id(elem, tmp);
1919 IHTMLElement_Release(elem);
1920 SysFreeString(tmp);
1921 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1923 _test_elem_id(line, unk, new_id);
1926 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1927 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1929 IHTMLElement *elem = _get_elem_iface(line, unk);
1930 BSTR title;
1931 HRESULT hres;
1933 hres = IHTMLElement_get_title(elem, &title);
1934 IHTMLElement_Release(elem);
1935 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1936 if(extitle)
1937 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1938 else
1939 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1941 SysFreeString(title);
1944 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1945 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1947 IHTMLElement *elem = _get_elem_iface(line, unk);
1948 BSTR tmp;
1949 HRESULT hres;
1951 tmp = a2bstr(title);
1952 hres = IHTMLElement_put_title(elem, tmp);
1953 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1955 IHTMLElement_Release(elem);
1956 SysFreeString(tmp);
1959 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1960 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1962 IHTMLDOMNode *node = _get_node_iface(line, unk);
1963 VARIANT var;
1964 HRESULT hres;
1966 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1967 IHTMLDOMNode_Release(node);
1968 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1970 if(exval) {
1971 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1972 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
1973 }else {
1974 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1977 VariantClear(&var);
1980 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1981 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1983 IHTMLDOMNode *node = _get_node_iface(line, unk);
1984 VARIANT var;
1985 HRESULT hres;
1987 V_VT(&var) = VT_BSTR;
1988 V_BSTR(&var) = a2bstr(val);
1990 hres = IHTMLDOMNode_put_nodeValue(node, var);
1991 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1992 IHTMLDOMNode_Release(node);
1993 VariantClear(&var);
1996 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1997 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1999 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2000 LONG l;
2001 HRESULT hres;
2003 hres = IHTMLElement2_get_clientWidth(elem, &l);
2004 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2005 hres = IHTMLElement2_get_clientHeight(elem, &l);
2006 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2008 IHTMLElement2_Release(elem);
2011 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2012 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2014 IHTMLElement *elem = NULL;
2015 BSTR tmp;
2016 HRESULT hres;
2018 tmp = a2bstr(tag);
2019 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2020 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2021 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2023 return elem;
2026 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2027 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2029 IHTMLDocument3 *doc3;
2030 IHTMLDOMNode *node = NULL;
2031 BSTR tmp;
2032 HRESULT hres;
2034 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2035 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2037 tmp = a2bstr(text);
2038 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2039 IHTMLDocument3_Release(doc3);
2040 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2041 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2043 return node;
2046 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2047 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2049 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2050 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2051 IHTMLDOMNode *new_child = NULL;
2052 HRESULT hres;
2054 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2055 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2056 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2057 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2059 IHTMLDOMNode_Release(node);
2060 IHTMLDOMNode_Release(child);
2062 return new_child;
2065 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2066 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2068 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2069 IHTMLDOMNode *new_child = NULL;
2070 HRESULT hres;
2072 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2073 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2074 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2075 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2077 IHTMLDOMNode_Release(node);
2079 return new_child;
2082 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2083 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2085 IHTMLDOMNode *node = _get_node_iface(line, unk);
2086 IHTMLDOMNode *new_node = NULL;
2087 HRESULT hres;
2089 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2090 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2091 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2092 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2094 IHTMLDOMNode_Release(node);
2095 IHTMLDOMNode_Release(new_node);
2098 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2099 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2101 BSTR title = NULL;
2102 HRESULT hres;
2104 hres = IHTMLDocument2_get_title(doc, &title);
2105 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2106 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2107 SysFreeString(title);
2110 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2111 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2113 BSTR tmp;
2114 HRESULT hres;
2116 tmp = a2bstr(title);
2117 hres = IHTMLDocument2_put_title(doc, tmp);
2118 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2119 SysFreeString(tmp);
2122 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2123 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2125 HRESULT hres;
2126 DISPID dispid;
2128 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2129 LOCALE_USER_DEFAULT, &dispid);
2130 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2131 if(hres == S_OK)
2133 DISPPARAMS params = {NULL,NULL,0,0};
2134 DISPID dispidNamed = DISPID_PROPERTYPUT;
2135 VARIANT ret;
2136 VARIANT vDefault;
2137 VARIANTARG arg;
2139 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2140 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2141 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2143 params.cArgs = 1;
2144 params.cNamedArgs = 1;
2145 params.rgdispidNamedArgs = &dispidNamed;
2146 V_VT(&arg) = VT_BSTR;
2147 V_BSTR(&arg) = a2bstr("none");
2148 params.rgvarg = &arg;
2149 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2150 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2151 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2152 VariantClear(&arg);
2154 V_VT(&arg) = VT_BSTR;
2155 V_BSTR(&arg) = a2bstr("dotted");
2156 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2157 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2158 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2159 VariantClear(&arg);
2161 V_VT(&arg) = VT_BSTR;
2162 V_BSTR(&arg) = a2bstr("dashed");
2163 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2164 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2165 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2166 VariantClear(&arg);
2168 V_VT(&arg) = VT_BSTR;
2169 V_BSTR(&arg) = a2bstr("solid");
2170 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2171 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2172 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2173 VariantClear(&arg);
2175 V_VT(&arg) = VT_BSTR;
2176 V_BSTR(&arg) = a2bstr("double");
2177 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2178 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2179 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2180 VariantClear(&arg);
2182 V_VT(&arg) = VT_BSTR;
2183 V_BSTR(&arg) = a2bstr("groove");
2184 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2185 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2186 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2187 VariantClear(&arg);
2189 V_VT(&arg) = VT_BSTR;
2190 V_BSTR(&arg) = a2bstr("ridge");
2191 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2192 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2193 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2194 VariantClear(&arg);
2196 V_VT(&arg) = VT_BSTR;
2197 V_BSTR(&arg) = a2bstr("inset");
2198 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2199 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2200 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2201 VariantClear(&arg);
2203 V_VT(&arg) = VT_BSTR;
2204 V_BSTR(&arg) = a2bstr("outset");
2205 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2206 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2207 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2208 VariantClear(&arg);
2210 V_VT(&arg) = VT_BSTR;
2211 V_BSTR(&arg) = a2bstr("invalid");
2212 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2213 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2214 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2215 VariantClear(&arg);
2217 params.rgvarg = &vDefault;
2218 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2219 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2220 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2224 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2225 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2227 BSTR text = (void*)0xdeadbeef;
2228 HRESULT hres;
2230 hres = IHTMLStyle_get_cssText(style, &text);
2231 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2232 if(extext)
2233 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2234 else
2235 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2237 SysFreeString(text);
2240 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2241 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2243 BSTR tmp;
2244 HRESULT hres;
2246 tmp = a2bstr(text);
2247 hres = IHTMLStyle_put_cssText(style, tmp);
2248 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2249 SysFreeString(tmp);
2252 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2253 const elem_type_t *elem_types, LONG len)
2255 IDispatch *disp;
2256 VARIANT name, index;
2257 DWORD i;
2258 HRESULT hres;
2260 V_VT(&index) = VT_EMPTY;
2261 V_VT(&name) = VT_BSTR;
2262 V_BSTR(&name) = a2bstr(n);
2264 hres = IHTMLElementCollection_item(col, name, index, &disp);
2265 ok(hres == S_OK, "item failed: %08x\n", hres);
2267 test_elem_collection((IUnknown*)disp, elem_types, len);
2268 IDispatch_Release(disp);
2269 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2270 if(hres != S_OK)
2271 goto cleanup;
2273 V_VT(&index) = VT_I4;
2275 for(i=0; i<len; i++) {
2276 V_I4(&index) = i;
2277 disp = (void*)0xdeadbeef;
2278 hres = IHTMLElementCollection_item(col, name, index, &disp);
2279 ok(hres == S_OK, "item failed: %08x\n", hres);
2280 ok(disp != NULL, "disp == NULL\n");
2281 if(FAILED(hres) || !disp)
2282 continue;
2284 test_elem_type((IUnknown*)disp, elem_types[i]);
2286 IDispatch_Release(disp);
2289 V_I4(&index) = len;
2290 disp = (void*)0xdeadbeef;
2291 hres = IHTMLElementCollection_item(col, name, index, &disp);
2292 ok(hres == S_OK, "item failed: %08x\n", hres);
2293 ok(disp == NULL, "disp != NULL\n");
2295 V_I4(&index) = -1;
2296 disp = (void*)0xdeadbeef;
2297 hres = IHTMLElementCollection_item(col, name, index, &disp);
2298 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2299 ok(disp == NULL, "disp != NULL\n");
2301 cleanup:
2302 SysFreeString(V_BSTR(&name));
2305 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2307 IHTMLElementCollection *col;
2308 IHTMLElement *elem;
2309 IDispatch *disp = (void*)0xdeadbeef;
2310 VARIANT name, index;
2311 HRESULT hres;
2313 hres = IHTMLDocument2_get_all(doc, &col);
2314 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2315 ok(col != NULL, "col == NULL\n");
2316 if(FAILED(hres) || !col)
2317 return NULL;
2319 V_VT(&index) = VT_EMPTY;
2320 V_VT(&name) = VT_BSTR;
2321 V_BSTR(&name) = a2bstr(id);
2323 hres = IHTMLElementCollection_item(col, name, index, &disp);
2324 IHTMLElementCollection_Release(col);
2325 SysFreeString(V_BSTR(&name));
2326 ok(hres == S_OK, "item failed: %08x\n", hres);
2327 if(!expect_success) {
2328 ok(disp == NULL, "disp != NULL\n");
2329 return NULL;
2332 ok(disp != NULL, "disp == NULL\n");
2333 if(!disp)
2334 return NULL;
2336 elem = get_elem_iface((IUnknown*)disp);
2337 IDispatch_Release(disp);
2339 return elem;
2342 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2344 IHTMLDocument3 *doc3;
2345 IHTMLElement *elem;
2346 BSTR tmp;
2347 HRESULT hres;
2349 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2350 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2352 tmp = a2bstr(id);
2353 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2354 SysFreeString(tmp);
2355 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2357 IHTMLDocument3_Release(doc3);
2359 return elem;
2362 static void test_select_elem(IHTMLSelectElement *select)
2364 test_select_type(select, "select-one");
2365 test_select_length(select, 2);
2366 test_select_selidx(select, 0);
2367 test_select_put_selidx(select, 1);
2369 test_select_set_value(select, "val1");
2370 test_select_value(select, "val1");
2372 test_select_get_disabled(select, VARIANT_FALSE);
2373 test_select_set_disabled(select, VARIANT_TRUE);
2374 test_select_set_disabled(select, VARIANT_FALSE);
2377 static void test_create_option_elem(IHTMLDocument2 *doc)
2379 IHTMLOptionElement *option;
2381 option = create_option_elem(doc, "test text", "test value");
2383 test_option_put_text(option, "new text");
2384 test_option_put_value(option, "new value");
2386 IHTMLOptionElement_Release(option);
2389 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2391 IHTMLBodyElement *body;
2392 IHTMLTxtRange *range;
2393 IHTMLElement *elem;
2394 HRESULT hres;
2396 hres = IHTMLDocument2_get_body(doc, &elem);
2397 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2399 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2400 IHTMLElement_Release(elem);
2402 hres = IHTMLBodyElement_createTextRange(body, &range);
2403 IHTMLBodyElement_Release(body);
2404 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2406 return range;
2409 static void test_txtrange(IHTMLDocument2 *doc)
2411 IHTMLTxtRange *body_range, *range, *range2;
2412 IHTMLSelectionObject *selection;
2413 IDispatch *disp_range;
2414 HRESULT hres;
2416 body_range = test_create_body_range(doc);
2418 test_range_text(body_range, "test abc 123\r\nit's text");
2420 hres = IHTMLTxtRange_duplicate(body_range, &range);
2421 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2423 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2424 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2425 test_range_isequal(range, range2, VARIANT_TRUE);
2427 test_range_text(range, "test abc 123\r\nit's text");
2428 test_range_text(body_range, "test abc 123\r\nit's text");
2430 test_range_collapse(range, TRUE);
2431 test_range_isequal(range, range2, VARIANT_FALSE);
2432 test_range_inrange(range, range2, VARIANT_FALSE);
2433 test_range_inrange(range2, range, VARIANT_TRUE);
2434 IHTMLTxtRange_Release(range2);
2436 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2437 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2438 test_range_move(range, characterW, 2, 2);
2439 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2441 test_range_collapse(range, FALSE);
2442 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2444 test_range_collapse(range, FALSE);
2445 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2446 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2447 test_range_move(range, characterW, 2, 2);
2448 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2449 test_range_moveend(range, characterW, -5, -5);
2450 test_range_text(range, NULL);
2451 test_range_moveend(range, characterW, 3, 3);
2452 test_range_text(range, "c 1");
2453 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2454 test_range_collapse(range, TRUE);
2455 test_range_move(range, characterW, 4, 4);
2456 test_range_moveend(range, characterW, 1, 1);
2457 test_range_text(range, " ");
2458 test_range_move(range, wordW, 1, 1);
2459 test_range_moveend(range, characterW, 2, 2);
2460 test_range_text(range, "ab");
2462 IHTMLTxtRange_Release(range);
2464 hres = IHTMLTxtRange_duplicate(body_range, &range);
2465 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2467 test_range_text(range, "test abc 123\r\nit's text");
2468 test_range_move(range, characterW, 3, 3);
2469 test_range_moveend(range, characterW, 1, 1);
2470 test_range_text(range, "t");
2471 test_range_moveend(range, characterW, 3, 3);
2472 test_range_text(range, "t ab");
2473 test_range_moveend(range, characterW, -2, -2);
2474 test_range_text(range, "t ");
2475 test_range_move(range, characterW, 6, 6);
2476 test_range_moveend(range, characterW, 3, 3);
2477 test_range_text(range, "123");
2478 test_range_moveend(range, characterW, 2, 2);
2479 test_range_text(range, "123\r\ni");
2481 IHTMLTxtRange_Release(range);
2483 hres = IHTMLTxtRange_duplicate(body_range, &range);
2484 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2486 test_range_move(range, wordW, 1, 1);
2487 test_range_moveend(range, characterW, 2, 2);
2488 test_range_text(range, "ab");
2490 test_range_move(range, characterW, -2, -2);
2491 test_range_moveend(range, characterW, 2, 2);
2492 test_range_text(range, "t ");
2494 test_range_move(range, wordW, 3, 3);
2495 test_range_move(range, wordW, -2, -2);
2496 test_range_moveend(range, characterW, 2, 2);
2497 test_range_text(range, "ab");
2499 test_range_move(range, characterW, -6, -5);
2500 test_range_moveend(range, characterW, -1, 0);
2501 test_range_moveend(range, characterW, -6, 0);
2502 test_range_move(range, characterW, 2, 2);
2503 test_range_moveend(range, characterW, 2, 2);
2504 test_range_text(range, "st");
2505 test_range_moveend(range, characterW, -6, -4);
2506 test_range_moveend(range, characterW, 2, 2);
2508 IHTMLTxtRange_Release(range);
2510 hres = IHTMLTxtRange_duplicate(body_range, &range);
2511 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2513 test_range_move(range, wordW, 2, 2);
2514 test_range_moveend(range, characterW, 2, 2);
2515 test_range_text(range, "12");
2517 test_range_move(range, characterW, 15, 14);
2518 test_range_move(range, characterW, -2, -2);
2519 test_range_moveend(range, characterW, 3, 2);
2520 test_range_text(range, "t");
2521 test_range_moveend(range, characterW, -1, -1);
2522 test_range_text(range, "t");
2523 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2524 test_range_move(range, characterW, -2, -2);
2525 test_range_moveend(range, characterW, 2, 2);
2526 test_range_text(range, "s ");
2527 test_range_move(range, characterW, 100, 7);
2528 test_range_move(range, wordW, 1, 0);
2529 test_range_move(range, characterW, -2, -2);
2530 test_range_moveend(range, characterW, 3, 2);
2531 test_range_text(range, "t");
2533 IHTMLTxtRange_Release(range);
2535 hres = IHTMLTxtRange_duplicate(body_range, &range);
2536 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2538 test_range_collapse(range, TRUE);
2539 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2540 test_range_put_text(range, "word");
2541 test_range_text(body_range, "wordabc 123\r\nit's text");
2542 test_range_text(range, NULL);
2543 test_range_moveend(range, characterW, 3, 3);
2544 test_range_text(range, "abc");
2545 test_range_movestart(range, characterW, -2, -2);
2546 test_range_text(range, "rdabc");
2547 test_range_movestart(range, characterW, 3, 3);
2548 test_range_text(range, "bc");
2549 test_range_movestart(range, characterW, 4, 4);
2550 test_range_text(range, NULL);
2551 test_range_movestart(range, characterW, -3, -3);
2552 test_range_text(range, "c 1");
2553 test_range_movestart(range, characterW, -7, -6);
2554 test_range_text(range, "wordabc 1");
2555 test_range_movestart(range, characterW, 100, 22);
2556 test_range_text(range, NULL);
2558 IHTMLTxtRange_Release(range);
2559 IHTMLTxtRange_Release(body_range);
2561 hres = IHTMLDocument2_get_selection(doc, &selection);
2562 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2564 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2565 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2566 IHTMLSelectionObject_Release(selection);
2568 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2569 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2570 IDispatch_Release(disp_range);
2572 test_range_text(range, NULL);
2573 test_range_moveend(range, characterW, 3, 3);
2574 test_range_text(range, "wor");
2575 test_range_parent(range, ET_BODY);
2576 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2577 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2578 test_range_move(range, characterW, 3, 3);
2579 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2580 test_range_moveend(range, characterW, -4, -4);
2581 test_range_put_text(range, "abc def ");
2582 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2583 test_range_move(range, wordW, 1, 1);
2584 test_range_movestart(range, characterW, -1, -1);
2585 test_range_text(range, " ");
2586 test_range_move(range, wordW, 1, 1);
2587 test_range_moveend(range, characterW, 3, 3);
2588 test_range_text(range, "def");
2589 test_range_put_text(range, "xyz");
2590 test_range_moveend(range, characterW, 1, 1);
2591 test_range_move(range, wordW, 1, 1);
2592 test_range_moveend(range, characterW, 2, 2);
2593 test_range_text(range, "ab");
2595 IHTMLTxtRange_Release(range);
2598 static void test_txtrange2(IHTMLDocument2 *doc)
2600 IHTMLTxtRange *range;
2602 range = test_create_body_range(doc);
2604 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2605 test_range_move(range, characterW, 5, 5);
2606 test_range_moveend(range, characterW, 1, 1);
2607 test_range_text(range, "2");
2608 test_range_move(range, characterW, -3, -3);
2609 test_range_moveend(range, characterW, 3, 3);
2610 test_range_text(range, "c\r\n\r\n1");
2611 test_range_collapse(range, VARIANT_FALSE);
2612 test_range_moveend(range, characterW, 4, 4);
2613 test_range_text(range, "23");
2614 test_range_moveend(range, characterW, 1, 1);
2615 test_range_text(range, "23\r\n\r\n\r\nd");
2616 test_range_moveend(range, characterW, -1, -1);
2617 test_range_text(range, "23");
2618 test_range_moveend(range, characterW, -1, -1);
2619 test_range_text(range, "23");
2620 test_range_moveend(range, characterW, -2, -2);
2621 test_range_text(range, "2");
2623 IHTMLTxtRange_Release(range);
2626 static void test_compatmode(IHTMLDocument2 *doc)
2628 IHTMLDocument5 *doc5;
2629 BSTR mode;
2630 HRESULT hres;
2632 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2633 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2634 if(FAILED(hres))
2635 return;
2637 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2638 IHTMLDocument5_Release(doc5);
2639 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2640 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2641 SysFreeString(mode);
2644 static void test_location(IHTMLDocument2 *doc)
2646 IHTMLLocation *location, *location2;
2647 IHTMLWindow2 *window;
2648 BSTR str;
2649 ULONG ref;
2650 HRESULT hres;
2652 hres = IHTMLDocument2_get_location(doc, &location);
2653 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2655 hres = IHTMLDocument2_get_location(doc, &location2);
2656 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2658 ok(location == location2, "location != location2\n");
2659 IHTMLLocation_Release(location2);
2661 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2662 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2664 hres = IHTMLWindow2_get_location(window, &location2);
2665 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2666 ok(location == location2, "location != location2\n");
2667 IHTMLLocation_Release(location2);
2669 test_ifaces((IUnknown*)location, location_iids);
2670 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2672 hres = IHTMLLocation_get_pathname(location, &str);
2673 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2674 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2676 hres = IHTMLLocation_get_href(location, NULL);
2677 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2679 hres = IHTMLLocation_get_href(location, &str);
2680 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2681 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2683 ref = IHTMLLocation_Release(location);
2684 ok(!ref, "location chould be destroyed here\n");
2687 static void test_navigator(IHTMLDocument2 *doc)
2689 IHTMLWindow2 *window;
2690 IOmNavigator *navigator, *navigator2;
2691 char buf[512];
2692 DWORD size;
2693 ULONG ref;
2694 BSTR bstr;
2695 HRESULT hres;
2697 static const WCHAR v40[] = {'4','.','0'};
2699 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2700 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2702 hres = IHTMLWindow2_get_navigator(window, &navigator);
2703 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2704 ok(navigator != NULL, "navigator == NULL\n");
2705 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2707 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2708 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2709 ok(navigator != navigator2, "navigator2 != navihgator\n");
2711 IHTMLWindow2_Release(window);
2712 IOmNavigator_Release(navigator2);
2714 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2715 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2716 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2717 SysFreeString(bstr);
2719 bstr = NULL;
2720 hres = IOmNavigator_get_appName(navigator, &bstr);
2721 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2722 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2723 SysFreeString(bstr);
2725 bstr = NULL;
2726 hres = IOmNavigator_get_platform(navigator, &bstr);
2727 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2728 #ifdef _WIN64
2729 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2730 #else
2731 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2732 #endif
2733 SysFreeString(bstr);
2735 bstr = NULL;
2736 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2737 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2738 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2739 SysFreeString(bstr);
2741 hres = IOmNavigator_toString(navigator, NULL);
2742 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2744 bstr = NULL;
2745 hres = IOmNavigator_toString(navigator, &bstr);
2746 ok(hres == S_OK, "toString failed: %08x\n", hres);
2747 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2748 SysFreeString(bstr);
2750 size = sizeof(buf);
2751 hres = ObtainUserAgentString(0, buf, &size);
2752 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2754 bstr = NULL;
2755 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2756 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2757 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2758 SysFreeString(bstr);
2760 ref = IOmNavigator_Release(navigator);
2761 ok(!ref, "navigator should be destroyed here\n");
2764 static void test_current_style(IHTMLCurrentStyle *current_style)
2766 BSTR str;
2767 HRESULT hres;
2768 VARIANT v;
2770 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2771 test_ifaces((IUnknown*)current_style, cstyle_iids);
2773 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2774 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2775 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2776 SysFreeString(str);
2778 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2779 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2780 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2781 SysFreeString(str);
2783 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2784 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2785 SysFreeString(str);
2787 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2788 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2789 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2790 SysFreeString(str);
2792 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2793 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2794 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2795 SysFreeString(str);
2797 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2798 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2799 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2800 SysFreeString(str);
2802 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2803 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2804 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2805 SysFreeString(str);
2807 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2808 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2809 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2810 SysFreeString(str);
2812 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2813 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2814 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2815 SysFreeString(str);
2817 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2818 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2819 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2820 SysFreeString(str);
2822 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2823 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2824 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2825 SysFreeString(str);
2827 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2828 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2829 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2830 SysFreeString(str);
2832 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2833 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2834 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2835 SysFreeString(str);
2837 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2838 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2839 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2840 SysFreeString(str);
2842 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2843 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2844 SysFreeString(str);
2846 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2847 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2848 SysFreeString(str);
2850 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2851 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2852 SysFreeString(str);
2854 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2855 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2856 SysFreeString(str);
2858 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2859 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2860 SysFreeString(str);
2862 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2863 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2864 SysFreeString(str);
2866 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2867 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2868 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2869 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2870 VariantClear(&v);
2872 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2873 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2874 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2875 VariantClear(&v);
2877 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2878 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2879 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2880 VariantClear(&v);
2882 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2883 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2884 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2885 VariantClear(&v);
2887 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2888 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2889 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2890 VariantClear(&v);
2892 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2893 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2894 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2895 VariantClear(&v);
2897 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2898 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2899 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2900 VariantClear(&v);
2902 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2903 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2904 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2905 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2906 VariantClear(&v);
2908 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2909 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2910 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2911 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2912 VariantClear(&v);
2914 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2915 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2916 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2917 VariantClear(&v);
2919 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2920 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2921 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2922 VariantClear(&v);
2924 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2925 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2926 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2927 VariantClear(&v);
2929 V_BSTR(&v) = NULL;
2930 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2931 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2932 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2933 VariantClear(&v);
2935 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2936 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2937 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2938 VariantClear(&v);
2940 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2941 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2942 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2943 VariantClear(&v);
2945 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2946 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2947 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2948 VariantClear(&v);
2950 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2951 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2952 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2953 VariantClear(&v);
2955 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
2956 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
2957 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2958 VariantClear(&v);
2960 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
2961 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
2962 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2963 VariantClear(&v);
2965 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
2966 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
2967 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2968 VariantClear(&v);
2970 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
2971 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
2972 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2973 VariantClear(&v);
2975 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
2976 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
2977 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2978 VariantClear(&v);
2980 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
2981 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2982 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2983 VariantClear(&v);
2985 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
2986 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2987 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2988 VariantClear(&v);
2990 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
2991 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
2992 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2993 VariantClear(&v);
2995 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
2996 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
2997 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2998 VariantClear(&v);
3000 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3001 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3002 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3003 VariantClear(&v);
3005 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3006 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3007 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3008 VariantClear(&v);
3010 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3011 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3012 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3013 VariantClear(&v);
3015 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3016 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3017 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3018 VariantClear(&v);
3020 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3021 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3022 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3023 VariantClear(&v);
3026 static void test_style2(IHTMLStyle2 *style2)
3028 BSTR str;
3029 HRESULT hres;
3031 str = (void*)0xdeadbeef;
3032 hres = IHTMLStyle2_get_position(style2, &str);
3033 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3034 ok(!str, "str != NULL\n");
3036 str = a2bstr("absolute");
3037 hres = IHTMLStyle2_put_position(style2, str);
3038 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3039 SysFreeString(str);
3041 str = NULL;
3042 hres = IHTMLStyle2_get_position(style2, &str);
3043 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3044 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3045 SysFreeString(str);
3048 static void test_style3(IHTMLStyle3 *style3)
3050 BSTR str;
3051 HRESULT hres;
3053 str = (void*)0xdeadbeef;
3054 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3055 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3056 ok(!str, "str != NULL\n");
3058 str = a2bstr("break-word");
3059 hres = IHTMLStyle3_put_wordWrap(style3, str);
3060 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3061 SysFreeString(str);
3063 str = NULL;
3064 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3065 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3066 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3067 SysFreeString(str);
3070 static void test_style4(IHTMLStyle4 *style4)
3072 HRESULT hres;
3073 VARIANT v;
3074 VARIANT vdefault;
3076 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3077 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3079 V_VT(&v) = VT_BSTR;
3080 V_BSTR(&v) = a2bstr("10px");
3081 hres = IHTMLStyle4_put_minHeight(style4, v);
3082 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3083 VariantClear(&v);
3085 hres = IHTMLStyle4_get_minHeight(style4, &v);
3086 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3087 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3088 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3090 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3091 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3092 VariantClear(&vdefault);
3095 static void test_default_style(IHTMLStyle *style)
3097 IHTMLStyle2 *style2;
3098 IHTMLStyle3 *style3;
3099 IHTMLStyle4 *style4;
3100 VARIANT_BOOL b;
3101 VARIANT v;
3102 BSTR str;
3103 HRESULT hres;
3104 float f;
3105 BSTR sOverflowDefault;
3106 BSTR sDefault;
3107 VARIANT vDefault;
3109 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3110 test_ifaces((IUnknown*)style, style_iids);
3112 test_style_csstext(style, NULL);
3114 hres = IHTMLStyle_get_position(style, &str);
3115 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3116 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3118 V_VT(&v) = VT_NULL;
3119 hres = IHTMLStyle_get_marginRight(style, &v);
3120 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3121 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3122 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3124 V_VT(&v) = VT_NULL;
3125 hres = IHTMLStyle_get_marginLeft(style, &v);
3126 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3127 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3128 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3130 str = (void*)0xdeadbeef;
3131 hres = IHTMLStyle_get_fontFamily(style, &str);
3132 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3133 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3135 str = (void*)0xdeadbeef;
3136 hres = IHTMLStyle_get_fontWeight(style, &str);
3137 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3138 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3140 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3141 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3143 str = a2bstr("test");
3144 hres = IHTMLStyle_put_fontWeight(style, str);
3145 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3146 SysFreeString(str);
3148 str = a2bstr("bold");
3149 hres = IHTMLStyle_put_fontWeight(style, str);
3150 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3151 SysFreeString(str);
3153 str = a2bstr("bolder");
3154 hres = IHTMLStyle_put_fontWeight(style, str);
3155 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3156 SysFreeString(str);
3158 str = a2bstr("lighter");
3159 hres = IHTMLStyle_put_fontWeight(style, str);
3160 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3161 SysFreeString(str);
3163 str = a2bstr("100");
3164 hres = IHTMLStyle_put_fontWeight(style, str);
3165 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3166 SysFreeString(str);
3168 str = a2bstr("200");
3169 hres = IHTMLStyle_put_fontWeight(style, str);
3170 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3171 SysFreeString(str);
3173 str = a2bstr("300");
3174 hres = IHTMLStyle_put_fontWeight(style, str);
3175 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3176 SysFreeString(str);
3178 str = a2bstr("400");
3179 hres = IHTMLStyle_put_fontWeight(style, str);
3180 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3181 SysFreeString(str);
3183 str = a2bstr("500");
3184 hres = IHTMLStyle_put_fontWeight(style, str);
3185 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3186 SysFreeString(str);
3188 str = a2bstr("600");
3189 hres = IHTMLStyle_put_fontWeight(style, str);
3190 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3191 SysFreeString(str);
3193 str = a2bstr("700");
3194 hres = IHTMLStyle_put_fontWeight(style, str);
3195 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3196 SysFreeString(str);
3198 str = a2bstr("800");
3199 hres = IHTMLStyle_put_fontWeight(style, str);
3200 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3201 SysFreeString(str);
3203 str = a2bstr("900");
3204 hres = IHTMLStyle_put_fontWeight(style, str);
3205 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3206 SysFreeString(str);
3208 hres = IHTMLStyle_get_fontWeight(style, &str);
3209 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3210 ok(!strcmp_wa(str, "900"), "str != style900\n");
3211 SysFreeString(str);
3213 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3214 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3215 SysFreeString(sDefault);
3217 /* font Variant */
3218 hres = IHTMLStyle_get_fontVariant(style, NULL);
3219 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3221 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3222 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3224 str = a2bstr("test");
3225 hres = IHTMLStyle_put_fontVariant(style, str);
3226 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3227 SysFreeString(str);
3229 str = a2bstr("small-caps");
3230 hres = IHTMLStyle_put_fontVariant(style, str);
3231 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3232 SysFreeString(str);
3234 str = a2bstr("normal");
3235 hres = IHTMLStyle_put_fontVariant(style, str);
3236 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3237 SysFreeString(str);
3239 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3240 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3241 SysFreeString(sDefault);
3243 str = (void*)0xdeadbeef;
3244 hres = IHTMLStyle_get_display(style, &str);
3245 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3246 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3248 str = (void*)0xdeadbeef;
3249 hres = IHTMLStyle_get_visibility(style, &str);
3250 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3251 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3253 V_VT(&v) = VT_NULL;
3254 hres = IHTMLStyle_get_fontSize(style, &v);
3255 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3256 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3257 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3259 V_VT(&v) = VT_NULL;
3260 hres = IHTMLStyle_get_color(style, &v);
3261 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3262 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3263 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3265 b = 0xfefe;
3266 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3267 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3268 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3270 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3271 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3272 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3274 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3275 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3276 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3278 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3279 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3281 b = 0xfefe;
3282 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3283 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3284 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3286 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3287 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3288 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3290 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3291 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3292 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3294 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3295 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3297 b = 0xfefe;
3298 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3299 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3300 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3302 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3303 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3304 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3306 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3307 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3308 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3310 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3311 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3313 b = 0xfefe;
3314 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3315 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3316 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3318 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3319 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3320 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3322 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3323 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3324 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3326 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3327 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3329 b = 0xfefe;
3330 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3331 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3332 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3334 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3335 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3336 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3338 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3339 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3340 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3342 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3343 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3345 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3346 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3348 str = a2bstr("invalid");
3349 hres = IHTMLStyle_put_textDecoration(style, str);
3350 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3351 SysFreeString(str);
3353 str = a2bstr("none");
3354 hres = IHTMLStyle_put_textDecoration(style, str);
3355 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3356 SysFreeString(str);
3358 str = a2bstr("underline");
3359 hres = IHTMLStyle_put_textDecoration(style, str);
3360 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3361 SysFreeString(str);
3363 str = a2bstr("overline");
3364 hres = IHTMLStyle_put_textDecoration(style, str);
3365 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3366 SysFreeString(str);
3368 str = a2bstr("line-through");
3369 hres = IHTMLStyle_put_textDecoration(style, str);
3370 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3371 SysFreeString(str);
3373 str = a2bstr("blink");
3374 hres = IHTMLStyle_put_textDecoration(style, str);
3375 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3376 SysFreeString(str);
3378 hres = IHTMLStyle_get_textDecoration(style, &str);
3379 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3380 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3381 SysFreeString(str);
3383 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3384 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3385 SysFreeString(sDefault);
3387 hres = IHTMLStyle_get_posWidth(style, NULL);
3388 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3390 hres = IHTMLStyle_get_posWidth(style, &f);
3391 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3392 ok(f == 0.0f, "f = %f\n", f);
3394 V_VT(&v) = VT_EMPTY;
3395 hres = IHTMLStyle_get_width(style, &v);
3396 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3397 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3398 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3400 hres = IHTMLStyle_put_posWidth(style, 2.2);
3401 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3403 hres = IHTMLStyle_get_posWidth(style, &f);
3404 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3405 ok(f == 2.0f ||
3406 f == 2.2f, /* IE8 */
3407 "f = %f\n", f);
3409 V_VT(&v) = VT_BSTR;
3410 V_BSTR(&v) = a2bstr("auto");
3411 hres = IHTMLStyle_put_width(style, v);
3412 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3413 VariantClear(&v);
3415 V_VT(&v) = VT_EMPTY;
3416 hres = IHTMLStyle_get_width(style, &v);
3417 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3418 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3419 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3420 VariantClear(&v);
3422 /* margin tests */
3423 str = (void*)0xdeadbeef;
3424 hres = IHTMLStyle_get_margin(style, &str);
3425 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3426 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3428 str = a2bstr("1");
3429 hres = IHTMLStyle_put_margin(style, str);
3430 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3431 SysFreeString(str);
3433 hres = IHTMLStyle_get_margin(style, &str);
3434 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3435 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3437 hres = IHTMLStyle_put_margin(style, NULL);
3438 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3440 str = NULL;
3441 hres = IHTMLStyle_get_border(style, &str);
3442 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3443 ok(!str || !*str, "str is not empty\n");
3444 SysFreeString(str);
3446 str = a2bstr("1px");
3447 hres = IHTMLStyle_put_border(style, str);
3448 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3449 SysFreeString(str);
3451 V_VT(&v) = VT_EMPTY;
3452 hres = IHTMLStyle_get_left(style, &v);
3453 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3454 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3455 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3456 VariantClear(&v);
3458 /* Test posLeft */
3459 hres = IHTMLStyle_get_posLeft(style, NULL);
3460 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3462 f = 1.0f;
3463 hres = IHTMLStyle_get_posLeft(style, &f);
3464 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3465 ok(f == 0.0, "expected 0.0 got %f\n", f);
3467 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3468 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3470 hres = IHTMLStyle_get_posLeft(style, &f);
3471 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3472 ok(f == 4.0 ||
3473 f == 4.9f, /* IE8 */
3474 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3476 /* Ensure left is updated correctly. */
3477 V_VT(&v) = VT_EMPTY;
3478 hres = IHTMLStyle_get_left(style, &v);
3479 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3480 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3481 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3482 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3483 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3484 VariantClear(&v);
3486 /* Test left */
3487 V_VT(&v) = VT_BSTR;
3488 V_BSTR(&v) = a2bstr("3px");
3489 hres = IHTMLStyle_put_left(style, v);
3490 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3491 VariantClear(&v);
3493 hres = IHTMLStyle_get_posLeft(style, &f);
3494 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3495 ok(f == 3.0, "expected 3.0 got %f\n", f);
3497 V_VT(&v) = VT_EMPTY;
3498 hres = IHTMLStyle_get_left(style, &v);
3499 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3500 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3501 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3502 VariantClear(&v);
3504 V_VT(&v) = VT_NULL;
3505 hres = IHTMLStyle_put_left(style, v);
3506 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3508 V_VT(&v) = VT_EMPTY;
3509 hres = IHTMLStyle_get_left(style, &v);
3510 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3511 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3512 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3513 VariantClear(&v);
3515 V_VT(&v) = VT_EMPTY;
3516 hres = IHTMLStyle_get_top(style, &v);
3517 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3518 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3519 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3520 VariantClear(&v);
3522 /* Test posTop */
3523 hres = IHTMLStyle_get_posTop(style, NULL);
3524 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3526 f = 1.0f;
3527 hres = IHTMLStyle_get_posTop(style, &f);
3528 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3529 ok(f == 0.0, "expected 0.0 got %f\n", f);
3531 hres = IHTMLStyle_put_posTop(style, 4.9f);
3532 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3534 hres = IHTMLStyle_get_posTop(style, &f);
3535 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3536 ok(f == 4.0 ||
3537 f == 4.9f, /* IE8 */
3538 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3540 V_VT(&v) = VT_BSTR;
3541 V_BSTR(&v) = a2bstr("3px");
3542 hres = IHTMLStyle_put_top(style, v);
3543 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3544 VariantClear(&v);
3546 V_VT(&v) = VT_EMPTY;
3547 hres = IHTMLStyle_get_top(style, &v);
3548 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3549 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3550 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3551 VariantClear(&v);
3553 hres = IHTMLStyle_get_posTop(style, &f);
3554 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3555 ok(f == 3.0, "expected 3.0 got %f\n", f);
3557 V_VT(&v) = VT_NULL;
3558 hres = IHTMLStyle_put_top(style, v);
3559 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3561 V_VT(&v) = VT_EMPTY;
3562 hres = IHTMLStyle_get_top(style, &v);
3563 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3564 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3565 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3566 VariantClear(&v);
3568 /* Test posHeight */
3569 hres = IHTMLStyle_get_posHeight(style, NULL);
3570 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3572 V_VT(&v) = VT_EMPTY;
3573 hres = IHTMLStyle_get_height(style, &v);
3574 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3575 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3576 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3577 VariantClear(&v);
3579 f = 1.0f;
3580 hres = IHTMLStyle_get_posHeight(style, &f);
3581 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3582 ok(f == 0.0, "expected 0.0 got %f\n", f);
3584 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3585 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3587 hres = IHTMLStyle_get_posHeight(style, &f);
3588 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3589 ok(f == 4.0 ||
3590 f == 4.9f, /* IE8 */
3591 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3593 V_VT(&v) = VT_BSTR;
3594 V_BSTR(&v) = a2bstr("64px");
3595 hres = IHTMLStyle_put_height(style, v);
3596 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3597 VariantClear(&v);
3599 V_VT(&v) = VT_EMPTY;
3600 hres = IHTMLStyle_get_height(style, &v);
3601 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3602 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3603 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3604 VariantClear(&v);
3606 hres = IHTMLStyle_get_posHeight(style, &f);
3607 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3608 ok(f == 64.0, "expected 64.0 got %f\n", f);
3610 str = (void*)0xdeadbeef;
3611 hres = IHTMLStyle_get_cursor(style, &str);
3612 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3613 ok(!str, "get_cursor != NULL\n");
3614 SysFreeString(str);
3616 str = a2bstr("default");
3617 hres = IHTMLStyle_put_cursor(style, str);
3618 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3619 SysFreeString(str);
3621 str = NULL;
3622 hres = IHTMLStyle_get_cursor(style, &str);
3623 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3624 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3625 SysFreeString(str);
3627 V_VT(&v) = VT_EMPTY;
3628 hres = IHTMLStyle_get_verticalAlign(style, &v);
3629 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3630 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3631 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3632 VariantClear(&v);
3634 V_VT(&v) = VT_BSTR;
3635 V_BSTR(&v) = a2bstr("middle");
3636 hres = IHTMLStyle_put_verticalAlign(style, v);
3637 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3638 VariantClear(&v);
3640 V_VT(&v) = VT_EMPTY;
3641 hres = IHTMLStyle_get_verticalAlign(style, &v);
3642 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3643 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3644 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3645 VariantClear(&v);
3647 str = (void*)0xdeadbeef;
3648 hres = IHTMLStyle_get_textAlign(style, &str);
3649 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3650 ok(!str, "textAlign != NULL\n");
3652 str = a2bstr("center");
3653 hres = IHTMLStyle_put_textAlign(style, str);
3654 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3655 SysFreeString(str);
3657 str = NULL;
3658 hres = IHTMLStyle_get_textAlign(style, &str);
3659 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3660 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3661 SysFreeString(str);
3663 str = (void*)0xdeadbeef;
3664 hres = IHTMLStyle_get_filter(style, &str);
3665 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3666 ok(!str, "filter != NULL\n");
3668 str = a2bstr("alpha(opacity=100)");
3669 hres = IHTMLStyle_put_filter(style, str);
3670 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3671 SysFreeString(str);
3673 V_VT(&v) = VT_EMPTY;
3674 hres = IHTMLStyle_get_zIndex(style, &v);
3675 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3676 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3677 ok(!V_I4(&v), "V_I4(v) != 0\n");
3678 VariantClear(&v);
3680 V_VT(&v) = VT_BSTR;
3681 V_BSTR(&v) = a2bstr("1");
3682 hres = IHTMLStyle_put_zIndex(style, v);
3683 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3684 VariantClear(&v);
3686 V_VT(&v) = VT_EMPTY;
3687 hres = IHTMLStyle_get_zIndex(style, &v);
3688 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3689 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3690 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3691 VariantClear(&v);
3693 /* fontStyle */
3694 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3695 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3697 str = a2bstr("test");
3698 hres = IHTMLStyle_put_fontStyle(style, str);
3699 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3700 SysFreeString(str);
3702 str = a2bstr("italic");
3703 hres = IHTMLStyle_put_fontStyle(style, str);
3704 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3705 SysFreeString(str);
3707 str = a2bstr("oblique");
3708 hres = IHTMLStyle_put_fontStyle(style, str);
3709 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3710 SysFreeString(str);
3712 str = a2bstr("normal");
3713 hres = IHTMLStyle_put_fontStyle(style, str);
3714 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3715 SysFreeString(str);
3717 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3718 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3719 SysFreeString(sDefault);
3721 /* overflow */
3722 hres = IHTMLStyle_get_overflow(style, NULL);
3723 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3725 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3726 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3728 str = a2bstr("test");
3729 hres = IHTMLStyle_put_overflow(style, str);
3730 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3731 SysFreeString(str);
3733 str = a2bstr("visible");
3734 hres = IHTMLStyle_put_overflow(style, str);
3735 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3736 SysFreeString(str);
3738 str = a2bstr("scroll");
3739 hres = IHTMLStyle_put_overflow(style, str);
3740 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3741 SysFreeString(str);
3743 str = a2bstr("hidden");
3744 hres = IHTMLStyle_put_overflow(style, str);
3745 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3746 SysFreeString(str);
3748 str = a2bstr("auto");
3749 hres = IHTMLStyle_put_overflow(style, str);
3750 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3751 SysFreeString(str);
3753 hres = IHTMLStyle_get_overflow(style, &str);
3754 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3755 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3756 SysFreeString(str);
3758 str = a2bstr("");
3759 hres = IHTMLStyle_put_overflow(style, str);
3760 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3761 SysFreeString(str);
3763 hres = IHTMLStyle_get_overflow(style, &str);
3764 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3765 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3766 SysFreeString(str);
3768 /* restore overflow default */
3769 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3770 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3771 SysFreeString(sOverflowDefault);
3773 /* Attribute Tests*/
3774 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3775 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3777 str = a2bstr("position");
3778 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3779 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3781 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3782 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3783 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3784 VariantClear(&v);
3786 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3787 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3789 V_VT(&v) = VT_BSTR;
3790 V_BSTR(&v) = a2bstr("absolute");
3791 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3792 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3793 VariantClear(&v);
3795 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3796 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3797 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3798 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3799 VariantClear(&v);
3801 V_VT(&v) = VT_BSTR;
3802 V_BSTR(&v) = NULL;
3803 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3804 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3805 VariantClear(&v);
3807 SysFreeString(str);
3809 str = a2bstr("borderLeftStyle");
3810 test_border_styles(style, str);
3811 SysFreeString(str);
3813 str = a2bstr("borderbottomstyle");
3814 test_border_styles(style, str);
3815 SysFreeString(str);
3817 str = a2bstr("borderrightstyle");
3818 test_border_styles(style, str);
3819 SysFreeString(str);
3821 str = a2bstr("bordertopstyle");
3822 test_border_styles(style, str);
3823 SysFreeString(str);
3825 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3826 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3828 str = a2bstr("none dotted dashed solid");
3829 hres = IHTMLStyle_put_borderStyle(style, str);
3830 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3831 SysFreeString(str);
3833 str = a2bstr("none dotted dashed solid");
3834 hres = IHTMLStyle_get_borderStyle(style, &str);
3835 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3836 ok(!strcmp_wa(str, "none dotted dashed solid"),
3837 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3838 SysFreeString(str);
3840 str = a2bstr("double groove ridge inset");
3841 hres = IHTMLStyle_put_borderStyle(style, str);
3842 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3843 SysFreeString(str);
3845 str = a2bstr("window-inset outset ridge inset");
3846 hres = IHTMLStyle_put_borderStyle(style, str);
3847 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3848 SysFreeString(str);
3850 str = a2bstr("window-inset");
3851 hres = IHTMLStyle_put_borderStyle(style, str);
3852 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3853 SysFreeString(str);
3855 str = a2bstr("none none none none none");
3856 hres = IHTMLStyle_put_borderStyle(style, str);
3857 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3858 SysFreeString(str);
3860 str = a2bstr("invalid none none none");
3861 hres = IHTMLStyle_put_borderStyle(style, str);
3862 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3863 SysFreeString(str);
3865 str = a2bstr("none invalid none none");
3866 hres = IHTMLStyle_put_borderStyle(style, str);
3867 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3868 SysFreeString(str);
3870 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3871 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3872 SysFreeString(sDefault);
3874 /* backgoundColor */
3875 hres = IHTMLStyle_get_backgroundColor(style, &v);
3876 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3877 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3878 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3879 VariantClear(&v);
3881 /* PaddingLeft */
3882 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3883 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3885 V_VT(&v) = VT_BSTR;
3886 V_BSTR(&v) = a2bstr("10");
3887 hres = IHTMLStyle_put_paddingLeft(style, v);
3888 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3889 VariantClear(&v);
3891 hres = IHTMLStyle_get_paddingLeft(style, &v);
3892 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3893 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3895 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3896 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3898 /* BackgroundRepeat */
3899 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3900 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3902 str = a2bstr("invalid");
3903 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3904 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3905 SysFreeString(str);
3907 str = a2bstr("repeat");
3908 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3909 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3910 SysFreeString(str);
3912 str = a2bstr("no-repeat");
3913 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3914 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3915 SysFreeString(str);
3917 str = a2bstr("repeat-x");
3918 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3919 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3920 SysFreeString(str);
3922 str = a2bstr("repeat-y");
3923 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3924 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3925 SysFreeString(str);
3927 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3928 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3929 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
3930 SysFreeString(str);
3932 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3933 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3934 SysFreeString(sDefault);
3936 /* BorderColor */
3937 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3938 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3940 str = a2bstr("red green red blue");
3941 hres = IHTMLStyle_put_borderColor(style, str);
3942 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3943 SysFreeString(str);
3945 hres = IHTMLStyle_get_borderColor(style, &str);
3946 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3947 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
3948 SysFreeString(str);
3950 hres = IHTMLStyle_put_borderColor(style, sDefault);
3951 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3952 SysFreeString(sDefault);
3954 /* BorderLeft */
3955 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3956 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3958 str = a2bstr("thick dotted red");
3959 hres = IHTMLStyle_put_borderLeft(style, str);
3960 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3961 SysFreeString(str);
3963 /* IHTMLStyle_get_borderLeft appears to have a bug where
3964 it returns the first letter of the color. So we check
3965 each style individually.
3967 V_BSTR(&v) = NULL;
3968 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3969 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3970 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3971 VariantClear(&v);
3973 V_BSTR(&v) = NULL;
3974 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3975 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3976 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3977 VariantClear(&v);
3979 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3980 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3981 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
3982 SysFreeString(str);
3984 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3985 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3986 SysFreeString(sDefault);
3988 /* backgroundPositionX */
3989 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3990 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3992 V_VT(&v) = VT_BSTR;
3993 V_BSTR(&v) = a2bstr("10px");
3994 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3995 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3996 VariantClear(&v);
3998 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3999 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4000 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4001 VariantClear(&v);
4003 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4004 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4005 VariantClear(&vDefault);
4007 /* backgroundPositionY */
4008 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4009 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4011 V_VT(&v) = VT_BSTR;
4012 V_BSTR(&v) = a2bstr("10px");
4013 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4014 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4015 VariantClear(&v);
4017 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4018 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4019 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4020 VariantClear(&v);
4022 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4023 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4024 VariantClear(&vDefault);
4026 /* borderTopWidth */
4027 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4028 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4030 V_VT(&v) = VT_BSTR;
4031 V_BSTR(&v) = a2bstr("10px");
4032 hres = IHTMLStyle_put_borderTopWidth(style, v);
4033 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4034 VariantClear(&v);
4036 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4037 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4038 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4039 VariantClear(&v);
4041 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4042 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4043 VariantClear(&vDefault);
4045 /* borderRightWidth */
4046 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4047 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4049 V_VT(&v) = VT_BSTR;
4050 V_BSTR(&v) = a2bstr("10");
4051 hres = IHTMLStyle_put_borderRightWidth(style, v);
4052 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4053 VariantClear(&v);
4055 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4056 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4057 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4058 VariantClear(&v);
4060 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4061 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4062 VariantClear(&vDefault);
4064 /* borderBottomWidth */
4065 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4066 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4068 V_VT(&v) = VT_BSTR;
4069 V_BSTR(&v) = a2bstr("10");
4070 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4071 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4072 VariantClear(&v);
4074 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4075 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4076 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4077 VariantClear(&v);
4079 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4080 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4081 VariantClear(&vDefault);
4083 /* borderLeftWidth */
4084 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4085 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4087 V_VT(&v) = VT_BSTR;
4088 V_BSTR(&v) = a2bstr("10");
4089 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4090 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4091 VariantClear(&v);
4093 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4094 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4095 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4096 VariantClear(&v);
4098 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4099 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4100 VariantClear(&vDefault);
4102 /* wordSpacing */
4103 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4104 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4106 V_VT(&v) = VT_BSTR;
4107 V_BSTR(&v) = a2bstr("10");
4108 hres = IHTMLStyle_put_wordSpacing(style, v);
4109 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4110 VariantClear(&v);
4112 hres = IHTMLStyle_get_wordSpacing(style, &v);
4113 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4114 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4115 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4116 VariantClear(&v);
4118 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4119 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4120 VariantClear(&vDefault);
4122 /* letterSpacing */
4123 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4124 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4126 V_VT(&v) = VT_BSTR;
4127 V_BSTR(&v) = a2bstr("11");
4128 hres = IHTMLStyle_put_letterSpacing(style, v);
4129 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4130 VariantClear(&v);
4132 hres = IHTMLStyle_get_letterSpacing(style, &v);
4133 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4134 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4135 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4136 VariantClear(&v);
4138 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4139 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4140 VariantClear(&vDefault);
4142 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4143 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4144 if(SUCCEEDED(hres)) {
4145 test_style2(style2);
4146 IHTMLStyle2_Release(style2);
4149 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4150 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4151 if(SUCCEEDED(hres)) {
4152 test_style3(style3);
4153 IHTMLStyle3_Release(style3);
4156 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4157 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4158 if(SUCCEEDED(hres)) {
4159 test_style4(style4);
4160 IHTMLStyle4_Release(style4);
4164 static void test_set_csstext(IHTMLStyle *style)
4166 VARIANT v;
4167 HRESULT hres;
4169 test_style_set_csstext(style, "background-color: black;");
4171 hres = IHTMLStyle_get_backgroundColor(style, &v);
4172 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4173 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4174 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4175 VariantClear(&v);
4178 static void test_default_selection(IHTMLDocument2 *doc)
4180 IHTMLSelectionObject *selection;
4181 IHTMLTxtRange *range;
4182 IDispatch *disp;
4183 BSTR str;
4184 HRESULT hres;
4186 hres = IHTMLDocument2_get_selection(doc, &selection);
4187 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4189 hres = IHTMLSelectionObject_get_type(selection, &str);
4190 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4191 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4192 SysFreeString(str);
4194 hres = IHTMLSelectionObject_createRange(selection, &disp);
4195 IHTMLSelectionObject_Release(selection);
4196 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4198 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4199 IDispatch_Release(disp);
4200 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4202 test_range_text(range, NULL);
4203 IHTMLTxtRange_Release(range);
4206 static void test_default_body(IHTMLBodyElement *body)
4208 LONG l;
4209 BSTR bstr;
4210 HRESULT hres;
4211 VARIANT v;
4212 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4213 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4215 bstr = (void*)0xdeadbeef;
4216 hres = IHTMLBodyElement_get_background(body, &bstr);
4217 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4218 ok(bstr == NULL, "bstr != NULL\n");
4220 l = elem_get_scroll_height((IUnknown*)body);
4221 ok(l != -1, "scrollHeight == -1\n");
4222 l = elem_get_scroll_width((IUnknown*)body);
4223 ok(l != -1, "scrollWidth == -1\n");
4224 l = elem_get_scroll_top((IUnknown*)body);
4225 ok(!l, "scrollTop = %d\n", l);
4226 elem_get_scroll_left((IUnknown*)body);
4228 /* get_text tests */
4229 hres = IHTMLBodyElement_get_text(body, &v);
4230 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4231 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4232 ok(bstr == NULL, "bstr != NULL\n");
4235 /* get_text - Invalid Text */
4236 V_VT(&v) = VT_BSTR;
4237 V_BSTR(&v) = SysAllocString(sTextInvalid);
4238 hres = IHTMLBodyElement_put_text(body, v);
4239 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4240 VariantClear(&v);
4242 V_VT(&v) = VT_NULL;
4243 hres = IHTMLBodyElement_get_text(body, &v);
4244 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4245 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4246 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4247 VariantClear(&v);
4249 /* get_text - Valid Text */
4250 V_VT(&v) = VT_BSTR;
4251 V_BSTR(&v) = SysAllocString(sBodyText);
4252 hres = IHTMLBodyElement_put_text(body, v);
4253 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4254 VariantClear(&v);
4256 V_VT(&v) = VT_NULL;
4257 hres = IHTMLBodyElement_get_text(body, &v);
4258 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4259 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4260 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4261 VariantClear(&v);
4264 static void test_body_funs(IHTMLBodyElement *body)
4266 static WCHAR sRed[] = {'r','e','d',0};
4267 VARIANT vbg;
4268 VARIANT vDefaultbg;
4269 HRESULT hres;
4271 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4272 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4273 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4275 V_VT(&vbg) = VT_BSTR;
4276 V_BSTR(&vbg) = SysAllocString(sRed);
4277 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4278 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4279 VariantClear(&vbg);
4281 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4282 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4283 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4284 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4285 VariantClear(&vbg);
4287 /* Restore Originial */
4288 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4289 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4290 VariantClear(&vDefaultbg);
4293 static void test_window(IHTMLDocument2 *doc)
4295 IHTMLWindow2 *window, *window2, *self;
4296 IHTMLDocument2 *doc2 = NULL;
4297 IDispatch *disp;
4298 IUnknown *unk;
4299 BSTR str;
4300 HRESULT hres;
4302 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4303 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4304 test_ifaces((IUnknown*)window, window_iids);
4305 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4307 hres = IHTMLWindow2_get_document(window, &doc2);
4308 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4309 ok(doc2 != NULL, "doc2 == NULL\n");
4311 test_ifaces((IUnknown*)doc2, doc_node_iids);
4312 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4314 test_ifaces((IUnknown*)doc, doc_obj_iids);
4315 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4317 unk = (void*)0xdeadbeef;
4318 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4319 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4320 ok(!unk, "unk = %p\n", unk);
4322 IHTMLDocument_Release(doc2);
4324 hres = IHTMLWindow2_get_window(window, &window2);
4325 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4326 ok(window2 != NULL, "window2 == NULL\n");
4328 hres = IHTMLWindow2_get_self(window, &self);
4329 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4330 ok(window2 != NULL, "self == NULL\n");
4332 ok(self == window2, "self != window2\n");
4334 IHTMLWindow2_Release(window2);
4335 IHTMLWindow2_Release(self);
4337 disp = NULL;
4338 hres = IHTMLDocument2_get_Script(doc, &disp);
4339 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4340 ok(disp == (void*)window, "disp != window\n");
4341 IDispatch_Release(disp);
4343 hres = IHTMLWindow2_toString(window, NULL);
4344 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4346 str = NULL;
4347 hres = IHTMLWindow2_toString(window, &str);
4348 ok(hres == S_OK, "toString failed: %08x\n", hres);
4349 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4350 SysFreeString(str);
4352 IHTMLWindow2_Release(window);
4355 static void test_defaults(IHTMLDocument2 *doc)
4357 IHTMLStyleSheetsCollection *stylesheetcol;
4358 IHTMLCurrentStyle *cstyle;
4359 IHTMLBodyElement *body;
4360 IHTMLElement2 *elem2;
4361 IHTMLElement *elem;
4362 IHTMLStyle *style;
4363 LONG l;
4364 HRESULT hres;
4365 IHTMLElementCollection *collection;
4367 hres = IHTMLDocument2_get_body(doc, &elem);
4368 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4370 hres = IHTMLDocument2_get_images(doc, NULL);
4371 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4373 hres = IHTMLDocument2_get_images(doc, &collection);
4374 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4375 if(hres == S_OK)
4377 test_elem_collection((IUnknown*)collection, NULL, 0);
4378 IHTMLElementCollection_Release(collection);
4381 hres = IHTMLDocument2_get_applets(doc, NULL);
4382 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4384 hres = IHTMLDocument2_get_applets(doc, &collection);
4385 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4386 if(hres == S_OK)
4388 test_elem_collection((IUnknown*)collection, NULL, 0);
4389 IHTMLElementCollection_Release(collection);
4392 hres = IHTMLDocument2_get_links(doc, NULL);
4393 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4395 hres = IHTMLDocument2_get_links(doc, &collection);
4396 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4397 if(hres == S_OK)
4399 test_elem_collection((IUnknown*)collection, NULL, 0);
4400 IHTMLElementCollection_Release(collection);
4403 hres = IHTMLDocument2_get_forms(doc, NULL);
4404 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4406 hres = IHTMLDocument2_get_forms(doc, &collection);
4407 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4408 if(hres == S_OK)
4410 test_elem_collection((IUnknown*)collection, NULL, 0);
4411 IHTMLElementCollection_Release(collection);
4414 hres = IHTMLDocument2_get_anchors(doc, NULL);
4415 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4417 hres = IHTMLDocument2_get_anchors(doc, &collection);
4418 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4419 if(hres == S_OK)
4421 test_elem_collection((IUnknown*)collection, NULL, 0);
4422 IHTMLElementCollection_Release(collection);
4425 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4426 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4427 test_default_body(body);
4428 test_body_funs(body);
4429 IHTMLBodyElement_Release(body);
4431 hres = IHTMLElement_get_style(elem, &style);
4432 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4434 test_default_style(style);
4435 test_window(doc);
4436 test_compatmode(doc);
4437 test_location(doc);
4438 test_navigator(doc);
4440 elem2 = get_elem2_iface((IUnknown*)elem);
4441 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4442 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4443 if(SUCCEEDED(hres)) {
4444 test_current_style(cstyle);
4445 IHTMLCurrentStyle_Release(cstyle);
4447 IHTMLElement2_Release(elem2);
4449 IHTMLElement_Release(elem);
4451 test_set_csstext(style);
4452 IHTMLStyle_Release(style);
4454 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4455 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4457 l = 0xdeadbeef;
4458 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4459 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4460 ok(l == 0, "length = %d\n", l);
4462 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4464 test_default_selection(doc);
4465 test_doc_title(doc, "");
4468 static void test_tr_elem(IHTMLElement *elem)
4470 IHTMLElementCollection *col;
4471 IHTMLTableRow *row;
4472 HRESULT hres;
4474 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4476 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4477 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4478 if(FAILED(hres))
4479 return;
4481 col = NULL;
4482 hres = IHTMLTableRow_get_cells(row, &col);
4483 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4484 ok(col != NULL, "get_cells returned NULL\n");
4486 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4487 IHTMLElementCollection_Release(col);
4489 IHTMLTable_Release(row);
4492 static void test_table_elem(IHTMLElement *elem)
4494 IHTMLElementCollection *col;
4495 IHTMLTable *table;
4496 IHTMLDOMNode *node;
4497 HRESULT hres;
4499 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4500 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4502 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4503 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4504 if(FAILED(hres))
4505 return;
4507 col = NULL;
4508 hres = IHTMLTable_get_rows(table, &col);
4509 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4510 ok(col != NULL, "get_ros returned NULL\n");
4512 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4513 IHTMLElementCollection_Release(col);
4515 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4517 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4518 test_elem_tag((IUnknown*)node, "TABLE");
4519 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4520 IHTMLDOMNode_Release(node);
4522 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4523 test_elem_tag((IUnknown*)node, "TABLE");
4524 test_elem_all((IUnknown*)node, NULL, 0);
4525 IHTMLDOMNode_Release(node);
4527 IHTMLTable_Release(table);
4530 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4532 SAFEARRAYBOUND dim;
4533 SAFEARRAY *sa;
4534 VARIANT *var;
4535 BSTR str;
4536 HRESULT hres;
4538 dim.lLbound = 0;
4539 dim.cElements = 1;
4540 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4541 SafeArrayAccessData(sa, (void**)&var);
4542 V_VT(var) = VT_BSTR;
4543 V_BSTR(var) = str = a2bstr(text);
4544 SafeArrayUnaccessData(sa);
4546 if(ln)
4547 hres = IHTMLDocument2_writeln(doc, sa);
4548 else
4549 hres = IHTMLDocument2_write(doc, sa);
4550 ok(hres == S_OK, "write failed: %08x\n", hres);
4552 SysFreeString(str);
4553 SafeArrayDestroy(sa);
4556 static void test_iframe_elem(IHTMLElement *elem)
4558 IHTMLElementCollection *col;
4559 IHTMLDocument2 *content_doc;
4560 IHTMLWindow2 *content_window;
4561 IHTMLFrameBase2 *base2;
4562 IDispatch *disp;
4563 VARIANT errv;
4564 BSTR str;
4565 HRESULT hres;
4567 static const elem_type_t all_types[] = {
4568 ET_HTML,
4569 ET_HEAD,
4570 ET_TITLE,
4571 ET_BODY,
4572 ET_BR
4575 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4576 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4577 if (!base2) return;
4579 content_window = NULL;
4580 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4581 IHTMLFrameBase2_Release(base2);
4582 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4583 ok(content_window != NULL, "contentWindow = NULL\n");
4585 content_doc = NULL;
4586 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4587 IHTMLWindow2_Release(content_window);
4588 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4589 ok(content_doc != NULL, "content_doc = NULL\n");
4591 str = a2bstr("text/html");
4592 V_VT(&errv) = VT_ERROR;
4593 disp = NULL;
4594 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4595 SysFreeString(str);
4596 ok(hres == S_OK, "open failed: %08x\n", hres);
4597 ok(disp != NULL, "disp == NULL\n");
4598 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4599 IDispatch_Release(disp);
4601 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4602 doc_write(content_doc, TRUE, "</html>");
4604 hres = IHTMLDocument2_get_all(content_doc, &col);
4605 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4606 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4607 IHTMLElementCollection_Release(col);
4609 hres = IHTMLDocument2_close(content_doc);
4610 ok(hres == S_OK, "close failed: %08x\n", hres);
4612 IHTMLDocument2_Release(content_doc);
4615 static void test_stylesheet(IDispatch *disp)
4617 IHTMLStyleSheetRulesCollection *col = NULL;
4618 IHTMLStyleSheet *stylesheet;
4619 HRESULT hres;
4621 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4622 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4624 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4625 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4626 ok(col != NULL, "col == NULL\n");
4628 IHTMLStyleSheetRulesCollection_Release(col);
4629 IHTMLStyleSheet_Release(stylesheet);
4632 static void test_stylesheets(IHTMLDocument2 *doc)
4634 IHTMLStyleSheetsCollection *col = NULL;
4635 VARIANT idx, res;
4636 LONG len = 0;
4637 HRESULT hres;
4639 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4640 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4641 ok(col != NULL, "col == NULL\n");
4643 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4644 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4645 ok(len == 1, "len=%d\n", len);
4647 VariantInit(&res);
4648 V_VT(&idx) = VT_I4;
4649 V_I4(&idx) = 0;
4651 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4652 ok(hres == S_OK, "item failed: %08x\n", hres);
4653 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4654 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4655 test_stylesheet(V_DISPATCH(&res));
4656 VariantClear(&res);
4658 V_VT(&res) = VT_I4;
4659 V_VT(&idx) = VT_I4;
4660 V_I4(&idx) = 1;
4662 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4663 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4664 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4665 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4666 VariantClear(&res);
4668 IHTMLStyleSheetsCollection_Release(col);
4671 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4673 IDispatchEx *dispex;
4674 IHTMLDOMNode *node;
4675 DISPPARAMS dp = {NULL, NULL, 0, 0};
4676 VARIANT var;
4677 EXCEPINFO ei;
4678 LONG type;
4679 DISPID id;
4680 BSTR bstr;
4681 HRESULT hres;
4683 static const WCHAR w0[] = {'0',0};
4684 static const WCHAR w100[] = {'1','0','0',0};
4686 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4687 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4689 bstr = SysAllocString(w0);
4690 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4691 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4692 SysFreeString(bstr);
4694 VariantInit(&var);
4695 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4696 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4697 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4698 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4699 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4700 type = get_node_type((IUnknown*)node);
4701 ok(type == 3, "type=%d\n", type);
4702 IHTMLDOMNode_Release(node);
4703 VariantClear(&var);
4705 bstr = SysAllocString(w100);
4706 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4707 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4708 SysFreeString(bstr);
4710 IDispatchEx_Release(dispex);
4715 static void test_elems(IHTMLDocument2 *doc)
4717 IHTMLElementCollection *col;
4718 IHTMLDOMChildrenCollection *child_col;
4719 IHTMLElement *elem, *elem2, *elem3;
4720 IHTMLDOMNode *node, *node2;
4721 IDispatch *disp;
4722 LONG type;
4723 HRESULT hres;
4724 IHTMLElementCollection *collection;
4725 IHTMLDocument3 *doc3;
4726 BSTR str;
4728 static const elem_type_t all_types[] = {
4729 ET_HTML,
4730 ET_HEAD,
4731 ET_TITLE,
4732 ET_STYLE,
4733 ET_BODY,
4734 ET_COMMENT,
4735 ET_A,
4736 ET_INPUT,
4737 ET_SELECT,
4738 ET_OPTION,
4739 ET_OPTION,
4740 ET_TEXTAREA,
4741 ET_TABLE,
4742 ET_TBODY,
4743 ET_TR,
4744 ET_TR,
4745 ET_TD,
4746 ET_TD,
4747 ET_SCRIPT,
4748 ET_TEST,
4749 ET_IMG,
4750 ET_IFRAME
4753 static const elem_type_t item_types[] = {
4754 ET_A,
4755 ET_OPTION,
4756 ET_TEXTAREA
4759 hres = IHTMLDocument2_get_all(doc, &col);
4760 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4761 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4762 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4763 IHTMLElementCollection_Release(col);
4765 hres = IHTMLDocument2_get_images(doc, &collection);
4766 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4767 if(hres == S_OK)
4769 static const elem_type_t images_types[] = {ET_IMG};
4770 test_elem_collection((IUnknown*)collection, images_types, 1);
4772 IHTMLElementCollection_Release(collection);
4775 hres = IHTMLDocument2_get_links(doc, &collection);
4776 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4777 if(hres == S_OK)
4779 static const elem_type_t images_types[] = {ET_A};
4780 test_elem_collection((IUnknown*)collection, images_types, 1);
4782 IHTMLElementCollection_Release(collection);
4785 hres = IHTMLDocument2_get_anchors(doc, &collection);
4786 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4787 if(hres == S_OK)
4789 static const elem_type_t anchor_types[] = {ET_A};
4790 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4792 IHTMLElementCollection_Release(collection);
4795 elem = get_doc_elem(doc);
4796 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4797 IHTMLElement_Release(elem);
4799 get_elem_by_id(doc, "xxx", FALSE);
4800 elem = get_doc_elem_by_id(doc, "xxx");
4801 ok(!elem, "elem != NULL\n");
4803 elem = get_doc_elem_by_id(doc, "s");
4804 ok(elem != NULL, "elem == NULL\n");
4805 if(elem) {
4806 test_elem_type((IUnknown*)elem, ET_SELECT);
4807 test_elem_attr(elem, "xxx", NULL);
4808 test_elem_attr(elem, "id", "s");
4809 test_elem_class((IUnknown*)elem, NULL);
4810 test_elem_set_class((IUnknown*)elem, "cl");
4811 test_elem_set_class((IUnknown*)elem, NULL);
4812 test_elem_tabindex((IUnknown*)elem, 0);
4813 test_elem_set_tabindex((IUnknown*)elem, 1);
4815 node = test_node_get_parent((IUnknown*)elem);
4816 ok(node != NULL, "node == NULL\n");
4817 test_node_name((IUnknown*)node, "BODY");
4818 node2 = test_node_get_parent((IUnknown*)node);
4819 IHTMLDOMNode_Release(node);
4820 ok(node2 != NULL, "node == NULL\n");
4821 test_node_name((IUnknown*)node2, "HTML");
4822 node = test_node_get_parent((IUnknown*)node2);
4823 IHTMLDOMNode_Release(node2);
4824 ok(node != NULL, "node == NULL\n");
4825 if (node)
4827 test_node_name((IUnknown*)node, "#document");
4828 type = get_node_type((IUnknown*)node);
4829 ok(type == 9, "type=%d, expected 9\n", type);
4830 node2 = test_node_get_parent((IUnknown*)node);
4831 IHTMLDOMNode_Release(node);
4832 ok(node2 == NULL, "node != NULL\n");
4835 elem2 = test_elem_get_parent((IUnknown*)elem);
4836 ok(elem2 != NULL, "elem2 == NULL\n");
4837 test_node_name((IUnknown*)elem2, "BODY");
4838 elem3 = test_elem_get_parent((IUnknown*)elem2);
4839 IHTMLElement_Release(elem2);
4840 ok(elem3 != NULL, "elem3 == NULL\n");
4841 test_node_name((IUnknown*)elem3, "HTML");
4842 elem2 = test_elem_get_parent((IUnknown*)elem3);
4843 IHTMLElement_Release(elem3);
4844 ok(elem2 == NULL, "elem2 != NULL\n");
4846 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4847 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4848 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4850 test_elem_innertext(elem, "opt1opt2");
4852 IHTMLElement_Release(elem);
4855 elem = get_elem_by_id(doc, "s", TRUE);
4856 if(elem) {
4857 IHTMLSelectElement *select;
4858 IHTMLDocument2 *doc_node;
4860 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4861 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4863 test_select_elem(select);
4865 test_elem_title((IUnknown*)select, NULL);
4866 test_elem_set_title((IUnknown*)select, "Title");
4867 test_elem_title((IUnknown*)select, "Title");
4868 test_elem_offset((IUnknown*)select);
4870 node = get_first_child((IUnknown*)select);
4871 ok(node != NULL, "node == NULL\n");
4872 if(node) {
4873 test_elem_type((IUnknown*)node, ET_OPTION);
4874 IHTMLDOMNode_Release(node);
4877 type = get_node_type((IUnknown*)select);
4878 ok(type == 1, "type=%d\n", type);
4880 IHTMLSelectElement_Release(select);
4882 hres = IHTMLElement_get_document(elem, &disp);
4883 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4885 doc_node = get_doc_node(doc);
4886 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
4887 IHTMLDocument2_Release(doc_node);
4889 IHTMLElement_Release(elem);
4892 elem = get_elem_by_id(doc, "sc", TRUE);
4893 if(elem) {
4894 IHTMLScriptElement *script;
4895 BSTR type;
4897 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4898 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4900 if(hres == S_OK)
4902 VARIANT_BOOL vb;
4904 hres = IHTMLScriptElement_get_type(script, &type);
4905 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4906 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4907 SysFreeString(type);
4909 /* test defer */
4910 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4911 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4913 hres = IHTMLScriptElement_get_defer(script, &vb);
4914 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4915 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4917 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4918 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4921 IHTMLScriptElement_Release(script);
4924 elem = get_elem_by_id(doc, "in", TRUE);
4925 if(elem) {
4926 IHTMLInputElement *input;
4928 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4929 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4931 test_elem_id((IUnknown*)elem, "in");
4932 test_elem_put_id((IUnknown*)elem, "newin");
4933 test_input_get_disabled(input, VARIANT_FALSE);
4934 test_input_set_disabled(input, VARIANT_TRUE);
4935 test_input_set_disabled(input, VARIANT_FALSE);
4936 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4937 test_input_get_disabled(input, VARIANT_TRUE);
4938 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4939 test_input_get_disabled(input, VARIANT_FALSE);
4940 test_elem_client_size((IUnknown*)elem);
4942 test_node_get_value_str((IUnknown*)elem, NULL);
4943 test_node_put_value_str((IUnknown*)elem, "test");
4944 test_node_get_value_str((IUnknown*)elem, NULL);
4945 test_input_value((IUnknown*)elem, NULL);
4946 test_input_put_value((IUnknown*)elem, "test");
4947 test_input_value((IUnknown*)elem, NULL);
4948 test_elem_class((IUnknown*)elem, "testclass");
4949 test_elem_tabindex((IUnknown*)elem, 2);
4950 test_elem_set_tabindex((IUnknown*)elem, 3);
4951 test_elem_title((IUnknown*)elem, "test title");
4953 test_input_get_defaultchecked(input, VARIANT_FALSE);
4954 test_input_set_defaultchecked(input, VARIANT_TRUE);
4955 test_input_set_defaultchecked(input, VARIANT_FALSE);
4957 test_input_get_checked(input, VARIANT_FALSE);
4958 test_input_set_checked(input, VARIANT_TRUE);
4959 test_input_set_checked(input, VARIANT_FALSE);
4961 test_input_src(input, NULL);
4962 test_input_set_src(input, "about:blank");
4964 IHTMLInputElement_Release(input);
4965 IHTMLElement_Release(elem);
4968 elem = get_elem_by_id(doc, "imgid", TRUE);
4969 if(elem) {
4970 test_img_src((IUnknown*)elem, "");
4971 test_img_set_src((IUnknown*)elem, "about:blank");
4972 test_img_alt((IUnknown*)elem, NULL);
4973 test_img_set_alt((IUnknown*)elem, "alt test");
4974 IHTMLElement_Release(elem);
4977 elem = get_doc_elem_by_id(doc, "tbl");
4978 ok(elem != NULL, "elem == NULL\n");
4979 if(elem) {
4980 test_table_elem(elem);
4981 IHTMLElement_Release(elem);
4984 elem = get_doc_elem_by_id(doc, "row2");
4985 ok(elem != NULL, "elem == NULL\n");
4986 if(elem) {
4987 test_tr_elem(elem);
4988 IHTMLElement_Release(elem);
4991 elem = get_doc_elem_by_id(doc, "ifr");
4992 ok(elem != NULL, "elem == NULL\n");
4993 if(elem) {
4994 test_iframe_elem(elem);
4995 IHTMLElement_Release(elem);
4998 elem = get_elem_by_id(doc, "a", TRUE);
4999 if(elem) {
5000 test_anchor_href((IUnknown*)elem, "http://test/");
5001 IHTMLElement_Release(elem);
5004 hres = IHTMLDocument2_get_body(doc, &elem);
5005 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5007 node = get_first_child((IUnknown*)elem);
5008 ok(node != NULL, "node == NULL\n");
5009 if(node) {
5010 test_ifaces((IUnknown*)node, text_iids);
5011 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5013 node2 = get_first_child((IUnknown*)node);
5014 ok(!node2, "node2 != NULL\n");
5016 type = get_node_type((IUnknown*)node);
5017 ok(type == 3, "type=%d\n", type);
5019 test_node_get_value_str((IUnknown*)node, "text test");
5020 test_node_put_value_str((IUnknown*)elem, "test text");
5021 test_node_get_value_str((IUnknown*)node, "text test");
5023 IHTMLDOMNode_Release(node);
5026 child_col = get_child_nodes((IUnknown*)elem);
5027 ok(child_col != NULL, "child_coll == NULL\n");
5028 if(child_col) {
5029 LONG length = 0;
5031 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5033 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5034 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5035 ok(length, "length=0\n");
5037 node = get_child_item(child_col, 0);
5038 ok(node != NULL, "node == NULL\n");
5039 if(node) {
5040 type = get_node_type((IUnknown*)node);
5041 ok(type == 3, "type=%d\n", type);
5042 IHTMLDOMNode_Release(node);
5045 node = get_child_item(child_col, 1);
5046 ok(node != NULL, "node == NULL\n");
5047 if(node) {
5048 type = get_node_type((IUnknown*)node);
5049 ok(type == 8, "type=%d\n", type);
5051 test_elem_id((IUnknown*)node, NULL);
5052 IHTMLDOMNode_Release(node);
5055 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5056 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5058 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5059 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5061 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5062 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5064 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5065 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5067 test_child_col_disp(child_col);
5069 IHTMLDOMChildrenCollection_Release(child_col);
5072 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5073 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5074 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5076 IHTMLElement_Release(elem);
5078 test_stylesheets(doc);
5079 test_create_option_elem(doc);
5081 elem = get_doc_elem_by_id(doc, "tbl");
5082 ok(elem != NULL, "elem = NULL\n");
5083 test_elem_set_innertext(elem, "inner text");
5084 IHTMLElement_Release(elem);
5086 test_doc_title(doc, "test");
5087 test_doc_set_title(doc, "test title");
5088 test_doc_title(doc, "test title");
5090 disp = NULL;
5091 hres = IHTMLDocument2_get_Script(doc, &disp);
5092 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5093 if(hres == S_OK)
5095 IDispatchEx *dispex;
5096 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5097 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5098 if(hres == S_OK)
5100 DISPID pid = -1;
5101 BSTR str = a2bstr("Testing");
5102 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5103 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5104 ok(pid != -1, "pid == -1\n");
5105 SysFreeString(str);
5106 IDispatchEx_Release(dispex);
5109 IDispatch_Release(disp);
5111 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5112 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5114 str = a2bstr("img");
5115 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5116 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5117 SysFreeString(str);
5118 if(hres == S_OK)
5120 static const elem_type_t img_types[] = { ET_IMG };
5122 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5123 IHTMLElementCollection_Release(col);
5126 elem = get_doc_elem_by_id(doc, "y");
5127 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5128 test_elem_innerhtml((IUnknown*)elem, "inner html");
5129 test_elem_set_innerhtml((IUnknown*)elem, "");
5130 test_elem_innerhtml((IUnknown*)elem, NULL);
5131 IHTMLElement_Release(elem);
5133 IHTMLDocument3_Release(doc3);
5136 static void test_create_elems(IHTMLDocument2 *doc)
5138 IHTMLElement *elem, *body, *elem2;
5139 IHTMLDOMNode *node, *node2, *node3, *comment;
5140 IHTMLDocument5 *doc5;
5141 IDispatch *disp;
5142 VARIANT var;
5143 LONG type;
5144 HRESULT hres;
5145 BSTR str;
5147 static const elem_type_t types1[] = { ET_TESTG };
5149 elem = test_create_elem(doc, "TEST");
5150 test_elem_tag((IUnknown*)elem, "TEST");
5151 type = get_node_type((IUnknown*)elem);
5152 ok(type == 1, "type=%d\n", type);
5153 test_ifaces((IUnknown*)elem, elem_iids);
5154 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5156 hres = IHTMLDocument2_get_body(doc, &body);
5157 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5158 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5160 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5161 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5162 elem2 = get_elem_iface((IUnknown*)node);
5163 IHTMLElement_Release(elem2);
5165 hres = IHTMLElement_get_all(body, &disp);
5166 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5167 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5168 IDispatch_Release(disp);
5170 test_node_remove_child((IUnknown*)body, node);
5172 hres = IHTMLElement_get_all(body, &disp);
5173 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5174 test_elem_collection((IUnknown*)disp, NULL, 0);
5175 IDispatch_Release(disp);
5176 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5178 IHTMLElement_Release(elem);
5179 IHTMLDOMNode_Release(node);
5181 node = test_create_text(doc, "test");
5182 test_ifaces((IUnknown*)node, text_iids);
5183 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5185 V_VT(&var) = VT_NULL;
5186 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5187 IHTMLDOMNode_Release(node);
5189 node = test_create_text(doc, "insert ");
5191 V_VT(&var) = VT_DISPATCH;
5192 V_DISPATCH(&var) = (IDispatch*)node2;
5193 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5194 IHTMLDOMNode_Release(node);
5195 IHTMLDOMNode_Release(node2);
5196 IHTMLDOMNode_Release(node3);
5198 test_elem_innertext(body, "insert test");
5199 test_elem_innerhtml((IUnknown*)body, "insert test");
5201 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5202 if(hres == S_OK)
5204 str = a2bstr("testing");
5205 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5206 SysFreeString(str);
5207 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5208 if(hres == S_OK)
5210 type = get_node_type((IUnknown*)comment);
5211 ok(type == 8, "type=%d, expected 8\n", type);
5213 test_node_get_value_str((IUnknown*)comment, "testing");
5215 IHTMLDOMNode_Release(comment);
5218 IHTMLDocument5_Release(doc5);
5221 IHTMLElement_Release(body);
5224 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5226 IOleCommandTarget *cmdtrg;
5227 HRESULT hres;
5229 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5230 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5232 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5233 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5235 IOleCommandTarget_Release(cmdtrg);
5238 static void test_indent(IHTMLDocument2 *doc)
5240 IHTMLElementCollection *col;
5241 IHTMLTxtRange *range;
5242 HRESULT hres;
5244 static const elem_type_t all_types[] = {
5245 ET_HTML,
5246 ET_HEAD,
5247 ET_TITLE,
5248 ET_BODY,
5249 ET_BR,
5250 ET_A,
5253 static const elem_type_t indent_types[] = {
5254 ET_HTML,
5255 ET_HEAD,
5256 ET_TITLE,
5257 ET_BODY,
5258 ET_BLOCKQUOTE,
5259 ET_P,
5260 ET_BR,
5261 ET_A,
5264 hres = IHTMLDocument2_get_all(doc, &col);
5265 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5266 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5267 IHTMLElementCollection_Release(col);
5269 range = test_create_body_range(doc);
5270 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5271 IHTMLTxtRange_Release(range);
5273 hres = IHTMLDocument2_get_all(doc, &col);
5274 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5275 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5276 IHTMLElementCollection_Release(col);
5279 static void test_cond_comment(IHTMLDocument2 *doc)
5281 IHTMLElementCollection *col;
5282 HRESULT hres;
5284 static const elem_type_t all_types[] = {
5285 ET_HTML,
5286 ET_HEAD,
5287 ET_TITLE,
5288 ET_BODY,
5289 ET_BR
5292 hres = IHTMLDocument2_get_all(doc, &col);
5293 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5294 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5295 IHTMLElementCollection_Release(col);
5298 static IHTMLDocument2 *notif_doc;
5299 static BOOL doc_complete;
5301 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5302 REFIID riid, void**ppv)
5304 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5305 *ppv = iface;
5306 return S_OK;
5309 ok(0, "unexpected call\n");
5310 return E_NOINTERFACE;
5313 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5315 return 2;
5318 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5320 return 1;
5323 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5325 if(dispID == DISPID_READYSTATE){
5326 BSTR state;
5327 HRESULT hres;
5329 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5330 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5332 if(!strcmp_wa(state, "complete"))
5333 doc_complete = TRUE;
5335 SysFreeString(state);
5338 return S_OK;
5341 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5343 ok(0, "unexpected call\n");
5344 return E_NOTIMPL;
5347 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5348 PropertyNotifySink_QueryInterface,
5349 PropertyNotifySink_AddRef,
5350 PropertyNotifySink_Release,
5351 PropertyNotifySink_OnChanged,
5352 PropertyNotifySink_OnRequestEdit
5355 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5357 static IHTMLDocument2 *create_doc_with_string(const char *str)
5359 IPersistStreamInit *init;
5360 IStream *stream;
5361 IHTMLDocument2 *doc;
5362 HGLOBAL mem;
5363 SIZE_T len;
5365 notif_doc = doc = create_document();
5366 if(!doc)
5367 return NULL;
5369 doc_complete = FALSE;
5370 len = strlen(str);
5371 mem = GlobalAlloc(0, len);
5372 memcpy(mem, str, len);
5373 CreateStreamOnHGlobal(mem, TRUE, &stream);
5375 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5377 IPersistStreamInit_Load(init, stream);
5378 IPersistStreamInit_Release(init);
5379 IStream_Release(stream);
5381 return doc;
5384 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5386 IConnectionPointContainer *container;
5387 IConnectionPoint *cp;
5388 DWORD cookie;
5389 HRESULT hres;
5391 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5392 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5394 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5395 IConnectionPointContainer_Release(container);
5396 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5398 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5399 IConnectionPoint_Release(cp);
5400 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5403 typedef void (*domtest_t)(IHTMLDocument2*);
5405 static void run_domtest(const char *str, domtest_t test)
5407 IHTMLDocument2 *doc;
5408 IHTMLElement *body = NULL;
5409 ULONG ref;
5410 MSG msg;
5411 HRESULT hres;
5413 doc = create_doc_with_string(str);
5414 if(!doc)
5415 return;
5417 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5419 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5420 TranslateMessage(&msg);
5421 DispatchMessage(&msg);
5424 hres = IHTMLDocument2_get_body(doc, &body);
5425 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5427 if(body) {
5428 IHTMLElement_Release(body);
5429 test(doc);
5430 }else {
5431 skip("Could not get document body. Assuming no Gecko installed.\n");
5434 ref = IHTMLDocument2_Release(doc);
5435 ok(!ref ||
5436 ref == 1, /* Vista */
5437 "ref = %d\n", ref);
5440 static void gecko_installer_workaround(BOOL disable)
5442 HKEY hkey;
5443 DWORD res;
5445 static BOOL has_url = FALSE;
5446 static char url[2048];
5448 if(!disable && !has_url)
5449 return;
5451 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5452 if(res != ERROR_SUCCESS)
5453 return;
5455 if(disable) {
5456 DWORD type, size = sizeof(url);
5458 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5459 if(res == ERROR_SUCCESS && type == REG_SZ)
5460 has_url = TRUE;
5462 RegDeleteValue(hkey, "GeckoUrl");
5463 }else {
5464 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5467 RegCloseKey(hkey);
5470 START_TEST(dom)
5472 gecko_installer_workaround(TRUE);
5473 CoInitialize(NULL);
5475 run_domtest(doc_str1, test_doc_elem);
5476 run_domtest(doc_str1, test_get_set_attr);
5477 run_domtest(range_test_str, test_txtrange);
5478 run_domtest(range_test2_str, test_txtrange2);
5479 if (winetest_interactive || ! is_ie_hardened()) {
5480 run_domtest(elem_test_str, test_elems);
5481 }else {
5482 skip("IE running in Enhanced Security Configuration\n");
5484 run_domtest(doc_blank, test_create_elems);
5485 run_domtest(doc_blank, test_defaults);
5486 run_domtest(indent_test_str, test_indent);
5487 run_domtest(cond_comment_str, test_cond_comment);
5489 CoUninitialize();
5490 gecko_installer_workaround(FALSE);