mshtml/tests: Fix a typo.
[wine/multimedia.git] / dlls / mshtml / tests / dom.c
blobc6e49eff04bc0678128b13befc61ed61be0c98b0
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"
35 #include "objsafe.h"
37 static const char doc_blank[] = "<html></html>";
38 static const char doc_str1[] = "<html><body>test</body></html>";
39 static const char range_test_str[] =
40 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
41 static const char range_test2_str[] =
42 "<html><body>abc<hr />123<br /><hr />def</body></html>";
43 static const char elem_test_str[] =
44 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
45 "<body onload=\"Testing()\">text test<!-- a comment -->"
46 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
47 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
48 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
49 "<textarea id=\"X\">text text</textarea>"
50 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
51 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
52 "<test /><object id=\"objid\" vspace=100></object><embed />"
53 "<img id=\"imgid\" name=\"WineImg\"/>"
54 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 "<form id=\"frm\"></form>"
56 "</body></html>";
57 static const char elem_test2_str[] =
58 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
59 "<body><div id=\"divid\"></div></body>"
60 "</html>";
62 static const char indent_test_str[] =
63 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
64 static const char cond_comment_str[] =
65 "<html><head><title>test</title></head><body>"
66 "<!--[if gte IE 4]> <br> <![endif]-->"
67 "</body></html>";
68 static const char frameset_str[] =
69 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
70 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
71 "<frame src=\"about:blank\" id=\"fr3\">"
72 "</frameset></html>";
73 static const char emptydiv_str[] =
74 "<html><head><title>emptydiv test</title></head>"
75 "<body><div id=\"divid\"></div></body></html>";
77 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
78 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
79 static WCHAR wordW[] = {'w','o','r','d',0};
81 typedef enum {
82 ET_NONE,
83 ET_HTML,
84 ET_HEAD,
85 ET_TITLE,
86 ET_BODY,
87 ET_A,
88 ET_INPUT,
89 ET_SELECT,
90 ET_TEXTAREA,
91 ET_OPTION,
92 ET_STYLE,
93 ET_BLOCKQUOTE,
94 ET_P,
95 ET_BR,
96 ET_TABLE,
97 ET_TBODY,
98 ET_SCRIPT,
99 ET_TEST,
100 ET_TESTG,
101 ET_COMMENT,
102 ET_IMG,
103 ET_TR,
104 ET_TD,
105 ET_IFRAME,
106 ET_FORM,
107 ET_FRAME,
108 ET_OBJECT,
109 ET_EMBED,
110 ET_DIV
111 } elem_type_t;
113 static const IID * const none_iids[] = {
114 &IID_IUnknown,
115 NULL
118 static const IID * const doc_node_iids[] = {
119 &IID_IHTMLDOMNode,
120 &IID_IHTMLDOMNode2,
121 &IID_IHTMLDocument,
122 &IID_IHTMLDocument2,
123 &IID_IHTMLDocument3,
124 &IID_IHTMLDocument4,
125 &IID_IHTMLDocument5,
126 &IID_IDispatchEx,
127 &IID_IConnectionPointContainer,
128 &IID_IInternetHostSecurityManager,
129 &IID_IOleContainer,
130 &IID_IObjectSafety,
131 NULL
134 static const IID * const doc_obj_iids[] = {
135 &IID_IHTMLDocument,
136 &IID_IHTMLDocument2,
137 &IID_IHTMLDocument3,
138 &IID_IHTMLDocument4,
139 &IID_IHTMLDocument5,
140 &IID_IDispatchEx,
141 &IID_IConnectionPointContainer,
142 &IID_ICustomDoc,
143 &IID_IOleContainer,
144 &IID_IObjectSafety,
145 NULL
148 static const IID * const elem_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IDispatchEx,
155 &IID_IConnectionPointContainer,
156 NULL
159 static const IID * const body_iids[] = {
160 &IID_IHTMLDOMNode,
161 &IID_IHTMLDOMNode2,
162 &IID_IHTMLElement,
163 &IID_IHTMLElement2,
164 &IID_IHTMLElement3,
165 &IID_IHTMLTextContainer,
166 &IID_IHTMLBodyElement,
167 &IID_IDispatchEx,
168 &IID_IConnectionPointContainer,
169 NULL
172 static const IID * const anchor_iids[] = {
173 &IID_IHTMLDOMNode,
174 &IID_IHTMLDOMNode2,
175 &IID_IHTMLElement,
176 &IID_IHTMLElement2,
177 &IID_IHTMLElement3,
178 &IID_IHTMLAnchorElement,
179 &IID_IDispatchEx,
180 &IID_IConnectionPointContainer,
181 NULL
184 static const IID * const input_iids[] = {
185 &IID_IHTMLDOMNode,
186 &IID_IHTMLDOMNode2,
187 &IID_IHTMLElement,
188 &IID_IHTMLElement2,
189 &IID_IHTMLElement3,
190 &IID_IHTMLInputElement,
191 &IID_IHTMLInputTextElement,
192 &IID_IDispatchEx,
193 &IID_IConnectionPointContainer,
194 NULL
197 static const IID * const select_iids[] = {
198 &IID_IHTMLDOMNode,
199 &IID_IHTMLDOMNode2,
200 &IID_IHTMLElement,
201 &IID_IHTMLElement2,
202 &IID_IHTMLElement3,
203 &IID_IHTMLSelectElement,
204 &IID_IDispatchEx,
205 &IID_IConnectionPointContainer,
206 NULL
209 static const IID * const textarea_iids[] = {
210 &IID_IHTMLDOMNode,
211 &IID_IHTMLDOMNode2,
212 &IID_IHTMLElement,
213 &IID_IHTMLElement2,
214 &IID_IHTMLElement3,
215 &IID_IHTMLTextAreaElement,
216 &IID_IDispatchEx,
217 &IID_IConnectionPointContainer,
218 NULL
221 static const IID * const option_iids[] = {
222 &IID_IHTMLDOMNode,
223 &IID_IHTMLDOMNode2,
224 &IID_IHTMLElement,
225 &IID_IHTMLElement2,
226 &IID_IHTMLElement3,
227 &IID_IHTMLOptionElement,
228 &IID_IDispatchEx,
229 &IID_IConnectionPointContainer,
230 NULL
233 static const IID * const table_iids[] = {
234 &IID_IHTMLDOMNode,
235 &IID_IHTMLDOMNode2,
236 &IID_IHTMLElement,
237 &IID_IHTMLElement2,
238 &IID_IHTMLElement3,
239 &IID_IHTMLTable,
240 &IID_IDispatchEx,
241 &IID_IConnectionPointContainer,
242 NULL
245 static const IID * const script_iids[] = {
246 &IID_IHTMLDOMNode,
247 &IID_IHTMLDOMNode2,
248 &IID_IHTMLElement,
249 &IID_IHTMLElement2,
250 &IID_IHTMLElement3,
251 &IID_IHTMLScriptElement,
252 &IID_IDispatchEx,
253 &IID_IConnectionPointContainer,
254 NULL
257 static const IID * const text_iids[] = {
258 &IID_IHTMLDOMNode,
259 &IID_IHTMLDOMNode2,
260 &IID_IHTMLDOMTextNode,
261 NULL
264 static const IID * const location_iids[] = {
265 &IID_IDispatch,
266 &IID_IHTMLLocation,
267 NULL
270 static const IID * const window_iids[] = {
271 &IID_IDispatch,
272 &IID_IHTMLWindow2,
273 &IID_IHTMLWindow3,
274 &IID_IDispatchEx,
275 &IID_IServiceProvider,
276 NULL
279 static const IID * const comment_iids[] = {
280 &IID_IHTMLDOMNode,
281 &IID_IHTMLDOMNode2,
282 &IID_IHTMLElement,
283 &IID_IHTMLElement2,
284 &IID_IHTMLElement3,
285 &IID_IHTMLCommentElement,
286 &IID_IDispatchEx,
287 &IID_IConnectionPointContainer,
288 NULL
291 static const IID * const img_iids[] = {
292 &IID_IHTMLDOMNode,
293 &IID_IHTMLDOMNode2,
294 &IID_IHTMLElement,
295 &IID_IHTMLElement2,
296 &IID_IHTMLElement3,
297 &IID_IDispatchEx,
298 &IID_IHTMLImgElement,
299 &IID_IConnectionPointContainer,
300 NULL
303 static const IID * const tr_iids[] = {
304 &IID_IHTMLDOMNode,
305 &IID_IHTMLDOMNode2,
306 &IID_IHTMLElement,
307 &IID_IHTMLElement2,
308 &IID_IHTMLElement3,
309 &IID_IDispatchEx,
310 &IID_IHTMLTableRow,
311 &IID_IConnectionPointContainer,
312 NULL
315 static const IID * const td_iids[] = {
316 &IID_IHTMLDOMNode,
317 &IID_IHTMLDOMNode2,
318 &IID_IHTMLElement,
319 &IID_IHTMLElement2,
320 &IID_IHTMLElement3,
321 &IID_IDispatchEx,
322 &IID_IConnectionPointContainer,
323 NULL
326 static const IID * const frame_iids[] = {
327 &IID_IHTMLDOMNode,
328 &IID_IHTMLDOMNode2,
329 &IID_IHTMLElement,
330 &IID_IHTMLElement2,
331 &IID_IHTMLElement3,
332 &IID_IHTMLFrameBase,
333 &IID_IHTMLFrameBase2,
334 &IID_IDispatchEx,
335 &IID_IConnectionPointContainer,
336 NULL
339 static const IID * const object_iids[] = {
340 &IID_IHTMLDOMNode,
341 &IID_IHTMLDOMNode2,
342 &IID_IHTMLElement,
343 &IID_IHTMLElement2,
344 &IID_IHTMLElement3,
345 &IID_IHTMLObjectElement,
346 &IID_IDispatchEx,
347 /* FIXME: No IConnectionPointContainer */
348 NULL
351 static const IID * const embed_iids[] = {
352 &IID_IHTMLDOMNode,
353 &IID_IHTMLDOMNode2,
354 &IID_IHTMLElement,
355 &IID_IHTMLElement2,
356 &IID_IHTMLElement3,
357 &IID_IHTMLEmbedElement,
358 &IID_IDispatchEx,
359 /* FIXME: No IConnectionPointContainer */
360 NULL
363 static const IID * const iframe_iids[] = {
364 &IID_IHTMLDOMNode,
365 &IID_IHTMLDOMNode2,
366 &IID_IHTMLElement,
367 &IID_IHTMLElement2,
368 &IID_IHTMLElement3,
369 &IID_IHTMLFrameBase,
370 &IID_IHTMLFrameBase2,
371 &IID_IHTMLIFrameElement,
372 &IID_IDispatchEx,
373 &IID_IConnectionPointContainer,
374 NULL
377 static const IID * const form_iids[] = {
378 &IID_IHTMLDOMNode,
379 &IID_IHTMLDOMNode2,
380 &IID_IHTMLElement,
381 &IID_IHTMLElement2,
382 &IID_IHTMLElement3,
383 &IID_IHTMLFormElement,
384 &IID_IDispatchEx,
385 &IID_IConnectionPointContainer,
386 NULL
389 static const IID * const styleelem_iids[] = {
390 &IID_IHTMLDOMNode,
391 &IID_IHTMLDOMNode2,
392 &IID_IHTMLElement,
393 &IID_IHTMLElement2,
394 &IID_IHTMLElement3,
395 &IID_IHTMLStyleElement,
396 &IID_IDispatchEx,
397 &IID_IConnectionPointContainer,
398 NULL
401 static const IID * const generic_iids[] = {
402 &IID_IHTMLDOMNode,
403 &IID_IHTMLDOMNode2,
404 &IID_IHTMLElement,
405 &IID_IHTMLElement2,
406 &IID_IHTMLElement3,
407 &IID_IHTMLGenericElement,
408 &IID_IDispatchEx,
409 &IID_IConnectionPointContainer,
410 NULL
413 static const IID * const style_iids[] = {
414 &IID_IUnknown,
415 &IID_IDispatch,
416 &IID_IDispatchEx,
417 &IID_IHTMLStyle,
418 &IID_IHTMLStyle2,
419 &IID_IHTMLStyle3,
420 &IID_IHTMLStyle4,
421 NULL
424 static const IID * const cstyle_iids[] = {
425 &IID_IUnknown,
426 &IID_IDispatch,
427 &IID_IDispatchEx,
428 &IID_IHTMLCurrentStyle,
429 NULL
432 static const IID * const img_factory_iids[] = {
433 &IID_IUnknown,
434 &IID_IDispatch,
435 &IID_IDispatchEx,
436 &IID_IHTMLImageElementFactory,
437 NULL
440 typedef struct {
441 const char *tag;
442 REFIID *iids;
443 const IID *dispiid;
444 } elem_type_info_t;
446 static const elem_type_info_t elem_type_infos[] = {
447 {"", none_iids, NULL},
448 {"HTML", elem_iids, NULL},
449 {"HEAD", elem_iids, NULL},
450 {"TITLE", elem_iids, NULL},
451 {"BODY", body_iids, &DIID_DispHTMLBody},
452 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
453 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
454 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
455 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
456 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
457 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
458 {"BLOCKQUOTE",elem_iids, NULL},
459 {"P", elem_iids, NULL},
460 {"BR", elem_iids, NULL},
461 {"TABLE", table_iids, &DIID_DispHTMLTable},
462 {"TBODY", elem_iids, NULL},
463 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
464 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
465 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
466 {"!", comment_iids, &DIID_DispHTMLCommentElement},
467 {"IMG", img_iids, &DIID_DispHTMLImg},
468 {"TR", tr_iids, &DIID_DispHTMLTableRow},
469 {"TD", td_iids, NULL},
470 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
471 {"FORM", form_iids, &DIID_DispHTMLFormElement},
472 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
473 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
474 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
475 {"DIV", elem_iids, NULL}
478 static const char *dbgstr_guid(REFIID riid)
480 static char buf[50];
482 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
483 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
484 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
485 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
487 return buf;
490 static int strcmp_wa(LPCWSTR strw, const char *stra)
492 CHAR buf[512];
493 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
494 return lstrcmpA(stra, buf);
497 static BSTR a2bstr(const char *str)
499 BSTR ret;
500 int len;
502 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
503 ret = SysAllocStringLen(NULL, len);
504 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
506 return ret;
509 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
511 IUnknown *unk1, *unk2;
513 if(iface1 == iface2)
514 return TRUE;
516 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
517 IUnknown_Release(unk1);
518 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
519 IUnknown_Release(unk2);
521 return unk1 == unk2;
524 static IHTMLDocument2 *create_document(void)
526 IHTMLDocument2 *doc;
527 IHTMLDocument5 *doc5;
528 HRESULT hres;
530 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
531 &IID_IHTMLDocument2, (void**)&doc);
532 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
533 if(FAILED(hres))
534 return NULL;
536 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
537 if(FAILED(hres)) {
538 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
539 IHTMLDocument2_Release(doc);
540 return NULL;
543 IHTMLDocument5_Release(doc5);
544 return doc;
547 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
548 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
550 const IID * const *piid;
551 IUnknown *unk;
552 HRESULT hres;
554 for(piid = iids; *piid; piid++) {
555 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
556 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
557 if(SUCCEEDED(hres))
558 IUnknown_Release(unk);
562 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
563 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
565 IDispatchEx *dispex;
566 ITypeInfo *typeinfo;
567 BOOL ret = FALSE;
568 UINT ticnt;
569 HRESULT hres;
571 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
572 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
573 if(FAILED(hres))
574 return FALSE;
576 ticnt = 0xdeadbeef;
577 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
578 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
579 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
581 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
582 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
584 if(SUCCEEDED(hres)) {
585 TYPEATTR *type_attr;
587 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
588 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
589 if(hres == S_OK) {
590 *iid = type_attr->guid;
591 ret = TRUE;
594 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
595 ITypeInfo_Release(typeinfo);
598 IDispatchEx_Release(dispex);
599 return ret;
602 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
603 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
605 DISPPARAMS dp = {NULL,NULL,0,0};
606 IDispatchEx *dispex;
607 EXCEPINFO ei;
608 VARIANT var;
609 HRESULT hres;
611 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
612 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
613 if(FAILED(hres))
614 return;
616 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
617 IDispatchEx_Release(dispex);
618 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
620 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
621 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
622 VariantClear(&var);
625 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
626 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
628 IID iid;
630 if(_test_get_dispid(line, unk, &iid))
631 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
633 if(val)
634 _test_disp_value(line, unk, val);
637 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
638 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
640 IID iid;
642 if(_test_get_dispid(line, unk, &iid))
643 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
644 "unexpected guid %s\n", dbgstr_guid(&iid));
646 if(val)
647 _test_disp_value(line, unk, val);
650 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
651 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
653 IHTMLElement *elem;
654 HRESULT hres;
656 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
657 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
658 return elem;
661 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
662 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
664 IHTMLElement2 *elem;
665 HRESULT hres;
667 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
668 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
669 return elem;
672 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
673 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
675 IHTMLElement3 *elem;
676 HRESULT hres;
678 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
679 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
680 return elem;
683 #define get_node_iface(u) _get_node_iface(__LINE__,u)
684 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
686 IHTMLDOMNode *node;
687 HRESULT hres;
689 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
690 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
691 return node;
694 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
695 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
697 IHTMLDOMNode2 *node;
698 HRESULT hres;
700 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
701 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
702 return node;
705 #define get_img_iface(u) _get_img_iface(__LINE__,u)
706 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
708 IHTMLImgElement *img;
709 HRESULT hres;
711 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
712 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
713 return img;
716 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
717 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
719 IHTMLAnchorElement *anchor;
720 HRESULT hres;
722 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
723 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
724 return anchor;
727 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
728 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
730 IHTMLTextAreaElement *textarea;
731 HRESULT hres;
733 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
734 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
735 return textarea;
738 #define get_select_iface(u) _get_select_iface(__LINE__,u)
739 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
741 IHTMLSelectElement *select;
742 HRESULT hres;
744 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
745 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
746 return select;
749 #define get_form_iface(u) _get_form_iface(__LINE__,u)
750 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
752 IHTMLFormElement *form;
753 HRESULT hres;
755 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
756 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
757 return form;
760 #define get_text_iface(u) _get_text_iface(__LINE__,u)
761 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
763 IHTMLDOMTextNode *text;
764 HRESULT hres;
766 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
767 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
768 return text;
771 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
772 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
774 IHTMLCommentElement *comment;
775 HRESULT hres;
777 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
778 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
779 return comment;
782 #define get_object_iface(u) _get_object_iface(__LINE__,u)
783 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
785 IHTMLObjectElement *obj;
786 HRESULT hres;
788 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
789 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
790 return obj;
793 #define get_style_iface(u) _get_style_iface(__LINE__,u)
794 static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
796 IHTMLStyleElement *obj;
797 HRESULT hres;
799 hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
800 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
801 return obj;
804 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
805 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
807 IHTMLDOMNode *node = _get_node_iface(line, unk);
808 BSTR name;
809 HRESULT hres;
811 hres = IHTMLDOMNode_get_nodeName(node, &name);
812 IHTMLDOMNode_Release(node);
813 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
814 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
816 SysFreeString(name);
819 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
820 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
822 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
823 IDispatch *disp = (void*)0xdeadbeef;
824 IHTMLDocument2 *doc = NULL;
825 HRESULT hres;
827 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
828 IHTMLDOMNode2_Release(node);
829 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
831 if(disp) {
832 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
833 IDispatch_Release(disp);
834 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
837 return doc;
840 #define get_doc_window(d) _get_doc_window(__LINE__,d)
841 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
843 IHTMLWindow2 *window;
844 HRESULT hres;
846 window = NULL;
847 hres = IHTMLDocument2_get_parentWindow(doc, &window);
848 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
849 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
851 return window;
854 #define clone_node(n,d) _clone_node(__LINE__,n,d)
855 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
857 IHTMLDOMNode *node = _get_node_iface(line, unk);
858 IHTMLDOMNode *ret = NULL;
859 HRESULT hres;
861 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
862 IHTMLDOMNode_Release(node);
863 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
864 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
866 return ret;
870 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
871 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
873 IHTMLElement *elem = _get_elem_iface(line, unk);
874 BSTR tag;
875 HRESULT hres;
877 hres = IHTMLElement_get_tagName(elem, &tag);
878 IHTMLElement_Release(elem);
879 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
880 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
882 SysFreeString(tag);
885 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
886 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
888 _test_elem_tag(line, unk, elem_type_infos[type].tag);
889 _test_ifaces(line, unk, elem_type_infos[type].iids);
891 if(elem_type_infos[type].dispiid && type != ET_A)
892 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
895 #define get_node_type(n) _get_node_type(__LINE__,n)
896 static LONG _get_node_type(unsigned line, IUnknown *unk)
898 IHTMLDOMNode *node = _get_node_iface(line, unk);
899 LONG type = -1;
900 HRESULT hres;
902 hres = IHTMLDOMNode_get_nodeType(node, &type);
903 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
905 IHTMLDOMNode_Release(node);
907 return type;
910 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
911 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
913 IHTMLDOMNode *node = _get_node_iface(line, unk);
914 IHTMLDOMChildrenCollection *col = NULL;
915 IDispatch *disp;
916 HRESULT hres;
918 hres = IHTMLDOMNode_get_childNodes(node, &disp);
919 IHTMLDOMNode_Release(node);
920 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
921 if(FAILED(hres))
922 return NULL;
924 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
925 IDispatch_Release(disp);
926 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
928 return col;
931 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
932 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
934 IHTMLDOMNode *node = NULL;
935 IDispatch *disp;
936 HRESULT hres;
938 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
939 ok(hres == S_OK, "item failed: %08x\n", hres);
941 node = _get_node_iface(line, (IUnknown*)disp);
942 IDispatch_Release(disp);
944 return node;
947 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
948 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
950 VARIANT value;
951 BSTR tmp;
952 HRESULT hres;
954 VariantInit(&value);
956 tmp = a2bstr(name);
957 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
958 SysFreeString(tmp);
959 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
961 if(exval) {
962 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
963 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
964 }else {
965 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
968 VariantClear(&value);
971 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
972 static void _test_elem_offset(unsigned line, IUnknown *unk)
974 IHTMLElement *elem = _get_elem_iface(line, unk);
975 LONG l;
976 HRESULT hres;
978 hres = IHTMLElement_get_offsetTop(elem, &l);
979 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
981 hres = IHTMLElement_get_offsetHeight(elem, &l);
982 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
984 hres = IHTMLElement_get_offsetWidth(elem, &l);
985 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
987 IHTMLElement_Release(elem);
990 #define get_doc_node(d) _get_doc_node(__LINE__,d)
991 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
993 IHTMLWindow2 *window;
994 IHTMLDocument2 *ret;
995 HRESULT hres;
997 hres = IHTMLDocument2_get_parentWindow(doc, &window);
998 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
1000 hres = IHTMLWindow2_get_document(window, &ret);
1001 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
1002 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
1004 return ret;
1007 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1008 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
1010 BSTR name;
1011 HRESULT hres;
1013 hres = IHTMLWindow2_get_name(window, &name);
1014 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
1015 if(exname)
1016 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
1017 else
1018 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
1019 SysFreeString(name);
1022 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1023 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
1025 BSTR str;
1026 HRESULT hres;
1028 str = a2bstr(name);
1029 hres = IHTMLWindow2_put_name(window, str);
1030 SysFreeString(str);
1031 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
1033 _test_window_name(line, window, name);
1036 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1037 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
1039 LONG length = -1;
1040 HRESULT hres;
1042 hres = IHTMLWindow2_get_length(window, &length);
1043 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1044 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1047 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1048 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1050 IHTMLFrameBase2 *base2;
1051 IHTMLWindow2 *window;
1052 HRESULT hres;
1054 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1055 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1057 window = NULL;
1058 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1059 IHTMLFrameBase2_Release(base2);
1060 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1061 ok(window != NULL, "contentWindow = NULL\n");
1063 return window;
1066 static void test_get_set_attr(IHTMLDocument2 *doc)
1068 IHTMLElement *elem;
1069 IHTMLDocument3 *doc3;
1070 HRESULT hres;
1071 BSTR bstr;
1072 VARIANT val;
1074 /* grab an element to test with */
1075 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1076 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1078 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1079 IHTMLDocument3_Release(doc3);
1080 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1082 /* get a non-present attribute */
1083 bstr = a2bstr("notAnAttribute");
1084 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1085 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1086 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1087 VariantClear(&val);
1088 SysFreeString(bstr);
1090 /* get a present attribute */
1091 bstr = a2bstr("scrollHeight");
1092 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1093 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1094 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1095 VariantClear(&val);
1096 SysFreeString(bstr);
1098 /* create a new BSTR attribute */
1099 bstr = a2bstr("newAttribute");
1101 V_VT(&val) = VT_BSTR;
1102 V_BSTR(&val) = a2bstr("the value");
1103 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1104 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1105 VariantClear(&val);
1107 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1108 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1109 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1110 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)));
1111 VariantClear(&val);
1113 /* overwrite the attribute with a BOOL */
1114 V_VT(&val) = VT_BOOL;
1115 V_BOOL(&val) = VARIANT_TRUE;
1116 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1117 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1118 VariantClear(&val);
1120 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1121 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1122 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1123 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1124 VariantClear(&val);
1126 SysFreeString(bstr);
1128 /* case-insensitive */
1129 bstr = a2bstr("newattribute");
1130 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1131 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1132 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1133 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1134 VariantClear(&val);
1135 SysFreeString(bstr);
1137 IHTMLElement_Release(elem);
1140 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1141 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1143 IHTMLElement *elem;
1144 IHTMLDocument3 *doc3;
1145 HRESULT hres;
1147 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1148 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1149 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1150 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1151 IHTMLDocument3_Release(doc3);
1153 return elem;
1156 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1157 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1159 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1160 BSTR str;
1161 HRESULT hres;
1163 hres = IHTMLAnchorElement_get_href(anchor, &str);
1164 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1165 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1166 SysFreeString(str);
1168 _test_disp_value(line, unk, exhref);
1171 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1172 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1174 BSTR bstr;
1175 HRESULT hres;
1177 hres = IHTMLOptionElement_get_text(option, &bstr);
1178 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1179 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1180 SysFreeString(bstr);
1183 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1184 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1186 BSTR bstr;
1187 HRESULT hres;
1189 bstr = a2bstr(text);
1190 hres = IHTMLOptionElement_put_text(option, bstr);
1191 SysFreeString(bstr);
1192 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1194 _test_option_text(line, option, text);
1197 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1198 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1200 BSTR bstr;
1201 HRESULT hres;
1203 hres = IHTMLOptionElement_get_value(option, &bstr);
1204 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1205 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1206 SysFreeString(bstr);
1209 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1210 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1212 BSTR bstr;
1213 HRESULT hres;
1215 bstr = a2bstr(value);
1216 hres = IHTMLOptionElement_put_value(option, bstr);
1217 SysFreeString(bstr);
1218 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1220 _test_option_value(line, option, value);
1223 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1224 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1226 VARIANT_BOOL b = 0x100;
1227 HRESULT hres;
1229 hres = IHTMLOptionElement_get_selected(option, &b);
1230 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1231 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1234 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1235 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1237 HRESULT hres;
1239 hres = IHTMLOptionElement_put_selected(option, b);
1240 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1241 _test_option_selected(line, option, b);
1244 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1245 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1247 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1248 BSTR value = (void*)0xdeadbeef;
1249 HRESULT hres;
1251 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1252 IHTMLTextAreaElement_Release(textarea);
1253 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1254 if(exval)
1255 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1256 else
1257 ok_(__FILE__,line)(!value, "value = %p\n", value);
1258 SysFreeString(value);
1261 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1262 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1264 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1265 BSTR tmp = a2bstr(value);
1266 HRESULT hres;
1268 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1269 IHTMLTextAreaElement_Release(textarea);
1270 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1271 SysFreeString(tmp);
1273 _test_textarea_value(line, unk, value);
1276 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1277 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1279 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1280 VARIANT_BOOL b = 0x100;
1281 HRESULT hres;
1283 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1284 IHTMLTextAreaElement_Release(textarea);
1285 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1286 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1289 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1290 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1292 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1293 HRESULT hres;
1295 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1296 IHTMLTextAreaElement_Release(textarea);
1297 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1299 _test_textarea_readonly(line, unk, b);
1302 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1303 static void _test_textarea_type(unsigned line, IUnknown *unk)
1305 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1306 BSTR type = (void*)0xdeadbeef;
1307 HRESULT hres;
1309 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1310 IHTMLTextAreaElement_Release(textarea);
1311 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1312 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1313 SysFreeString(type);
1316 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1317 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1319 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1320 BSTR text;
1321 HRESULT hres;
1323 text = a2bstr(extext);
1324 hres = IHTMLCommentElement_get_text(comment, &text);
1325 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1326 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1328 IHTMLCommentElement_Release(comment);
1329 SysFreeString(text);
1332 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1333 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1335 IHTMLObjectElement *object = _get_object_iface(line, unk);
1336 LONG l;
1337 HRESULT hres;
1339 l = 0xdeadbeef;
1340 hres = IHTMLObjectElement_get_vspace(object, &l);
1341 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1342 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1343 IHTMLObjectElement_Release(object);
1346 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1347 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1348 const char *txt, const char *val)
1350 IHTMLOptionElementFactory *factory;
1351 IHTMLOptionElement *option;
1352 IHTMLWindow2 *window;
1353 VARIANT text, value, empty;
1354 HRESULT hres;
1356 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1357 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1359 hres = IHTMLWindow2_get_Option(window, &factory);
1360 IHTMLWindow2_Release(window);
1361 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1363 V_VT(&text) = VT_BSTR;
1364 V_BSTR(&text) = a2bstr(txt);
1365 V_VT(&value) = VT_BSTR;
1366 V_BSTR(&value) = a2bstr(val);
1367 V_VT(&empty) = VT_EMPTY;
1369 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1370 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1372 IHTMLOptionElementFactory_Release(factory);
1373 VariantClear(&text);
1374 VariantClear(&value);
1376 _test_option_text(line, option, txt);
1377 _test_option_value(line, option, val);
1378 _test_option_selected(line, option, VARIANT_FALSE);
1380 return option;
1383 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1384 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1386 LONG found = -1;
1387 HRESULT hres;
1389 hres = IHTMLImgElement_get_width(img, &found);
1390 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1391 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1394 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1395 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1397 HRESULT hres;
1399 hres = IHTMLImgElement_put_width(img, width);
1400 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1402 _test_img_width(line, img, width);
1405 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1406 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1408 LONG found = -1;
1409 HRESULT hres;
1411 hres = IHTMLImgElement_get_height(img, &found);
1412 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1413 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1416 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1417 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1419 HRESULT hres;
1421 hres = IHTMLImgElement_put_height(img, height);
1422 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1424 _test_img_height(line, img, height);
1427 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1428 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1429 LONG wdth, LONG hght)
1431 IHTMLImageElementFactory *factory;
1432 IHTMLImgElement *img;
1433 IHTMLWindow2 *window;
1434 VARIANT width, height;
1435 char buf[16];
1436 HRESULT hres;
1438 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1439 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1441 hres = IHTMLWindow2_get_Image(window, &factory);
1442 IHTMLWindow2_Release(window);
1443 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1445 test_ifaces((IUnknown*)factory, img_factory_iids);
1446 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1448 if(wdth >= 0){
1449 snprintf(buf, 16, "%d", wdth);
1450 V_VT(&width) = VT_BSTR;
1451 V_BSTR(&width) = a2bstr(buf);
1452 }else{
1453 V_VT(&width) = VT_EMPTY;
1454 wdth = 0;
1457 if(hght >= 0){
1458 snprintf(buf, 16, "%d", hght);
1459 V_VT(&height) = VT_BSTR;
1460 V_BSTR(&height) = a2bstr(buf);
1461 }else{
1462 V_VT(&height) = VT_EMPTY;
1463 hght = 0;
1466 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1467 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1469 IHTMLImageElementFactory_Release(factory);
1470 VariantClear(&width);
1471 VariantClear(&height);
1473 if(SUCCEEDED(hres)) {
1474 _test_img_width(line, img, wdth);
1475 _test_img_height(line, img, hght);
1476 return img;
1479 return NULL;
1482 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1483 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1485 LONG len = 0xdeadbeef;
1486 HRESULT hres;
1488 hres = IHTMLSelectElement_get_length(select, &len);
1489 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1490 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1493 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1494 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1496 IHTMLSelectElement *select = _get_select_iface(line, unk);
1497 HRESULT hres;
1499 hres = IHTMLSelectElement_put_length(select, length);
1500 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1501 _test_select_length(line, select, length);
1502 IHTMLSelectElement_Release(select);
1505 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1506 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1508 LONG idx = 0xdeadbeef;
1509 HRESULT hres;
1511 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1512 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1513 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1516 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1517 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1519 HRESULT hres;
1521 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1522 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1523 _test_select_selidx(line, select, index);
1526 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1527 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1529 BSTR val;
1530 HRESULT hres;
1532 hres = IHTMLSelectElement_get_value(select, &val);
1533 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1534 if(exval)
1535 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1536 else
1537 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1538 SysFreeString(val);
1541 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1542 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1544 BSTR bstr;
1545 HRESULT hres;
1547 bstr = a2bstr(val);
1548 hres = IHTMLSelectElement_put_value(select, bstr);
1549 SysFreeString(bstr);
1550 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1553 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1554 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1556 BSTR type;
1557 HRESULT hres;
1559 hres = IHTMLSelectElement_get_type(select, &type);
1560 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1561 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1562 SysFreeString(type);
1565 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1566 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1568 BSTR text;
1569 HRESULT hres;
1571 hres = IHTMLTxtRange_get_text(range, &text);
1572 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1574 if(extext) {
1575 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1576 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1577 }else {
1578 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1581 SysFreeString(text);
1585 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1586 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1588 HRESULT hres;
1590 hres = IHTMLTxtRange_collapse(range, b);
1591 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1592 _test_range_text(line, range, NULL);
1595 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1596 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1597 VARIANT_BOOL exb, const char *extext)
1599 VARIANT_BOOL b = 0xe0e0;
1600 HRESULT hres;
1602 hres = IHTMLTxtRange_expand(range, unit, &b);
1603 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1604 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1605 _test_range_text(line, range, extext);
1608 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1609 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1611 LONG c = 0xdeadbeef;
1612 HRESULT hres;
1614 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1615 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1616 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1617 _test_range_text(line, range, NULL);
1620 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1621 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1622 LPWSTR unit, LONG cnt, LONG excnt)
1624 LONG c = 0xdeadbeef;
1625 HRESULT hres;
1627 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1628 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1629 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1632 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1633 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1635 LONG c = 0xdeadbeef;
1636 HRESULT hres;
1638 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1639 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1640 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1643 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1644 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1646 HRESULT hres;
1647 BSTR bstr = a2bstr(text);
1649 hres = IHTMLTxtRange_put_text(range, bstr);
1650 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1651 SysFreeString(bstr);
1652 _test_range_text(line, range, NULL);
1655 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1656 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1658 VARIANT_BOOL b;
1659 HRESULT hres;
1661 b = 0xe0e0;
1662 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1663 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1664 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1667 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1668 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1670 VARIANT_BOOL b;
1671 HRESULT hres;
1673 b = 0xe0e0;
1674 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1675 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1676 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1678 b = 0xe0e0;
1679 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1680 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1681 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1683 if(exb) {
1684 test_range_inrange(range1, range2, VARIANT_TRUE);
1685 test_range_inrange(range2, range1, VARIANT_TRUE);
1689 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1690 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1692 IHTMLElement *elem;
1693 HRESULT hres;
1695 hres = IHTMLTxtRange_parentElement(range, &elem);
1696 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1698 _test_elem_type(line, (IUnknown*)elem, type);
1700 IHTMLElement_Release(elem);
1703 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1704 static void _test_elem_collection(unsigned line, IUnknown *unk,
1705 const elem_type_t *elem_types, LONG exlen)
1707 IHTMLElementCollection *col;
1708 LONG len;
1709 DWORD i;
1710 VARIANT name, index;
1711 IDispatch *disp, *disp2;
1712 HRESULT hres;
1714 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1715 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1717 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1719 hres = IHTMLElementCollection_get_length(col, &len);
1720 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1721 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1723 if(len > exlen)
1724 len = exlen;
1726 V_VT(&index) = VT_EMPTY;
1728 for(i=0; i<len; i++) {
1729 V_VT(&name) = VT_I4;
1730 V_I4(&name) = i;
1731 disp = (void*)0xdeadbeef;
1732 hres = IHTMLElementCollection_item(col, name, index, &disp);
1733 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1734 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1735 if(FAILED(hres) || !disp)
1736 continue;
1738 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1740 if(!i) {
1741 V_VT(&name) = VT_UINT;
1742 V_I4(&name) = 0;
1743 disp2 = (void*)0xdeadbeef;
1744 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1745 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1746 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1747 if(disp2)
1748 IDispatch_Release(disp2);
1751 IDispatch_Release(disp);
1754 V_VT(&name) = VT_I4;
1755 V_I4(&name) = len;
1756 disp = (void*)0xdeadbeef;
1757 hres = IHTMLElementCollection_item(col, name, index, &disp);
1758 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1759 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1761 V_VT(&name) = VT_I4;
1762 V_I4(&name) = -1;
1763 disp = (void*)0xdeadbeef;
1764 hres = IHTMLElementCollection_item(col, name, index, &disp);
1765 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1766 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1768 IHTMLElementCollection_Release(col);
1771 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1772 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1774 IHTMLElement *elem = _get_elem_iface(line, unk);
1775 IDispatch *disp;
1776 HRESULT hres;
1778 hres = IHTMLElement_get_all(elem, &disp);
1779 IHTMLElement_Release(elem);
1780 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1782 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1783 IDispatch_Release(disp);
1786 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1787 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1789 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1790 IHTMLElementCollection *col = NULL;
1791 elem_type_t *types = NULL;
1792 BSTR tmp;
1793 int i;
1794 HRESULT hres;
1796 tmp = a2bstr(elem_type_infos[type].tag);
1797 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1798 SysFreeString(tmp);
1799 IHTMLElement2_Release(elem);
1800 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1801 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1803 if(exlen) {
1804 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1805 for(i=0; i<exlen; i++)
1806 types[i] = type;
1809 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1811 HeapFree(GetProcessHeap(), 0, types);
1814 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1815 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1817 BSTR text = NULL;
1818 HRESULT hres;
1820 hres = IHTMLElement_get_innerText(elem, &text);
1821 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1822 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1823 wine_dbgstr_w(text), extext);
1824 SysFreeString(text);
1827 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1828 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1830 IHTMLDOMChildrenCollection *col;
1831 BSTR str;
1832 HRESULT hres;
1834 str = a2bstr(text);
1835 hres = IHTMLElement_put_innerText(elem, str);
1836 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1837 SysFreeString(str);
1839 _test_elem_innertext(line, elem, text);
1842 col = _get_child_nodes(line, (IUnknown*)elem);
1843 ok(col != NULL, "col == NULL\n");
1844 if(col) {
1845 LONG length = 0, type;
1846 IHTMLDOMNode *node;
1848 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1849 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1850 ok(length == 1, "length = %d\n", length);
1852 node = _get_child_item(line, col, 0);
1853 ok(node != NULL, "node == NULL\n");
1854 if(node) {
1855 type = _get_node_type(line, (IUnknown*)node);
1856 ok(type == 3, "type=%d\n", type);
1857 IHTMLDOMNode_Release(node);
1860 IHTMLDOMChildrenCollection_Release(col);
1865 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1866 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1868 IHTMLElement *elem = _get_elem_iface(line, unk);
1869 BSTR html;
1870 HRESULT hres;
1872 hres = IHTMLElement_get_innerHTML(elem, &html);
1873 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1874 if(inner_html)
1875 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1876 else
1877 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1879 IHTMLElement_Release(elem);
1880 SysFreeString(html);
1883 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1884 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1886 IHTMLElement *elem = _get_elem_iface(line, unk);
1887 BSTR html;
1888 HRESULT hres;
1890 html = a2bstr(inner_html);
1891 hres = IHTMLElement_put_innerHTML(elem, html);
1892 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1894 IHTMLElement_Release(elem);
1895 SysFreeString(html);
1898 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1899 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1901 IHTMLElement *elem = _get_elem_iface(line, unk);
1902 BSTR html;
1903 HRESULT hres;
1905 html = a2bstr(outer_html);
1906 hres = IHTMLElement_put_outerHTML(elem, html);
1907 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1909 IHTMLElement_Release(elem);
1910 SysFreeString(html);
1913 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1914 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1916 IHTMLElement *elem = _get_elem_iface(line, unk);
1917 BSTR html;
1918 HRESULT hres;
1920 hres = IHTMLElement_get_outerHTML(elem, &html);
1921 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1922 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1924 IHTMLElement_Release(elem);
1925 SysFreeString(html);
1928 #define get_first_child(n) _get_first_child(__LINE__,n)
1929 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1931 IHTMLDOMNode *node = _get_node_iface(line, unk);
1932 IHTMLDOMNode *child = NULL;
1933 HRESULT hres;
1935 hres = IHTMLDOMNode_get_firstChild(node, &child);
1936 IHTMLDOMNode_Release(node);
1937 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1939 return child;
1942 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1943 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1945 IHTMLDOMNode *node = _get_node_iface(line, unk);
1946 VARIANT_BOOL b = 0xdead;
1947 HRESULT hres;
1949 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1950 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1951 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1953 IHTMLDOMNode_Release(node);
1956 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1957 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1959 IHTMLDOMNode *node = _get_node_iface(line, unk);
1960 IHTMLDOMNode *parent;
1961 HRESULT hres;
1963 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1964 IHTMLDOMNode_Release(node);
1965 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1967 return parent;
1970 #define node_get_next(u) _node_get_next(__LINE__,u)
1971 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1973 IHTMLDOMNode *node = _get_node_iface(line, unk);
1974 IHTMLDOMNode *next;
1975 HRESULT hres;
1977 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1978 IHTMLDOMNode_Release(node);
1979 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1981 return next;
1984 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1985 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1987 IHTMLElement *elem = _get_elem_iface(line, unk);
1988 IHTMLElement *parent;
1989 HRESULT hres;
1991 hres = IHTMLElement_get_parentElement(elem, &parent);
1992 IHTMLElement_Release(elem);
1993 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1995 return parent;
1998 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1999 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
2001 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2002 VARIANT_BOOL disabled = 100;
2003 HRESULT hres;
2005 if (!elem3) return;
2006 hres = IHTMLElement3_get_disabled(elem3, &disabled);
2007 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2008 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2009 IHTMLElement3_Release(elem3);
2012 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2013 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
2015 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2016 HRESULT hres;
2018 if (!elem3) return;
2019 hres = IHTMLElement3_put_disabled(elem3, b);
2020 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2022 IHTMLElement3_Release(elem3);
2023 _test_elem3_get_disabled(line, unk, b);
2026 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2027 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2029 VARIANT_BOOL disabled = 100;
2030 HRESULT hres;
2032 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2033 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2034 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2036 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2039 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2040 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2042 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2043 LONG length;
2044 HRESULT hres;
2046 hres = IHTMLDOMTextNode_get_length(text, &length);
2047 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2048 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2049 IHTMLDOMTextNode_Release(text);
2052 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2053 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2055 HRESULT hres;
2057 hres = IHTMLSelectElement_put_disabled(select, b);
2058 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2060 _test_select_get_disabled(line, select, b);
2063 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2064 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2066 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2067 IHTMLTextContainer *txtcont;
2068 LONG l = -1, l2 = -1;
2069 HRESULT hres;
2071 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2072 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2073 IHTMLElement2_Release(elem);
2075 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2076 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2078 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2079 IHTMLTextContainer_Release(txtcont);
2080 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2081 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2083 return l;
2086 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2087 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2089 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2090 IHTMLTextContainer *txtcont;
2091 LONG l = -1, l2 = -1;
2092 HRESULT hres;
2094 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2095 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2096 IHTMLElement2_Release(elem);
2098 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2099 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2101 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2102 IHTMLTextContainer_Release(txtcont);
2103 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2104 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2106 return l;
2109 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2110 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2112 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2113 IHTMLTextContainer *txtcont;
2114 LONG l = -1, l2 = -1;
2115 HRESULT hres;
2117 hres = IHTMLElement2_get_scrollTop(elem, &l);
2118 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2119 IHTMLElement2_Release(elem);
2121 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2122 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2124 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2125 IHTMLTextContainer_Release(txtcont);
2126 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2127 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2129 return l;
2132 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2133 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2135 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2136 IHTMLTextContainer *txtcont;
2137 LONG l = -1, l2 = -1;
2138 HRESULT hres;
2140 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2141 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2143 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2144 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2145 IHTMLElement2_Release(elem);
2147 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2148 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2150 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2151 IHTMLTextContainer_Release(txtcont);
2152 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2153 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2156 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2157 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2159 IHTMLImgElement *img = _get_img_iface(line, unk);
2160 BSTR src;
2161 HRESULT hres;
2163 hres = IHTMLImgElement_get_src(img, &src);
2164 IHTMLImgElement_Release(img);
2165 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2166 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2167 SysFreeString(src);
2170 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2171 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2173 IHTMLImgElement *img = _get_img_iface(line, unk);
2174 BSTR tmp;
2175 HRESULT hres;
2177 tmp = a2bstr(src);
2178 hres = IHTMLImgElement_put_src(img, tmp);
2179 IHTMLImgElement_Release(img);
2180 SysFreeString(tmp);
2181 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2183 _test_img_src(line, unk, src);
2186 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2187 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2189 IHTMLImgElement *img = _get_img_iface(line, unk);
2190 BSTR alt;
2191 HRESULT hres;
2193 hres = IHTMLImgElement_get_alt(img, &alt);
2194 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2195 if(exalt)
2196 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2197 else
2198 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2199 SysFreeString(alt);
2202 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2203 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2205 IHTMLImgElement *img = _get_img_iface(line, unk);
2206 BSTR tmp;
2207 HRESULT hres;
2209 tmp = a2bstr(alt);
2210 hres = IHTMLImgElement_put_alt(img, tmp);
2211 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2212 SysFreeString(tmp);
2214 _test_img_alt(line, unk, alt);
2217 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2218 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2220 IHTMLImgElement *img = _get_img_iface(line, unk);
2221 BSTR sName;
2222 HRESULT hres;
2224 hres = IHTMLImgElement_get_name(img, &sName);
2225 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2226 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2227 IHTMLImgElement_Release(img);
2228 SysFreeString(sName);
2231 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2232 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2234 BSTR type;
2235 HRESULT hres;
2237 hres = IHTMLInputElement_get_type(input, &type);
2238 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2239 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2240 SysFreeString(type);
2243 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2244 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2246 BSTR name = (BSTR)0xdeadbeef;
2247 HRESULT hres;
2249 hres = IHTMLInputElement_get_name(input, &name);
2250 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2251 if(exname)
2252 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2253 else
2254 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2255 SysFreeString(name);
2258 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2259 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2261 BSTR tmp = a2bstr(name);
2262 HRESULT hres;
2264 hres = IHTMLInputElement_put_name(input, tmp);
2265 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2266 SysFreeString(tmp);
2268 _test_input_name(line, input, name);
2271 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2272 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2274 VARIANT_BOOL disabled = 100;
2275 HRESULT hres;
2277 hres = IHTMLInputElement_get_disabled(input, &disabled);
2278 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2279 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2281 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2284 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2285 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2287 HRESULT hres;
2289 hres = IHTMLInputElement_put_disabled(input, b);
2290 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2292 _test_input_get_disabled(line, input, b);
2295 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2296 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2298 VARIANT_BOOL checked = 100;
2299 HRESULT hres;
2301 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2302 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2303 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2306 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2307 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2309 HRESULT hres;
2311 hres = IHTMLInputElement_put_defaultChecked(input, b);
2312 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2314 _test_input_get_defaultchecked(line, input, b);
2317 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2318 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2320 VARIANT_BOOL checked = 100;
2321 HRESULT hres;
2323 hres = IHTMLInputElement_get_checked(input, &checked);
2324 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2325 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2328 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2329 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2331 HRESULT hres;
2333 hres = IHTMLInputElement_put_checked(input, b);
2334 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2336 _test_input_get_checked(line, input, b);
2339 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2340 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2342 IHTMLInputElement *input;
2343 BSTR bstr;
2344 HRESULT hres;
2346 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2347 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2348 if(FAILED(hres))
2349 return;
2351 hres = IHTMLInputElement_get_value(input, &bstr);
2352 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2353 if(exval)
2354 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2355 else
2356 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2357 SysFreeString(bstr);
2358 IHTMLInputElement_Release(input);
2361 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2362 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2364 IHTMLInputElement *input;
2365 BSTR bstr;
2366 HRESULT hres;
2368 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2369 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2370 if(FAILED(hres))
2371 return;
2373 bstr = a2bstr(val);
2374 hres = IHTMLInputElement_get_value(input, &bstr);
2375 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2376 SysFreeString(bstr);
2377 IHTMLInputElement_Release(input);
2380 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2381 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2383 BSTR src;
2384 HRESULT hres;
2386 hres = IHTMLInputElement_get_src(input, &src);
2387 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2388 if(exsrc)
2389 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2390 else
2391 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2392 SysFreeString(src);
2395 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2396 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2398 BSTR tmp;
2399 HRESULT hres;
2401 tmp = a2bstr(src);
2402 hres = IHTMLInputElement_put_src(input, tmp);
2403 SysFreeString(tmp);
2404 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2406 _test_input_src(line, input, src);
2409 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2410 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2412 IHTMLElement *elem = _get_elem_iface(line, unk);
2413 BSTR class = (void*)0xdeadbeef;
2414 HRESULT hres;
2416 hres = IHTMLElement_get_className(elem, &class);
2417 IHTMLElement_Release(elem);
2418 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2419 if(exclass)
2420 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2421 else
2422 ok_(__FILE__,line) (!class, "class != NULL\n");
2423 SysFreeString(class);
2426 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2427 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2429 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2430 short index = -3;
2431 HRESULT hres;
2433 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2434 IHTMLElement2_Release(elem2);
2435 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2436 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2439 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2440 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2442 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2443 HRESULT hres;
2445 hres = IHTMLElement2_put_tabIndex(elem2, index);
2446 IHTMLElement2_Release(elem2);
2447 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2449 _test_elem_tabindex(line, unk, index);
2452 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2453 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2455 IHTMLStyleElement *style = _get_style_iface(line, unk);
2456 BSTR media;
2457 HRESULT hres;
2459 hres = IHTMLStyleElement_get_media(style, &media);
2460 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2461 if(exmedia)
2462 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2463 else
2464 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2466 IHTMLStyleElement_Release(style);
2467 SysFreeString(media);
2470 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2471 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2473 IHTMLStyleElement *style = _get_style_iface(line, unk);
2474 BSTR str;
2475 HRESULT hres;
2477 str = a2bstr(media);
2478 hres = IHTMLStyleElement_put_media(style, str);
2479 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2480 IHTMLStyleElement_Release(style);
2481 SysFreeString(str);
2483 _test_style_media(line, unk, media);
2486 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2487 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2489 IHTMLStyleElement *style = _get_style_iface(line, unk);
2490 BSTR type;
2491 HRESULT hres;
2493 hres = IHTMLStyleElement_get_type(style, &type);
2494 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2495 if(extype)
2496 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2497 else
2498 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2500 IHTMLStyleElement_Release(style);
2501 SysFreeString(type);
2504 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2505 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2507 IHTMLStyleElement *style = _get_style_iface(line, unk);
2508 BSTR str;
2509 HRESULT hres;
2511 str = a2bstr(type);
2512 hres = IHTMLStyleElement_put_type(style, str);
2513 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2514 IHTMLStyleElement_Release(style);
2515 SysFreeString(str);
2517 _test_style_type(line, unk, type);
2520 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2521 static void _test_elem_filters(unsigned line, IUnknown *unk)
2523 IHTMLElement *elem = _get_elem_iface(line, unk);
2524 HRESULT hres;
2525 IHTMLFiltersCollection *filters;
2527 hres = IHTMLElement_get_filters(elem, &filters);
2528 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2529 "get_filters failed: %08x\n", hres);
2530 if(hres == S_OK)
2532 LONG len;
2533 IDispatchEx *dispex;
2535 hres = IHTMLFiltersCollection_get_length(filters, &len);
2536 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2537 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2539 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2540 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2541 "Could not get IDispatchEx interface: %08x\n", hres);
2542 if(SUCCEEDED(hres)) {
2543 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2544 IDispatchEx_Release(dispex);
2547 IHTMLFiltersCollection_Release(filters);
2550 IHTMLElement_Release(elem);
2553 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2554 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2556 IHTMLElement *elem = _get_elem_iface(line, unk);
2557 BSTR tmp;
2558 HRESULT hres;
2560 tmp = class ? a2bstr(class) : NULL;
2561 hres = IHTMLElement_put_className(elem, tmp);
2562 IHTMLElement_Release(elem);
2563 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2564 SysFreeString(tmp);
2566 _test_elem_class(line, unk, class);
2569 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2570 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2572 IHTMLElement *elem = _get_elem_iface(line, unk);
2573 BSTR id = (void*)0xdeadbeef;
2574 HRESULT hres;
2576 hres = IHTMLElement_get_id(elem, &id);
2577 IHTMLElement_Release(elem);
2578 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2580 if(exid)
2581 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2582 else
2583 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2585 SysFreeString(id);
2588 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2589 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2591 IHTMLElement *elem = _get_elem_iface(line, unk);
2592 BSTR tmp = a2bstr(new_id);
2593 HRESULT hres;
2595 hres = IHTMLElement_put_id(elem, tmp);
2596 IHTMLElement_Release(elem);
2597 SysFreeString(tmp);
2598 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2600 _test_elem_id(line, unk, new_id);
2603 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2604 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2606 IHTMLElement *elem = _get_elem_iface(line, unk);
2607 BSTR title;
2608 HRESULT hres;
2610 hres = IHTMLElement_get_title(elem, &title);
2611 IHTMLElement_Release(elem);
2612 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2613 if(extitle)
2614 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2615 else
2616 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2618 SysFreeString(title);
2621 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2622 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2624 IHTMLElement *elem = _get_elem_iface(line, unk);
2625 BSTR tmp;
2626 HRESULT hres;
2628 tmp = a2bstr(title);
2629 hres = IHTMLElement_put_title(elem, tmp);
2630 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2632 IHTMLElement_Release(elem);
2633 SysFreeString(tmp);
2636 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2637 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2639 IHTMLDOMNode *node = _get_node_iface(line, unk);
2640 VARIANT var;
2641 HRESULT hres;
2643 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2644 IHTMLDOMNode_Release(node);
2645 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2647 if(exval) {
2648 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2649 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2650 }else {
2651 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2654 VariantClear(&var);
2657 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2658 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2660 IHTMLDOMNode *node = _get_node_iface(line, unk);
2661 VARIANT var;
2662 HRESULT hres;
2664 V_VT(&var) = VT_BSTR;
2665 V_BSTR(&var) = a2bstr(val);
2667 hres = IHTMLDOMNode_put_nodeValue(node, var);
2668 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2669 IHTMLDOMNode_Release(node);
2670 VariantClear(&var);
2673 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2674 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2676 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2677 LONG l;
2678 HRESULT hres;
2680 hres = IHTMLElement2_get_clientWidth(elem, &l);
2681 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2682 hres = IHTMLElement2_get_clientHeight(elem, &l);
2683 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2685 IHTMLElement2_Release(elem);
2688 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2689 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2691 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2692 LONG l;
2693 HRESULT hres;
2695 hres = IHTMLElement2_get_clientLeft(elem, &l);
2696 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2697 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2699 hres = IHTMLElement2_get_clientTop(elem, &l);
2700 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2701 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2703 IHTMLElement2_Release(elem);
2706 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2707 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2709 IHTMLFormElement *form = _get_form_iface(line, unk);
2710 LONG len = 0xdeadbeef;
2711 HRESULT hres;
2713 hres = IHTMLFormElement_get_length(form, &len);
2714 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2715 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2717 IHTMLFormElement_Release(form);
2720 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2721 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2723 IHTMLFormElement *form = _get_form_iface(line, unk);
2724 BSTR action = (void*)0xdeadbeef;
2725 HRESULT hres;
2727 hres = IHTMLFormElement_get_action(form, &action);
2728 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2729 if(ex)
2730 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2731 else
2732 ok_(__FILE__,line)(!action, "action=%p\n", action);
2734 SysFreeString(action);
2735 IHTMLFormElement_Release(form);
2738 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2739 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2741 IHTMLFormElement *form = _get_form_iface(line, unk);
2742 BSTR tmp = a2bstr(action);
2743 HRESULT hres;
2745 hres = IHTMLFormElement_put_action(form, tmp);
2746 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2747 SysFreeString(tmp);
2748 IHTMLFormElement_Release(form);
2750 _test_form_action(line, unk, action);
2753 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2754 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2756 IHTMLFormElement *form = _get_form_iface(line, unk);
2757 BSTR method = (void*)0xdeadbeef;
2758 HRESULT hres;
2760 hres = IHTMLFormElement_get_method(form, &method);
2761 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2762 if(ex)
2763 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2764 else
2765 ok_(__FILE__,line)(!method, "method=%p\n", method);
2767 SysFreeString(method);
2768 IHTMLFormElement_Release(form);
2771 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2772 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2774 IHTMLFormElement *form = _get_form_iface(line, unk);
2775 BSTR tmp = a2bstr(method);
2776 HRESULT hres;
2778 hres = IHTMLFormElement_put_method(form, tmp);
2779 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2780 SysFreeString(tmp);
2781 IHTMLFormElement_Release(form);
2783 if(exp_hres == S_OK)
2784 _test_form_method(line, unk, method);
2787 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2788 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2790 IHTMLFormElement *form = _get_form_iface(line, unk);
2791 BSTR name = (void*)0xdeadbeef;
2792 HRESULT hres;
2794 hres = IHTMLFormElement_get_name(form, &name);
2795 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2796 if(ex)
2797 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2798 else
2799 ok_(__FILE__,line)(!name, "name=%p\n", name);
2801 SysFreeString(name);
2802 IHTMLFormElement_Release(form);
2805 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2806 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2808 IHTMLFormElement *form = _get_form_iface(line, unk);
2809 BSTR tmp = a2bstr(name);
2810 HRESULT hres;
2812 hres = IHTMLFormElement_put_name(form, tmp);
2813 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2814 SysFreeString(tmp);
2815 IHTMLFormElement_Release(form);
2817 _test_form_name(line, unk, name);
2820 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2821 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2823 IHTMLFormElement *form = _get_form_iface(line, unk);
2824 BSTR encoding = (void*)0xdeadbeef;
2825 HRESULT hres;
2827 hres = IHTMLFormElement_get_encoding(form, &encoding);
2828 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2829 if(ex)
2830 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2831 else
2832 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2834 SysFreeString(encoding);
2835 IHTMLFormElement_Release(form);
2838 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2839 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2841 IHTMLFormElement *form = _get_form_iface(line, unk);
2842 BSTR tmp = a2bstr(encoding);
2843 HRESULT hres;
2845 hres = IHTMLFormElement_put_encoding(form, tmp);
2846 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2847 SysFreeString(tmp);
2848 IHTMLFormElement_Release(form);
2850 if(exp_hres == S_OK)
2851 _test_form_encoding(line, unk, encoding);
2854 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2855 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2857 IHTMLElement *elem = _get_elem_iface(line, unk);
2858 IHTMLDocument2 *doc;
2859 IDispatch *disp;
2860 HRESULT hres;
2862 disp = NULL;
2863 hres = IHTMLElement_get_document(elem, &disp);
2864 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2865 ok(disp != NULL, "disp == NULL\n");
2867 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2868 IDispatch_Release(disp);
2869 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2871 return doc;
2874 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2875 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2877 IHTMLDocument2 *doc;
2878 HRESULT hres;
2880 doc = NULL;
2881 hres = IHTMLWindow2_get_document(window, &doc);
2882 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2883 ok(doc != NULL, "disp == NULL\n");
2885 return doc;
2888 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2889 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
2891 IHTMLElement *elem;
2892 HRESULT hres;
2894 hres = IHTMLDocument2_get_body(doc, &elem);
2895 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2896 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
2898 return elem;
2901 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2902 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2904 IHTMLElement *elem = NULL;
2905 BSTR tmp;
2906 HRESULT hres;
2908 tmp = a2bstr(tag);
2909 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2910 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2911 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2912 SysFreeString(tmp);
2914 return elem;
2917 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2918 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2920 IHTMLDocument3 *doc3;
2921 IHTMLDOMNode *node = NULL;
2922 BSTR tmp;
2923 HRESULT hres;
2925 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2926 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2928 tmp = a2bstr(text);
2929 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2930 IHTMLDocument3_Release(doc3);
2931 SysFreeString(tmp);
2932 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2933 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2935 return node;
2938 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2939 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2941 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2942 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2943 IHTMLDOMNode *new_child = NULL;
2944 HRESULT hres;
2946 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2947 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2948 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2949 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2951 IHTMLDOMNode_Release(node);
2952 IHTMLDOMNode_Release(child);
2954 return new_child;
2957 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2958 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2960 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2961 IHTMLDOMNode *new_child = NULL;
2962 HRESULT hres;
2964 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2965 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2966 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2967 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2969 IHTMLDOMNode_Release(node);
2971 return new_child;
2974 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2975 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2977 IHTMLDOMNode *node = _get_node_iface(line, unk);
2978 IHTMLDOMNode *new_node = NULL;
2979 HRESULT hres;
2981 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2982 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2983 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2984 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2986 IHTMLDOMNode_Release(node);
2987 IHTMLDOMNode_Release(new_node);
2990 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2991 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2993 BSTR title = NULL;
2994 HRESULT hres;
2996 hres = IHTMLDocument2_get_title(doc, &title);
2997 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2998 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2999 SysFreeString(title);
3002 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3003 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3005 BSTR tmp;
3006 HRESULT hres;
3008 tmp = a2bstr(title);
3009 hres = IHTMLDocument2_put_title(doc, tmp);
3010 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3011 SysFreeString(tmp);
3014 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
3015 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
3017 HRESULT hres;
3018 DISPID dispid;
3020 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
3021 LOCALE_USER_DEFAULT, &dispid);
3022 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
3023 if(hres == S_OK)
3025 DISPPARAMS params = {NULL,NULL,0,0};
3026 DISPID dispidNamed = DISPID_PROPERTYPUT;
3027 VARIANT ret;
3028 VARIANT vDefault;
3029 VARIANTARG arg;
3031 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3032 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
3033 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
3035 params.cArgs = 1;
3036 params.cNamedArgs = 1;
3037 params.rgdispidNamedArgs = &dispidNamed;
3038 V_VT(&arg) = VT_BSTR;
3039 V_BSTR(&arg) = a2bstr("none");
3040 params.rgvarg = &arg;
3041 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3042 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3043 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
3044 VariantClear(&arg);
3046 V_VT(&arg) = VT_BSTR;
3047 V_BSTR(&arg) = a2bstr("dotted");
3048 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3049 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3050 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
3051 VariantClear(&arg);
3053 V_VT(&arg) = VT_BSTR;
3054 V_BSTR(&arg) = a2bstr("dashed");
3055 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3056 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3057 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
3058 VariantClear(&arg);
3060 V_VT(&arg) = VT_BSTR;
3061 V_BSTR(&arg) = a2bstr("solid");
3062 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3063 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3064 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
3065 VariantClear(&arg);
3067 V_VT(&arg) = VT_BSTR;
3068 V_BSTR(&arg) = a2bstr("double");
3069 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3070 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3071 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
3072 VariantClear(&arg);
3074 V_VT(&arg) = VT_BSTR;
3075 V_BSTR(&arg) = a2bstr("groove");
3076 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3077 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3078 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
3079 VariantClear(&arg);
3081 V_VT(&arg) = VT_BSTR;
3082 V_BSTR(&arg) = a2bstr("ridge");
3083 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3084 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3085 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
3086 VariantClear(&arg);
3088 V_VT(&arg) = VT_BSTR;
3089 V_BSTR(&arg) = a2bstr("inset");
3090 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3091 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3092 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
3093 VariantClear(&arg);
3095 V_VT(&arg) = VT_BSTR;
3096 V_BSTR(&arg) = a2bstr("outset");
3097 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3098 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3099 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
3100 VariantClear(&arg);
3102 V_VT(&arg) = VT_BSTR;
3103 V_BSTR(&arg) = a2bstr("invalid");
3104 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3105 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3106 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
3107 VariantClear(&arg);
3109 params.rgvarg = &vDefault;
3110 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3111 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
3112 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
3116 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3117 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
3119 BSTR text = (void*)0xdeadbeef;
3120 HRESULT hres;
3122 hres = IHTMLStyle_get_cssText(style, &text);
3123 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
3124 if(extext)
3125 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
3126 else
3127 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
3129 SysFreeString(text);
3132 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3133 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
3135 BSTR tmp;
3136 HRESULT hres;
3138 tmp = a2bstr(text);
3139 hres = IHTMLStyle_put_cssText(style, tmp);
3140 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3141 SysFreeString(tmp);
3144 static void test_elem_bounding_client_rect(IUnknown *unk)
3146 IHTMLRect *rect, *rect2;
3147 IHTMLElement2 *elem2;
3148 LONG l;
3149 HRESULT hres;
3151 elem2 = get_elem2_iface(unk);
3152 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3153 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3154 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3155 IHTMLElement2_Release(elem2);
3156 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3157 ok(rect != NULL, "rect == NULL\n");
3158 ok(rect != rect2, "rect == rect2\n");
3159 IHTMLRect_Release(rect2);
3161 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3163 l = 0xdeadbeef;
3164 hres = IHTMLRect_get_top(rect, &l);
3165 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3166 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3168 l = 0xdeadbeef;
3169 hres = IHTMLRect_get_left(rect, &l);
3170 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3171 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3173 l = 0xdeadbeef;
3174 hres = IHTMLRect_get_bottom(rect, &l);
3175 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3176 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3178 l = 0xdeadbeef;
3179 hres = IHTMLRect_get_right(rect, &l);
3180 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3181 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3183 IHTMLRect_Release(rect);
3186 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3187 const elem_type_t *elem_types, LONG len)
3189 IDispatch *disp;
3190 VARIANT name, index;
3191 DWORD i;
3192 HRESULT hres;
3194 V_VT(&index) = VT_EMPTY;
3195 V_VT(&name) = VT_BSTR;
3196 V_BSTR(&name) = a2bstr(n);
3198 hres = IHTMLElementCollection_item(col, name, index, &disp);
3199 ok(hres == S_OK, "item failed: %08x\n", hres);
3201 test_elem_collection((IUnknown*)disp, elem_types, len);
3202 IDispatch_Release(disp);
3203 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3204 if(hres != S_OK)
3205 goto cleanup;
3207 V_VT(&index) = VT_I4;
3209 for(i=0; i<len; i++) {
3210 V_I4(&index) = i;
3211 disp = (void*)0xdeadbeef;
3212 hres = IHTMLElementCollection_item(col, name, index, &disp);
3213 ok(hres == S_OK, "item failed: %08x\n", hres);
3214 ok(disp != NULL, "disp == NULL\n");
3215 if(FAILED(hres) || !disp)
3216 continue;
3218 test_elem_type((IUnknown*)disp, elem_types[i]);
3220 IDispatch_Release(disp);
3223 V_I4(&index) = len;
3224 disp = (void*)0xdeadbeef;
3225 hres = IHTMLElementCollection_item(col, name, index, &disp);
3226 ok(hres == S_OK, "item failed: %08x\n", hres);
3227 ok(disp == NULL, "disp != NULL\n");
3229 V_I4(&index) = -1;
3230 disp = (void*)0xdeadbeef;
3231 hres = IHTMLElementCollection_item(col, name, index, &disp);
3232 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3233 ok(disp == NULL, "disp != NULL\n");
3235 cleanup:
3236 SysFreeString(V_BSTR(&name));
3239 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3241 IHTMLElementCollection *col;
3242 IHTMLElement *elem;
3243 IDispatch *disp = (void*)0xdeadbeef;
3244 VARIANT name, index;
3245 HRESULT hres;
3247 hres = IHTMLDocument2_get_all(doc, &col);
3248 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3249 ok(col != NULL, "col == NULL\n");
3250 if(FAILED(hres) || !col)
3251 return NULL;
3253 V_VT(&index) = VT_EMPTY;
3254 V_VT(&name) = VT_BSTR;
3255 V_BSTR(&name) = a2bstr(id);
3257 hres = IHTMLElementCollection_item(col, name, index, &disp);
3258 IHTMLElementCollection_Release(col);
3259 SysFreeString(V_BSTR(&name));
3260 ok(hres == S_OK, "item failed: %08x\n", hres);
3261 if(!expect_success) {
3262 ok(disp == NULL, "disp != NULL\n");
3263 return NULL;
3266 ok(disp != NULL, "disp == NULL\n");
3267 if(!disp)
3268 return NULL;
3270 elem = get_elem_iface((IUnknown*)disp);
3271 IDispatch_Release(disp);
3273 return elem;
3276 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3278 IHTMLDocument3 *doc3;
3279 IHTMLElement *elem;
3280 BSTR tmp;
3281 HRESULT hres;
3283 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3284 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3286 tmp = a2bstr(id);
3287 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3288 SysFreeString(tmp);
3289 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3291 IHTMLDocument3_Release(doc3);
3293 return elem;
3296 static void test_select_elem(IHTMLSelectElement *select)
3298 IDispatch *disp, *disp2;
3299 VARIANT name, index;
3300 HRESULT hres;
3302 test_select_type(select, "select-one");
3303 test_select_length(select, 2);
3304 test_select_selidx(select, 0);
3305 test_select_put_selidx(select, 1);
3307 test_select_set_value(select, "val1");
3308 test_select_value(select, "val1");
3310 test_select_get_disabled(select, VARIANT_FALSE);
3311 test_select_set_disabled(select, VARIANT_TRUE);
3312 test_select_set_disabled(select, VARIANT_FALSE);
3314 disp = NULL;
3315 hres = IHTMLSelectElement_get_options(select, &disp);
3316 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3317 ok(disp != NULL, "options == NULL\n");
3318 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3319 IDispatch_Release(disp);
3321 V_VT(&index) = VT_EMPTY;
3322 V_VT(&name) = VT_I4;
3323 V_I4(&name) = -1;
3324 disp = (void*)0xdeadbeef;
3325 hres = IHTMLSelectElement_item(select, name, index, &disp);
3326 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3327 ok(!disp, "disp = %p\n", disp);
3329 V_I4(&name) = 2;
3330 disp = (void*)0xdeadbeef;
3331 hres = IHTMLSelectElement_item(select, name, index, &disp);
3332 ok(hres == S_OK, "item failed: %08x\n", hres);
3333 ok(!disp, "disp = %p\n", disp);
3335 V_I4(&name) = 1;
3336 hres = IHTMLSelectElement_item(select, name, index, NULL);
3337 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3339 disp = NULL;
3340 hres = IHTMLSelectElement_item(select, name, index, &disp);
3341 ok(hres == S_OK, "item failed: %08x\n", hres);
3342 ok(disp != NULL, "disp = NULL\n");
3343 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3345 V_VT(&index) = VT_I4;
3346 V_I4(&index) = 1;
3347 disp2 = NULL;
3348 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3349 ok(hres == S_OK, "item failed: %08x\n", hres);
3350 ok(disp2 != NULL, "disp = NULL\n");
3351 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3352 IDispatch_Release(disp2);
3353 IDispatch_Release(disp);
3356 static void test_form_item(IHTMLElement *elem)
3358 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3359 IDispatch *disp, *disp2;
3360 VARIANT name, index;
3361 HRESULT hres;
3363 V_VT(&index) = VT_EMPTY;
3364 V_VT(&name) = VT_I4;
3365 V_I4(&name) = -1;
3366 disp = (void*)0xdeadbeef;
3367 hres = IHTMLFormElement_item(form, name, index, &disp);
3368 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3369 ok(!disp, "disp = %p\n", disp);
3371 V_I4(&name) = 2;
3372 disp = (void*)0xdeadbeef;
3373 hres = IHTMLFormElement_item(form, name, index, &disp);
3374 ok(hres == S_OK, "item failed: %08x\n", hres);
3375 ok(!disp, "disp = %p\n", disp);
3377 V_I4(&name) = 1;
3378 hres = IHTMLFormElement_item(form, name, index, NULL);
3379 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3381 disp = NULL;
3382 hres = IHTMLFormElement_item(form, name, index, &disp);
3383 ok(hres == S_OK, "item failed: %08x\n", hres);
3384 ok(disp != NULL, "disp = NULL\n");
3385 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3387 V_VT(&index) = VT_I4;
3388 V_I4(&index) = 1;
3389 disp2 = NULL;
3390 hres = IHTMLFormElement_item(form, name, index, &disp2);
3391 ok(hres == S_OK, "item failed: %08x\n", hres);
3392 ok(disp2 != NULL, "disp = NULL\n");
3393 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3394 IDispatch_Release(disp2);
3395 IDispatch_Release(disp);
3398 static void test_create_option_elem(IHTMLDocument2 *doc)
3400 IHTMLOptionElement *option;
3402 option = create_option_elem(doc, "test text", "test value");
3404 test_option_put_text(option, "new text");
3405 test_option_put_value(option, "new value");
3406 test_option_put_selected(option, VARIANT_TRUE);
3407 test_option_put_selected(option, VARIANT_FALSE);
3409 IHTMLOptionElement_Release(option);
3412 static void test_create_img_elem(IHTMLDocument2 *doc)
3414 IHTMLImgElement *img;
3416 img = create_img_elem(doc, 10, 15);
3418 if(img){
3419 test_img_put_width(img, 5);
3420 test_img_put_height(img, 20);
3422 IHTMLImgElement_Release(img);
3423 img = NULL;
3426 img = create_img_elem(doc, -1, -1);
3428 if(img){
3429 test_img_put_width(img, 5);
3430 test_img_put_height(img, 20);
3432 IHTMLImgElement_Release(img);
3436 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3438 IHTMLBodyElement *body;
3439 IHTMLTxtRange *range;
3440 IHTMLElement *elem;
3441 HRESULT hres;
3443 elem = doc_get_body(doc);
3444 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3445 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3446 IHTMLElement_Release(elem);
3448 hres = IHTMLBodyElement_createTextRange(body, &range);
3449 IHTMLBodyElement_Release(body);
3450 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3452 return range;
3455 static void test_txtrange(IHTMLDocument2 *doc)
3457 IHTMLTxtRange *body_range, *range, *range2;
3458 IHTMLSelectionObject *selection;
3459 IDispatch *disp_range;
3460 HRESULT hres;
3462 body_range = test_create_body_range(doc);
3464 test_range_text(body_range, "test abc 123\r\nit's text");
3466 hres = IHTMLTxtRange_duplicate(body_range, &range);
3467 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3469 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3470 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3471 test_range_isequal(range, range2, VARIANT_TRUE);
3473 test_range_text(range, "test abc 123\r\nit's text");
3474 test_range_text(body_range, "test abc 123\r\nit's text");
3476 test_range_collapse(range, TRUE);
3477 test_range_isequal(range, range2, VARIANT_FALSE);
3478 test_range_inrange(range, range2, VARIANT_FALSE);
3479 test_range_inrange(range2, range, VARIANT_TRUE);
3480 IHTMLTxtRange_Release(range2);
3482 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3483 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3484 test_range_move(range, characterW, 2, 2);
3485 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3487 test_range_collapse(range, FALSE);
3488 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3490 test_range_collapse(range, FALSE);
3491 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3492 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3493 test_range_move(range, characterW, 2, 2);
3494 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3495 test_range_moveend(range, characterW, -5, -5);
3496 test_range_text(range, NULL);
3497 test_range_moveend(range, characterW, 3, 3);
3498 test_range_text(range, "c 1");
3499 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3500 test_range_collapse(range, TRUE);
3501 test_range_move(range, characterW, 4, 4);
3502 test_range_moveend(range, characterW, 1, 1);
3503 test_range_text(range, " ");
3504 test_range_move(range, wordW, 1, 1);
3505 test_range_moveend(range, characterW, 2, 2);
3506 test_range_text(range, "ab");
3508 IHTMLTxtRange_Release(range);
3510 hres = IHTMLTxtRange_duplicate(body_range, &range);
3511 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3513 test_range_text(range, "test abc 123\r\nit's text");
3514 test_range_move(range, characterW, 3, 3);
3515 test_range_moveend(range, characterW, 1, 1);
3516 test_range_text(range, "t");
3517 test_range_moveend(range, characterW, 3, 3);
3518 test_range_text(range, "t ab");
3519 test_range_moveend(range, characterW, -2, -2);
3520 test_range_text(range, "t ");
3521 test_range_move(range, characterW, 6, 6);
3522 test_range_moveend(range, characterW, 3, 3);
3523 test_range_text(range, "123");
3524 test_range_moveend(range, characterW, 2, 2);
3525 test_range_text(range, "123\r\ni");
3527 IHTMLTxtRange_Release(range);
3529 hres = IHTMLTxtRange_duplicate(body_range, &range);
3530 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3532 test_range_move(range, wordW, 1, 1);
3533 test_range_moveend(range, characterW, 2, 2);
3534 test_range_text(range, "ab");
3536 test_range_move(range, characterW, -2, -2);
3537 test_range_moveend(range, characterW, 2, 2);
3538 test_range_text(range, "t ");
3540 test_range_move(range, wordW, 3, 3);
3541 test_range_move(range, wordW, -2, -2);
3542 test_range_moveend(range, characterW, 2, 2);
3543 test_range_text(range, "ab");
3545 test_range_move(range, characterW, -6, -5);
3546 test_range_moveend(range, characterW, -1, 0);
3547 test_range_moveend(range, characterW, -6, 0);
3548 test_range_move(range, characterW, 2, 2);
3549 test_range_moveend(range, characterW, 2, 2);
3550 test_range_text(range, "st");
3551 test_range_moveend(range, characterW, -6, -4);
3552 test_range_moveend(range, characterW, 2, 2);
3554 IHTMLTxtRange_Release(range);
3556 hres = IHTMLTxtRange_duplicate(body_range, &range);
3557 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3559 test_range_move(range, wordW, 2, 2);
3560 test_range_moveend(range, characterW, 2, 2);
3561 test_range_text(range, "12");
3563 test_range_move(range, characterW, 15, 14);
3564 test_range_move(range, characterW, -2, -2);
3565 test_range_moveend(range, characterW, 3, 2);
3566 test_range_text(range, "t");
3567 test_range_moveend(range, characterW, -1, -1);
3568 test_range_text(range, "t");
3569 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3570 test_range_move(range, characterW, -2, -2);
3571 test_range_moveend(range, characterW, 2, 2);
3572 test_range_text(range, "s ");
3573 test_range_move(range, characterW, 100, 7);
3574 test_range_move(range, wordW, 1, 0);
3575 test_range_move(range, characterW, -2, -2);
3576 test_range_moveend(range, characterW, 3, 2);
3577 test_range_text(range, "t");
3579 IHTMLTxtRange_Release(range);
3581 hres = IHTMLTxtRange_duplicate(body_range, &range);
3582 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3584 test_range_collapse(range, TRUE);
3585 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3586 test_range_put_text(range, "word");
3587 test_range_text(body_range, "wordabc 123\r\nit's text");
3588 test_range_text(range, NULL);
3589 test_range_moveend(range, characterW, 3, 3);
3590 test_range_text(range, "abc");
3591 test_range_movestart(range, characterW, -2, -2);
3592 test_range_text(range, "rdabc");
3593 test_range_movestart(range, characterW, 3, 3);
3594 test_range_text(range, "bc");
3595 test_range_movestart(range, characterW, 4, 4);
3596 test_range_text(range, NULL);
3597 test_range_movestart(range, characterW, -3, -3);
3598 test_range_text(range, "c 1");
3599 test_range_movestart(range, characterW, -7, -6);
3600 test_range_text(range, "wordabc 1");
3601 test_range_movestart(range, characterW, 100, 22);
3602 test_range_text(range, NULL);
3604 IHTMLTxtRange_Release(range);
3605 IHTMLTxtRange_Release(body_range);
3607 hres = IHTMLDocument2_get_selection(doc, &selection);
3608 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3610 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3611 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3612 IHTMLSelectionObject_Release(selection);
3614 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3615 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3616 IDispatch_Release(disp_range);
3618 test_range_text(range, NULL);
3619 test_range_moveend(range, characterW, 3, 3);
3620 test_range_text(range, "wor");
3621 test_range_parent(range, ET_BODY);
3622 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3623 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3624 test_range_move(range, characterW, 3, 3);
3625 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3626 test_range_moveend(range, characterW, -4, -4);
3627 test_range_put_text(range, "abc def ");
3628 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3629 test_range_move(range, wordW, 1, 1);
3630 test_range_movestart(range, characterW, -1, -1);
3631 test_range_text(range, " ");
3632 test_range_move(range, wordW, 1, 1);
3633 test_range_moveend(range, characterW, 3, 3);
3634 test_range_text(range, "def");
3635 test_range_put_text(range, "xyz");
3636 test_range_moveend(range, characterW, 1, 1);
3637 test_range_move(range, wordW, 1, 1);
3638 test_range_moveend(range, characterW, 2, 2);
3639 test_range_text(range, "ab");
3641 IHTMLTxtRange_Release(range);
3644 static void test_txtrange2(IHTMLDocument2 *doc)
3646 IHTMLTxtRange *range;
3648 range = test_create_body_range(doc);
3650 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3651 test_range_move(range, characterW, 5, 5);
3652 test_range_moveend(range, characterW, 1, 1);
3653 test_range_text(range, "2");
3654 test_range_move(range, characterW, -3, -3);
3655 test_range_moveend(range, characterW, 3, 3);
3656 test_range_text(range, "c\r\n\r\n1");
3657 test_range_collapse(range, VARIANT_FALSE);
3658 test_range_moveend(range, characterW, 4, 4);
3659 test_range_text(range, "23");
3660 test_range_moveend(range, characterW, 1, 1);
3661 test_range_text(range, "23\r\n\r\n\r\nd");
3662 test_range_moveend(range, characterW, -1, -1);
3663 test_range_text(range, "23");
3664 test_range_moveend(range, characterW, -1, -1);
3665 test_range_text(range, "23");
3666 test_range_moveend(range, characterW, -2, -2);
3667 test_range_text(range, "2");
3669 IHTMLTxtRange_Release(range);
3672 static void test_compatmode(IHTMLDocument2 *doc)
3674 IHTMLDocument5 *doc5;
3675 BSTR mode;
3676 HRESULT hres;
3678 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3679 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3680 if(FAILED(hres))
3681 return;
3683 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3684 IHTMLDocument5_Release(doc5);
3685 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3686 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3687 SysFreeString(mode);
3690 static void test_location(IHTMLDocument2 *doc)
3692 IHTMLLocation *location, *location2;
3693 IHTMLWindow2 *window;
3694 BSTR str;
3695 ULONG ref;
3696 HRESULT hres;
3698 hres = IHTMLDocument2_get_location(doc, &location);
3699 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3701 hres = IHTMLDocument2_get_location(doc, &location2);
3702 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3704 ok(location == location2, "location != location2\n");
3705 IHTMLLocation_Release(location2);
3707 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3708 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3710 hres = IHTMLWindow2_get_location(window, &location2);
3711 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3712 ok(location == location2, "location != location2\n");
3713 IHTMLLocation_Release(location2);
3715 test_ifaces((IUnknown*)location, location_iids);
3716 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3718 hres = IHTMLLocation_get_pathname(location, &str);
3719 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3720 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3721 SysFreeString(str);
3723 hres = IHTMLLocation_get_href(location, NULL);
3724 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3726 hres = IHTMLLocation_get_href(location, &str);
3727 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3728 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3729 SysFreeString(str);
3731 ref = IHTMLLocation_Release(location);
3732 ok(!ref, "location chould be destroyed here\n");
3735 static void test_plugins_col(IOmNavigator *nav)
3737 IHTMLPluginsCollection *col, *col2;
3738 ULONG ref;
3739 HRESULT hres;
3741 hres = IOmNavigator_get_plugins(nav, &col);
3742 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3744 hres = IOmNavigator_get_plugins(nav, &col2);
3745 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3746 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3747 IHTMLPluginsCollection_Release(col2);
3749 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3751 ref = IHTMLPluginsCollection_Release(col);
3752 ok(!ref, "ref=%d\n", ref);
3755 static void test_navigator(IHTMLDocument2 *doc)
3757 IHTMLWindow2 *window;
3758 IOmNavigator *navigator, *navigator2;
3759 char buf[512];
3760 DWORD size;
3761 ULONG ref;
3762 BSTR bstr;
3763 HRESULT hres;
3765 static const WCHAR v40[] = {'4','.','0'};
3767 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3768 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3770 hres = IHTMLWindow2_get_navigator(window, &navigator);
3771 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3772 ok(navigator != NULL, "navigator == NULL\n");
3773 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3775 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3776 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3777 ok(navigator != navigator2, "navigator2 != navihgator\n");
3779 IHTMLWindow2_Release(window);
3780 IOmNavigator_Release(navigator2);
3782 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3783 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3784 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3785 SysFreeString(bstr);
3787 bstr = NULL;
3788 hres = IOmNavigator_get_appName(navigator, &bstr);
3789 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3790 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3791 SysFreeString(bstr);
3793 bstr = NULL;
3794 hres = IOmNavigator_get_platform(navigator, &bstr);
3795 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3796 #ifdef _WIN64
3797 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3798 #else
3799 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3800 #endif
3801 SysFreeString(bstr);
3803 bstr = NULL;
3804 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3805 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3806 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3807 SysFreeString(bstr);
3809 hres = IOmNavigator_toString(navigator, NULL);
3810 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3812 bstr = NULL;
3813 hres = IOmNavigator_toString(navigator, &bstr);
3814 ok(hres == S_OK, "toString failed: %08x\n", hres);
3815 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3816 SysFreeString(bstr);
3818 size = sizeof(buf);
3819 hres = ObtainUserAgentString(0, buf, &size);
3820 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3822 bstr = NULL;
3823 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3824 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3825 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3826 SysFreeString(bstr);
3828 if(!strncmp(buf, "Mozilla/", 8)) {
3829 bstr = NULL;
3830 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3831 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3832 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3833 SysFreeString(bstr);
3834 }else {
3835 skip("nonstandard user agent\n");
3838 test_plugins_col(navigator);
3840 ref = IOmNavigator_Release(navigator);
3841 ok(!ref, "navigator should be destroyed here\n");
3844 static void test_screen(IHTMLWindow2 *window)
3846 IHTMLScreen *screen, *screen2;
3847 IDispatchEx *dispex;
3848 LONG l, exl;
3849 HDC hdc;
3850 HRESULT hres;
3852 screen = NULL;
3853 hres = IHTMLWindow2_get_screen(window, &screen);
3854 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3855 ok(screen != NULL, "screen == NULL\n");
3857 screen2 = NULL;
3858 hres = IHTMLWindow2_get_screen(window, &screen2);
3859 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3860 ok(screen2 != NULL, "screen == NULL\n");
3861 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3862 IHTMLScreen_Release(screen2);
3864 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3865 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3866 if(SUCCEEDED(hres)) {
3867 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3868 IDispatchEx_Release(dispex);
3871 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3873 exl = GetDeviceCaps(hdc, HORZRES);
3874 l = 0xdeadbeef;
3875 hres = IHTMLScreen_get_width(screen, &l);
3876 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3877 ok(l == exl, "width = %d, expected %d\n", l, exl);
3879 exl = GetDeviceCaps(hdc, VERTRES);
3880 l = 0xdeadbeef;
3881 hres = IHTMLScreen_get_height(screen, &l);
3882 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3883 ok(l == exl, "height = %d, expected %d\n", l, exl);
3885 exl = GetDeviceCaps(hdc, BITSPIXEL);
3886 l = 0xdeadbeef;
3887 hres = IHTMLScreen_get_colorDepth(screen, &l);
3888 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3889 ok(l == exl, "height = %d, expected %d\n", l, exl);
3891 DeleteObject(hdc);
3893 IHTMLScreen_Release(screen);
3896 static void test_current_style(IHTMLCurrentStyle *current_style)
3898 BSTR str;
3899 HRESULT hres;
3900 VARIANT v;
3902 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3903 test_ifaces((IUnknown*)current_style, cstyle_iids);
3905 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3906 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3907 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3908 SysFreeString(str);
3910 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3911 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3912 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3913 SysFreeString(str);
3915 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3916 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3917 SysFreeString(str);
3919 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3920 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3921 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3922 SysFreeString(str);
3924 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3925 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3926 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3927 SysFreeString(str);
3929 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3930 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3931 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3932 SysFreeString(str);
3934 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3935 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3936 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3937 SysFreeString(str);
3939 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3940 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3941 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3942 SysFreeString(str);
3944 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3945 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3946 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3947 SysFreeString(str);
3949 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3950 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3951 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3952 SysFreeString(str);
3954 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3955 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3956 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3957 SysFreeString(str);
3959 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3960 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3961 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3962 SysFreeString(str);
3964 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3965 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3966 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3967 SysFreeString(str);
3969 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3970 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3971 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3972 SysFreeString(str);
3974 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3975 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3976 SysFreeString(str);
3978 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3979 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3980 SysFreeString(str);
3982 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3983 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3984 SysFreeString(str);
3986 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3987 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3988 SysFreeString(str);
3990 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3991 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3992 SysFreeString(str);
3994 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3995 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3996 SysFreeString(str);
3998 hres = IHTMLCurrentStyle_get_padding(current_style, &str);
3999 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
4000 SysFreeString(str);
4002 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
4003 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4004 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4005 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
4006 VariantClear(&v);
4008 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
4009 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4010 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4011 VariantClear(&v);
4013 hres = IHTMLCurrentStyle_get_left(current_style, &v);
4014 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4015 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4016 VariantClear(&v);
4018 hres = IHTMLCurrentStyle_get_top(current_style, &v);
4019 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4020 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4021 VariantClear(&v);
4023 hres = IHTMLCurrentStyle_get_width(current_style, &v);
4024 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4025 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4026 VariantClear(&v);
4028 hres = IHTMLCurrentStyle_get_height(current_style, &v);
4029 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4030 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4031 VariantClear(&v);
4033 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
4034 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
4035 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4036 VariantClear(&v);
4038 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
4039 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4040 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4041 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
4042 VariantClear(&v);
4044 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
4045 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4046 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4047 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
4048 VariantClear(&v);
4050 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
4051 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4052 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4053 VariantClear(&v);
4055 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
4056 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4057 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4058 VariantClear(&v);
4060 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
4061 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4062 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4063 VariantClear(&v);
4065 V_BSTR(&v) = NULL;
4066 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
4067 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4068 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4069 VariantClear(&v);
4071 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
4072 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4073 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4074 VariantClear(&v);
4076 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
4077 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4078 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4079 VariantClear(&v);
4081 hres = IHTMLCurrentStyle_get_color(current_style, &v);
4082 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4083 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4084 VariantClear(&v);
4086 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
4087 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
4088 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4089 VariantClear(&v);
4091 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
4092 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4093 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4094 VariantClear(&v);
4096 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
4097 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4098 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4099 VariantClear(&v);
4101 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
4102 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4103 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4104 VariantClear(&v);
4106 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
4107 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4108 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4109 VariantClear(&v);
4111 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
4112 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
4113 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4114 VariantClear(&v);
4116 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
4117 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4118 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4119 VariantClear(&v);
4121 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
4122 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4123 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4124 VariantClear(&v);
4126 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
4127 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
4128 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4129 VariantClear(&v);
4131 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
4132 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4133 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4134 VariantClear(&v);
4136 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
4137 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
4138 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4139 VariantClear(&v);
4141 hres = IHTMLCurrentStyle_get_right(current_style, &v);
4142 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
4143 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4144 VariantClear(&v);
4146 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
4147 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
4148 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4149 VariantClear(&v);
4151 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
4152 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
4153 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4154 VariantClear(&v);
4156 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
4157 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
4158 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4159 VariantClear(&v);
4162 static void test_style2(IHTMLStyle2 *style2)
4164 VARIANT v;
4165 BSTR str;
4166 HRESULT hres;
4168 str = (void*)0xdeadbeef;
4169 hres = IHTMLStyle2_get_position(style2, &str);
4170 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4171 ok(!str, "str != NULL\n");
4173 str = a2bstr("absolute");
4174 hres = IHTMLStyle2_put_position(style2, str);
4175 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4176 SysFreeString(str);
4178 str = NULL;
4179 hres = IHTMLStyle2_get_position(style2, &str);
4180 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4181 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4182 SysFreeString(str);
4184 /* Test right */
4185 V_VT(&v) = VT_EMPTY;
4186 hres = IHTMLStyle2_get_right(style2, &v);
4187 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4188 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4189 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4190 VariantClear(&v);
4192 V_VT(&v) = VT_BSTR;
4193 V_BSTR(&v) = a2bstr("3px");
4194 hres = IHTMLStyle2_put_right(style2, v);
4195 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4196 VariantClear(&v);
4198 V_VT(&v) = VT_EMPTY;
4199 hres = IHTMLStyle2_get_right(style2, &v);
4200 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4201 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4202 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4203 VariantClear(&v);
4206 static void test_style3(IHTMLStyle3 *style3)
4208 BSTR str;
4209 HRESULT hres;
4211 str = (void*)0xdeadbeef;
4212 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4213 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4214 ok(!str, "str != NULL\n");
4216 str = a2bstr("break-word");
4217 hres = IHTMLStyle3_put_wordWrap(style3, str);
4218 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4219 SysFreeString(str);
4221 str = NULL;
4222 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4223 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4224 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4225 SysFreeString(str);
4228 static void test_style4(IHTMLStyle4 *style4)
4230 HRESULT hres;
4231 VARIANT v;
4232 VARIANT vdefault;
4234 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4235 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4237 V_VT(&v) = VT_BSTR;
4238 V_BSTR(&v) = a2bstr("10px");
4239 hres = IHTMLStyle4_put_minHeight(style4, v);
4240 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4241 VariantClear(&v);
4243 hres = IHTMLStyle4_get_minHeight(style4, &v);
4244 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4245 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4246 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4247 VariantClear(&v);
4249 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4250 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4251 VariantClear(&vdefault);
4254 static void test_default_style(IHTMLStyle *style)
4256 IHTMLStyle2 *style2;
4257 IHTMLStyle3 *style3;
4258 IHTMLStyle4 *style4;
4259 VARIANT_BOOL b;
4260 VARIANT v;
4261 BSTR str;
4262 HRESULT hres;
4263 float f;
4264 BSTR sOverflowDefault;
4265 BSTR sDefault;
4266 VARIANT vDefault;
4268 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4269 test_ifaces((IUnknown*)style, style_iids);
4271 test_style_csstext(style, NULL);
4273 hres = IHTMLStyle_get_position(style, &str);
4274 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4275 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4277 V_VT(&v) = VT_NULL;
4278 hres = IHTMLStyle_get_marginRight(style, &v);
4279 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4280 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4281 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4283 V_VT(&v) = VT_NULL;
4284 hres = IHTMLStyle_get_marginLeft(style, &v);
4285 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4286 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4287 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4289 str = (void*)0xdeadbeef;
4290 hres = IHTMLStyle_get_fontFamily(style, &str);
4291 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4292 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4294 str = (void*)0xdeadbeef;
4295 hres = IHTMLStyle_get_fontWeight(style, &str);
4296 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4297 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4299 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4300 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4302 str = a2bstr("test");
4303 hres = IHTMLStyle_put_fontWeight(style, str);
4304 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4305 SysFreeString(str);
4307 str = a2bstr("bold");
4308 hres = IHTMLStyle_put_fontWeight(style, str);
4309 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4310 SysFreeString(str);
4312 str = a2bstr("bolder");
4313 hres = IHTMLStyle_put_fontWeight(style, str);
4314 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4315 SysFreeString(str);
4317 str = a2bstr("lighter");
4318 hres = IHTMLStyle_put_fontWeight(style, str);
4319 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4320 SysFreeString(str);
4322 str = a2bstr("100");
4323 hres = IHTMLStyle_put_fontWeight(style, str);
4324 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4325 SysFreeString(str);
4327 str = a2bstr("200");
4328 hres = IHTMLStyle_put_fontWeight(style, str);
4329 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4330 SysFreeString(str);
4332 str = a2bstr("300");
4333 hres = IHTMLStyle_put_fontWeight(style, str);
4334 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4335 SysFreeString(str);
4337 str = a2bstr("400");
4338 hres = IHTMLStyle_put_fontWeight(style, str);
4339 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4340 SysFreeString(str);
4342 str = a2bstr("500");
4343 hres = IHTMLStyle_put_fontWeight(style, str);
4344 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4345 SysFreeString(str);
4347 str = a2bstr("600");
4348 hres = IHTMLStyle_put_fontWeight(style, str);
4349 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4350 SysFreeString(str);
4352 str = a2bstr("700");
4353 hres = IHTMLStyle_put_fontWeight(style, str);
4354 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4355 SysFreeString(str);
4357 str = a2bstr("800");
4358 hres = IHTMLStyle_put_fontWeight(style, str);
4359 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4360 SysFreeString(str);
4362 str = a2bstr("900");
4363 hres = IHTMLStyle_put_fontWeight(style, str);
4364 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4365 SysFreeString(str);
4367 hres = IHTMLStyle_get_fontWeight(style, &str);
4368 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4369 ok(!strcmp_wa(str, "900"), "str != style900\n");
4370 SysFreeString(str);
4372 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4373 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4374 SysFreeString(sDefault);
4376 /* font Variant */
4377 hres = IHTMLStyle_get_fontVariant(style, NULL);
4378 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4380 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4381 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4383 str = a2bstr("test");
4384 hres = IHTMLStyle_put_fontVariant(style, str);
4385 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4386 SysFreeString(str);
4388 str = a2bstr("small-caps");
4389 hres = IHTMLStyle_put_fontVariant(style, str);
4390 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4391 SysFreeString(str);
4393 str = a2bstr("normal");
4394 hres = IHTMLStyle_put_fontVariant(style, str);
4395 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4396 SysFreeString(str);
4398 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4399 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4400 SysFreeString(sDefault);
4402 str = (void*)0xdeadbeef;
4403 hres = IHTMLStyle_get_display(style, &str);
4404 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4405 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4407 str = (void*)0xdeadbeef;
4408 hres = IHTMLStyle_get_visibility(style, &str);
4409 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4410 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4412 V_VT(&v) = VT_NULL;
4413 hres = IHTMLStyle_get_fontSize(style, &v);
4414 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4415 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4416 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4418 V_VT(&v) = VT_NULL;
4419 hres = IHTMLStyle_get_color(style, &v);
4420 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4421 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4422 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4424 b = 0xfefe;
4425 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4426 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4427 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4429 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4430 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4431 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4433 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4434 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4435 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4437 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4438 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4440 b = 0xfefe;
4441 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4442 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4443 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4445 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4446 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4447 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4449 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4450 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4451 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4453 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4454 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4456 b = 0xfefe;
4457 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4458 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4459 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4461 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4462 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4463 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4465 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4466 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4467 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4469 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4470 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4472 b = 0xfefe;
4473 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4474 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4475 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4477 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4478 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4479 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4481 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4482 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4483 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4485 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4486 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4488 b = 0xfefe;
4489 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4490 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4491 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4493 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4494 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4495 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4497 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4498 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4499 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4501 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4502 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4504 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4505 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4507 str = a2bstr("invalid");
4508 hres = IHTMLStyle_put_textDecoration(style, str);
4509 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4510 SysFreeString(str);
4512 str = a2bstr("none");
4513 hres = IHTMLStyle_put_textDecoration(style, str);
4514 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4515 SysFreeString(str);
4517 str = a2bstr("underline");
4518 hres = IHTMLStyle_put_textDecoration(style, str);
4519 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4520 SysFreeString(str);
4522 str = a2bstr("overline");
4523 hres = IHTMLStyle_put_textDecoration(style, str);
4524 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4525 SysFreeString(str);
4527 str = a2bstr("line-through");
4528 hres = IHTMLStyle_put_textDecoration(style, str);
4529 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4530 SysFreeString(str);
4532 str = a2bstr("blink");
4533 hres = IHTMLStyle_put_textDecoration(style, str);
4534 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4535 SysFreeString(str);
4537 hres = IHTMLStyle_get_textDecoration(style, &str);
4538 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4539 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4540 SysFreeString(str);
4542 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4543 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4544 SysFreeString(sDefault);
4546 hres = IHTMLStyle_get_posWidth(style, NULL);
4547 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4549 hres = IHTMLStyle_get_posWidth(style, &f);
4550 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4551 ok(f == 0.0f, "f = %f\n", f);
4553 V_VT(&v) = VT_EMPTY;
4554 hres = IHTMLStyle_get_width(style, &v);
4555 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4556 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4557 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4559 hres = IHTMLStyle_put_posWidth(style, 2.2);
4560 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4562 hres = IHTMLStyle_get_posWidth(style, &f);
4563 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4564 ok(f == 2.0f ||
4565 f == 2.2f, /* IE8 */
4566 "f = %f\n", f);
4568 V_VT(&v) = VT_BSTR;
4569 V_BSTR(&v) = a2bstr("auto");
4570 hres = IHTMLStyle_put_width(style, v);
4571 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4572 VariantClear(&v);
4574 V_VT(&v) = VT_EMPTY;
4575 hres = IHTMLStyle_get_width(style, &v);
4576 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4577 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4578 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4579 VariantClear(&v);
4581 V_VT(&v) = VT_I4;
4582 V_I4(&v) = 100;
4583 hres = IHTMLStyle_put_width(style, v);
4584 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4586 V_VT(&v) = VT_EMPTY;
4587 hres = IHTMLStyle_get_width(style, &v);
4588 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4589 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4590 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4591 VariantClear(&v);
4593 /* margin tests */
4594 str = (void*)0xdeadbeef;
4595 hres = IHTMLStyle_get_margin(style, &str);
4596 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4597 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4599 str = a2bstr("1");
4600 hres = IHTMLStyle_put_margin(style, str);
4601 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4602 SysFreeString(str);
4604 hres = IHTMLStyle_get_margin(style, &str);
4605 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4606 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4607 SysFreeString(str);
4609 hres = IHTMLStyle_put_margin(style, NULL);
4610 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4612 str = (void*)0xdeadbeef;
4613 hres = IHTMLStyle_get_marginTop(style, &v);
4614 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4615 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4616 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4618 V_VT(&v) = VT_BSTR;
4619 V_BSTR(&v) = a2bstr("6px");
4620 hres = IHTMLStyle_put_marginTop(style, v);
4621 SysFreeString(V_BSTR(&v));
4622 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4624 str = (void*)0xdeadbeef;
4625 hres = IHTMLStyle_get_marginTop(style, &v);
4626 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4627 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4628 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4629 VariantClear(&v);
4631 str = NULL;
4632 hres = IHTMLStyle_get_border(style, &str);
4633 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4634 ok(!str || !*str, "str is not empty\n");
4635 SysFreeString(str);
4637 str = a2bstr("1px");
4638 hres = IHTMLStyle_put_border(style, str);
4639 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4640 SysFreeString(str);
4642 V_VT(&v) = VT_EMPTY;
4643 hres = IHTMLStyle_get_left(style, &v);
4644 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4645 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4646 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4647 VariantClear(&v);
4649 /* Test posLeft */
4650 hres = IHTMLStyle_get_posLeft(style, NULL);
4651 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4653 f = 1.0f;
4654 hres = IHTMLStyle_get_posLeft(style, &f);
4655 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4656 ok(f == 0.0, "expected 0.0 got %f\n", f);
4658 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4659 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4661 hres = IHTMLStyle_get_posLeft(style, &f);
4662 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4663 ok(f == 4.0 ||
4664 f == 4.9f, /* IE8 */
4665 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4667 /* Ensure left is updated correctly. */
4668 V_VT(&v) = VT_EMPTY;
4669 hres = IHTMLStyle_get_left(style, &v);
4670 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4671 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4672 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4673 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4674 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4675 VariantClear(&v);
4677 /* Test left */
4678 V_VT(&v) = VT_BSTR;
4679 V_BSTR(&v) = a2bstr("3px");
4680 hres = IHTMLStyle_put_left(style, v);
4681 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4682 VariantClear(&v);
4684 hres = IHTMLStyle_get_posLeft(style, &f);
4685 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4686 ok(f == 3.0, "expected 3.0 got %f\n", f);
4688 V_VT(&v) = VT_EMPTY;
4689 hres = IHTMLStyle_get_left(style, &v);
4690 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4691 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4692 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4693 VariantClear(&v);
4695 V_VT(&v) = VT_NULL;
4696 hres = IHTMLStyle_put_left(style, v);
4697 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4699 V_VT(&v) = VT_EMPTY;
4700 hres = IHTMLStyle_get_left(style, &v);
4701 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4702 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4703 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4704 VariantClear(&v);
4706 V_VT(&v) = VT_EMPTY;
4707 hres = IHTMLStyle_get_top(style, &v);
4708 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4709 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4710 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4711 VariantClear(&v);
4713 /* Test posTop */
4714 hres = IHTMLStyle_get_posTop(style, NULL);
4715 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4717 f = 1.0f;
4718 hres = IHTMLStyle_get_posTop(style, &f);
4719 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4720 ok(f == 0.0, "expected 0.0 got %f\n", f);
4722 hres = IHTMLStyle_put_posTop(style, 4.9f);
4723 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4725 hres = IHTMLStyle_get_posTop(style, &f);
4726 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4727 ok(f == 4.0 ||
4728 f == 4.9f, /* IE8 */
4729 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4731 V_VT(&v) = VT_BSTR;
4732 V_BSTR(&v) = a2bstr("3px");
4733 hres = IHTMLStyle_put_top(style, v);
4734 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4735 VariantClear(&v);
4737 V_VT(&v) = VT_EMPTY;
4738 hres = IHTMLStyle_get_top(style, &v);
4739 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4740 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4741 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4742 VariantClear(&v);
4744 hres = IHTMLStyle_get_posTop(style, &f);
4745 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4746 ok(f == 3.0, "expected 3.0 got %f\n", f);
4748 V_VT(&v) = VT_NULL;
4749 hres = IHTMLStyle_put_top(style, v);
4750 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4752 V_VT(&v) = VT_EMPTY;
4753 hres = IHTMLStyle_get_top(style, &v);
4754 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4755 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4756 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4757 VariantClear(&v);
4759 /* Test posHeight */
4760 hres = IHTMLStyle_get_posHeight(style, NULL);
4761 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4763 V_VT(&v) = VT_EMPTY;
4764 hres = IHTMLStyle_get_height(style, &v);
4765 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4766 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4767 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4768 VariantClear(&v);
4770 f = 1.0f;
4771 hres = IHTMLStyle_get_posHeight(style, &f);
4772 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4773 ok(f == 0.0, "expected 0.0 got %f\n", f);
4775 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4776 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4778 hres = IHTMLStyle_get_posHeight(style, &f);
4779 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4780 ok(f == 4.0 ||
4781 f == 4.9f, /* IE8 */
4782 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4784 V_VT(&v) = VT_BSTR;
4785 V_BSTR(&v) = a2bstr("64px");
4786 hres = IHTMLStyle_put_height(style, v);
4787 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4788 VariantClear(&v);
4790 V_VT(&v) = VT_EMPTY;
4791 hres = IHTMLStyle_get_height(style, &v);
4792 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4793 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4794 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4795 VariantClear(&v);
4797 hres = IHTMLStyle_get_posHeight(style, &f);
4798 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4799 ok(f == 64.0, "expected 64.0 got %f\n", f);
4801 str = (void*)0xdeadbeef;
4802 hres = IHTMLStyle_get_cursor(style, &str);
4803 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4804 ok(!str, "get_cursor != NULL\n");
4805 SysFreeString(str);
4807 str = a2bstr("default");
4808 hres = IHTMLStyle_put_cursor(style, str);
4809 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4810 SysFreeString(str);
4812 str = NULL;
4813 hres = IHTMLStyle_get_cursor(style, &str);
4814 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4815 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4816 SysFreeString(str);
4818 V_VT(&v) = VT_EMPTY;
4819 hres = IHTMLStyle_get_verticalAlign(style, &v);
4820 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4821 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4822 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4823 VariantClear(&v);
4825 V_VT(&v) = VT_BSTR;
4826 V_BSTR(&v) = a2bstr("middle");
4827 hres = IHTMLStyle_put_verticalAlign(style, v);
4828 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4829 VariantClear(&v);
4831 V_VT(&v) = VT_EMPTY;
4832 hres = IHTMLStyle_get_verticalAlign(style, &v);
4833 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4834 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4835 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4836 VariantClear(&v);
4838 str = (void*)0xdeadbeef;
4839 hres = IHTMLStyle_get_textAlign(style, &str);
4840 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4841 ok(!str, "textAlign != NULL\n");
4843 str = a2bstr("center");
4844 hres = IHTMLStyle_put_textAlign(style, str);
4845 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4846 SysFreeString(str);
4848 str = NULL;
4849 hres = IHTMLStyle_get_textAlign(style, &str);
4850 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4851 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4852 SysFreeString(str);
4854 str = (void*)0xdeadbeef;
4855 hres = IHTMLStyle_get_filter(style, &str);
4856 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4857 ok(!str, "filter != NULL\n");
4859 str = a2bstr("alpha(opacity=100)");
4860 hres = IHTMLStyle_put_filter(style, str);
4861 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4862 SysFreeString(str);
4864 V_VT(&v) = VT_EMPTY;
4865 hres = IHTMLStyle_get_zIndex(style, &v);
4866 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4867 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4868 ok(!V_I4(&v), "V_I4(v) != 0\n");
4869 VariantClear(&v);
4871 V_VT(&v) = VT_BSTR;
4872 V_BSTR(&v) = a2bstr("1");
4873 hres = IHTMLStyle_put_zIndex(style, v);
4874 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4875 VariantClear(&v);
4877 V_VT(&v) = VT_EMPTY;
4878 hres = IHTMLStyle_get_zIndex(style, &v);
4879 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4880 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4881 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4882 VariantClear(&v);
4884 /* fontStyle */
4885 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4886 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4888 str = a2bstr("test");
4889 hres = IHTMLStyle_put_fontStyle(style, str);
4890 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4891 SysFreeString(str);
4893 str = a2bstr("italic");
4894 hres = IHTMLStyle_put_fontStyle(style, str);
4895 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4896 SysFreeString(str);
4898 str = a2bstr("oblique");
4899 hres = IHTMLStyle_put_fontStyle(style, str);
4900 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4901 SysFreeString(str);
4903 str = a2bstr("normal");
4904 hres = IHTMLStyle_put_fontStyle(style, str);
4905 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4906 SysFreeString(str);
4908 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4909 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4910 SysFreeString(sDefault);
4912 /* overflow */
4913 hres = IHTMLStyle_get_overflow(style, NULL);
4914 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4916 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4917 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4919 str = a2bstr("test");
4920 hres = IHTMLStyle_put_overflow(style, str);
4921 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4922 SysFreeString(str);
4924 str = a2bstr("visible");
4925 hres = IHTMLStyle_put_overflow(style, str);
4926 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4927 SysFreeString(str);
4929 str = a2bstr("scroll");
4930 hres = IHTMLStyle_put_overflow(style, str);
4931 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4932 SysFreeString(str);
4934 str = a2bstr("hidden");
4935 hres = IHTMLStyle_put_overflow(style, str);
4936 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4937 SysFreeString(str);
4939 str = a2bstr("auto");
4940 hres = IHTMLStyle_put_overflow(style, str);
4941 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4942 SysFreeString(str);
4944 hres = IHTMLStyle_get_overflow(style, &str);
4945 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4946 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4947 SysFreeString(str);
4949 str = a2bstr("");
4950 hres = IHTMLStyle_put_overflow(style, str);
4951 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4952 SysFreeString(str);
4954 hres = IHTMLStyle_get_overflow(style, &str);
4955 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4956 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4957 SysFreeString(str);
4959 /* restore overflow default */
4960 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4961 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4962 SysFreeString(sOverflowDefault);
4964 /* Attribute Tests*/
4965 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4966 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4968 str = a2bstr("position");
4969 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4970 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4972 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4973 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4974 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4975 VariantClear(&v);
4977 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4978 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4980 V_VT(&v) = VT_BSTR;
4981 V_BSTR(&v) = a2bstr("absolute");
4982 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4983 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4984 VariantClear(&v);
4986 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4987 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4988 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4989 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4990 VariantClear(&v);
4992 V_VT(&v) = VT_BSTR;
4993 V_BSTR(&v) = NULL;
4994 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4995 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4996 VariantClear(&v);
4998 SysFreeString(str);
5000 str = a2bstr("borderLeftStyle");
5001 test_border_styles(style, str);
5002 SysFreeString(str);
5004 str = a2bstr("borderbottomstyle");
5005 test_border_styles(style, str);
5006 SysFreeString(str);
5008 str = a2bstr("borderrightstyle");
5009 test_border_styles(style, str);
5010 SysFreeString(str);
5012 str = a2bstr("bordertopstyle");
5013 test_border_styles(style, str);
5014 SysFreeString(str);
5016 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
5017 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5019 str = a2bstr("none dotted dashed solid");
5020 hres = IHTMLStyle_put_borderStyle(style, str);
5021 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5022 SysFreeString(str);
5024 str = a2bstr("none dotted dashed solid");
5025 hres = IHTMLStyle_get_borderStyle(style, &str);
5026 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5027 ok(!strcmp_wa(str, "none dotted dashed solid"),
5028 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
5029 SysFreeString(str);
5031 str = a2bstr("double groove ridge inset");
5032 hres = IHTMLStyle_put_borderStyle(style, str);
5033 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5034 SysFreeString(str);
5036 str = a2bstr("window-inset outset ridge inset");
5037 hres = IHTMLStyle_put_borderStyle(style, str);
5038 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5039 SysFreeString(str);
5041 str = a2bstr("window-inset");
5042 hres = IHTMLStyle_put_borderStyle(style, str);
5043 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5044 SysFreeString(str);
5046 str = a2bstr("none none none none none");
5047 hres = IHTMLStyle_put_borderStyle(style, str);
5048 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5049 SysFreeString(str);
5051 str = a2bstr("invalid none none none");
5052 hres = IHTMLStyle_put_borderStyle(style, str);
5053 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5054 SysFreeString(str);
5056 str = a2bstr("none invalid none none");
5057 hres = IHTMLStyle_put_borderStyle(style, str);
5058 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5059 SysFreeString(str);
5061 hres = IHTMLStyle_put_borderStyle(style, sDefault);
5062 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5063 SysFreeString(sDefault);
5065 /* backgoundColor */
5066 hres = IHTMLStyle_get_backgroundColor(style, &v);
5067 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5068 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5069 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5070 VariantClear(&v);
5072 /* padding */
5073 hres = IHTMLStyle_get_padding(style, &str);
5074 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5075 ok(!str, "padding = %s\n", wine_dbgstr_w(str));
5076 SysFreeString(str);
5078 str = a2bstr("1");
5079 hres = IHTMLStyle_put_padding(style, str);
5080 ok(hres == S_OK, "put_padding failed: %08x\n", hres);
5081 SysFreeString(str);
5083 hres = IHTMLStyle_get_padding(style, &str);
5084 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5085 ok(!strcmp_wa(str, "1px"), "padding = %s\n", wine_dbgstr_w(str));
5086 SysFreeString(str);
5088 /* PaddingLeft */
5089 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
5090 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5092 V_VT(&v) = VT_BSTR;
5093 V_BSTR(&v) = a2bstr("10");
5094 hres = IHTMLStyle_put_paddingLeft(style, v);
5095 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5096 VariantClear(&v);
5098 hres = IHTMLStyle_get_paddingLeft(style, &v);
5099 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5100 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5101 VariantClear(&v);
5103 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
5104 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5106 /* BackgroundRepeat */
5107 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
5108 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5110 str = a2bstr("invalid");
5111 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5112 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
5113 SysFreeString(str);
5115 str = a2bstr("repeat");
5116 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5117 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5118 SysFreeString(str);
5120 str = a2bstr("no-repeat");
5121 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5122 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5123 SysFreeString(str);
5125 str = a2bstr("repeat-x");
5126 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5127 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5128 SysFreeString(str);
5130 str = a2bstr("repeat-y");
5131 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5132 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5133 SysFreeString(str);
5135 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
5136 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5137 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
5138 SysFreeString(str);
5140 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
5141 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5142 SysFreeString(sDefault);
5144 /* BorderColor */
5145 hres = IHTMLStyle_get_borderColor(style, &sDefault);
5146 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5148 str = a2bstr("red green red blue");
5149 hres = IHTMLStyle_put_borderColor(style, str);
5150 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5151 SysFreeString(str);
5153 hres = IHTMLStyle_get_borderColor(style, &str);
5154 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5155 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
5156 SysFreeString(str);
5158 hres = IHTMLStyle_put_borderColor(style, sDefault);
5159 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5160 SysFreeString(sDefault);
5162 /* BorderRight */
5163 hres = IHTMLStyle_get_borderRight(style, &sDefault);
5164 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
5166 str = a2bstr("thick dotted red");
5167 hres = IHTMLStyle_put_borderRight(style, str);
5168 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5169 SysFreeString(str);
5171 /* IHTMLStyle_get_borderRight appears to have a bug where
5172 it returns the first letter of the color. So we check
5173 each style individually.
5175 V_BSTR(&v) = NULL;
5176 hres = IHTMLStyle_get_borderRightColor(style, &v);
5177 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
5178 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5179 VariantClear(&v);
5181 V_BSTR(&v) = NULL;
5182 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5183 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5184 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5185 VariantClear(&v);
5187 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5188 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5189 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5190 SysFreeString(str);
5192 hres = IHTMLStyle_put_borderRight(style, sDefault);
5193 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5194 SysFreeString(sDefault);
5196 /* BorderTop */
5197 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5198 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5200 str = a2bstr("thick dotted red");
5201 hres = IHTMLStyle_put_borderTop(style, str);
5202 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5203 SysFreeString(str);
5205 /* IHTMLStyle_get_borderTop appears to have a bug where
5206 it returns the first letter of the color. So we check
5207 each style individually.
5209 V_BSTR(&v) = NULL;
5210 hres = IHTMLStyle_get_borderTopColor(style, &v);
5211 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5212 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5213 VariantClear(&v);
5215 V_BSTR(&v) = NULL;
5216 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5217 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5218 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5219 VariantClear(&v);
5221 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5222 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5223 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5224 SysFreeString(str);
5226 hres = IHTMLStyle_put_borderTop(style, sDefault);
5227 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5228 SysFreeString(sDefault);
5230 /* BorderBottom */
5231 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5232 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5234 str = a2bstr("thick dotted red");
5235 hres = IHTMLStyle_put_borderBottom(style, str);
5236 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5237 SysFreeString(str);
5239 /* IHTMLStyle_get_borderBottom appears to have a bug where
5240 it returns the first letter of the color. So we check
5241 each style individually.
5243 V_BSTR(&v) = NULL;
5244 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5245 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5246 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5247 VariantClear(&v);
5249 V_BSTR(&v) = NULL;
5250 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5251 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5252 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5253 VariantClear(&v);
5255 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5256 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5257 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5258 SysFreeString(str);
5260 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5261 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5262 SysFreeString(sDefault);
5264 /* BorderLeft */
5265 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5266 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5268 str = a2bstr("thick dotted red");
5269 hres = IHTMLStyle_put_borderLeft(style, str);
5270 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5271 SysFreeString(str);
5273 /* IHTMLStyle_get_borderLeft appears to have a bug where
5274 it returns the first letter of the color. So we check
5275 each style individually.
5277 V_BSTR(&v) = NULL;
5278 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5279 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5280 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5281 VariantClear(&v);
5283 V_BSTR(&v) = NULL;
5284 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5285 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5286 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5287 VariantClear(&v);
5289 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5290 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5291 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5292 SysFreeString(str);
5294 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5295 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5296 SysFreeString(sDefault);
5298 /* backgroundPositionX */
5299 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
5300 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5302 V_VT(&v) = VT_BSTR;
5303 V_BSTR(&v) = a2bstr("10px");
5304 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5305 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5306 VariantClear(&v);
5308 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5309 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5310 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5311 VariantClear(&v);
5313 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
5314 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5315 VariantClear(&vDefault);
5317 /* backgroundPositionY */
5318 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
5319 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5321 V_VT(&v) = VT_BSTR;
5322 V_BSTR(&v) = a2bstr("10px");
5323 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5324 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5325 VariantClear(&v);
5327 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5328 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5329 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5330 VariantClear(&v);
5332 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
5333 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5334 VariantClear(&vDefault);
5336 /* borderTopWidth */
5337 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5338 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5340 V_VT(&v) = VT_BSTR;
5341 V_BSTR(&v) = a2bstr("10px");
5342 hres = IHTMLStyle_put_borderTopWidth(style, v);
5343 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5344 VariantClear(&v);
5346 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5347 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5348 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5349 VariantClear(&v);
5351 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5352 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5353 VariantClear(&vDefault);
5355 /* borderRightWidth */
5356 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5357 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5359 V_VT(&v) = VT_BSTR;
5360 V_BSTR(&v) = a2bstr("10");
5361 hres = IHTMLStyle_put_borderRightWidth(style, v);
5362 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5363 VariantClear(&v);
5365 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5366 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5367 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5368 VariantClear(&v);
5370 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5371 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5372 VariantClear(&vDefault);
5374 /* borderBottomWidth */
5375 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5376 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5378 V_VT(&v) = VT_BSTR;
5379 V_BSTR(&v) = a2bstr("10");
5380 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5381 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5382 VariantClear(&v);
5384 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5385 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5386 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5387 VariantClear(&v);
5389 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5390 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5391 VariantClear(&vDefault);
5393 /* borderLeftWidth */
5394 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5395 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5397 V_VT(&v) = VT_BSTR;
5398 V_BSTR(&v) = a2bstr("10");
5399 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5400 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5401 VariantClear(&v);
5403 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5404 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5405 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5406 VariantClear(&v);
5408 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5409 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5410 VariantClear(&vDefault);
5412 /* wordSpacing */
5413 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5414 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5416 V_VT(&v) = VT_BSTR;
5417 V_BSTR(&v) = a2bstr("10");
5418 hres = IHTMLStyle_put_wordSpacing(style, v);
5419 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5420 VariantClear(&v);
5422 hres = IHTMLStyle_get_wordSpacing(style, &v);
5423 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5424 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5425 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5426 VariantClear(&v);
5428 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5429 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5430 VariantClear(&vDefault);
5432 /* letterSpacing */
5433 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5434 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5436 V_VT(&v) = VT_BSTR;
5437 V_BSTR(&v) = a2bstr("11");
5438 hres = IHTMLStyle_put_letterSpacing(style, v);
5439 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5440 VariantClear(&v);
5442 hres = IHTMLStyle_get_letterSpacing(style, &v);
5443 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5444 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5445 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5446 VariantClear(&v);
5448 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5449 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5450 VariantClear(&vDefault);
5452 /* borderTopColor */
5453 hres = IHTMLStyle_get_borderTopColor(style, &vDefault);
5454 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5456 V_VT(&v) = VT_BSTR;
5457 V_BSTR(&v) = a2bstr("red");
5458 hres = IHTMLStyle_put_borderTopColor(style, v);
5459 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5460 VariantClear(&v);
5462 hres = IHTMLStyle_get_borderTopColor(style, &v);
5463 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5464 ok(!strcmp_wa(V_BSTR(&v), "red"), "expecte red = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5465 VariantClear(&v);
5467 hres = IHTMLStyle_put_borderTopColor(style, vDefault);
5468 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5470 /* borderRightColor */
5471 hres = IHTMLStyle_get_borderRightColor(style, &vDefault);
5472 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5474 V_VT(&v) = VT_BSTR;
5475 V_BSTR(&v) = a2bstr("blue");
5476 hres = IHTMLStyle_put_borderRightColor(style, v);
5477 ok(hres == S_OK, "put_borderRightColor: %08x\n", hres);
5478 VariantClear(&v);
5480 hres = IHTMLStyle_get_borderRightColor(style, &v);
5481 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5482 ok(!strcmp_wa(V_BSTR(&v), "blue"), "expected blue = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5483 VariantClear(&v);
5485 hres = IHTMLStyle_put_borderRightColor(style, vDefault);
5486 ok(hres == S_OK, "putborderRightColorr: %08x\n", hres);
5488 /* borderBottomColor */
5489 hres = IHTMLStyle_get_borderBottomColor(style, &vDefault);
5490 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5492 V_VT(&v) = VT_BSTR;
5493 V_BSTR(&v) = a2bstr("cyan");
5494 hres = IHTMLStyle_put_borderBottomColor(style, v);
5495 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5496 VariantClear(&v);
5498 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5499 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5500 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5501 VariantClear(&v);
5503 hres = IHTMLStyle_put_borderBottomColor(style, vDefault);
5504 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5506 /* borderLeftColor */
5507 hres = IHTMLStyle_get_borderLeftColor(style, &vDefault);
5508 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5510 V_VT(&v) = VT_BSTR;
5511 V_BSTR(&v) = a2bstr("cyan");
5512 hres = IHTMLStyle_put_borderLeftColor(style, v);
5513 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5514 VariantClear(&v);
5516 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5517 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5518 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5519 VariantClear(&v);
5521 hres = IHTMLStyle_put_borderLeftColor(style, vDefault);
5522 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5524 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5525 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5526 if(SUCCEEDED(hres)) {
5527 test_style2(style2);
5528 IHTMLStyle2_Release(style2);
5531 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5532 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5533 if(SUCCEEDED(hres)) {
5534 test_style3(style3);
5535 IHTMLStyle3_Release(style3);
5538 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5539 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5540 if(SUCCEEDED(hres)) {
5541 test_style4(style4);
5542 IHTMLStyle4_Release(style4);
5546 static void test_set_csstext(IHTMLStyle *style)
5548 VARIANT v;
5549 HRESULT hres;
5551 test_style_set_csstext(style, "background-color: black;");
5553 hres = IHTMLStyle_get_backgroundColor(style, &v);
5554 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5555 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5556 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5557 VariantClear(&v);
5560 static void test_default_selection(IHTMLDocument2 *doc)
5562 IHTMLSelectionObject *selection;
5563 IHTMLTxtRange *range;
5564 IDispatch *disp;
5565 BSTR str;
5566 HRESULT hres;
5568 hres = IHTMLDocument2_get_selection(doc, &selection);
5569 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5571 hres = IHTMLSelectionObject_get_type(selection, &str);
5572 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5573 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5574 SysFreeString(str);
5576 hres = IHTMLSelectionObject_createRange(selection, &disp);
5577 IHTMLSelectionObject_Release(selection);
5578 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5580 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5581 IDispatch_Release(disp);
5582 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5584 test_range_text(range, NULL);
5585 IHTMLTxtRange_Release(range);
5588 static void test_doc_elem(IHTMLDocument2 *doc)
5590 IHTMLDocument2 *doc_node, *owner_doc;
5591 IHTMLElement *elem;
5592 IHTMLDocument3 *doc3;
5593 HRESULT hres;
5595 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5596 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5598 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5599 IHTMLDocument3_Release(doc3);
5600 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5602 test_node_name((IUnknown*)elem, "HTML");
5603 test_elem_tag((IUnknown*)elem, "HTML");
5605 doc_node = get_doc_node(doc);
5606 owner_doc = get_owner_doc((IUnknown*)elem);
5607 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5608 IHTMLDocument2_Release(owner_doc);
5610 owner_doc = get_owner_doc((IUnknown*)doc_node);
5611 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5612 IHTMLDocument2_Release(doc_node);
5614 test_elem_client_rect((IUnknown*)elem);
5616 IHTMLElement_Release(elem);
5619 static void test_default_body(IHTMLBodyElement *body)
5621 LONG l;
5622 BSTR bstr;
5623 HRESULT hres;
5624 VARIANT v;
5626 bstr = (void*)0xdeadbeef;
5627 hres = IHTMLBodyElement_get_background(body, &bstr);
5628 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5629 ok(bstr == NULL, "bstr != NULL\n");
5631 l = elem_get_scroll_height((IUnknown*)body);
5632 ok(l != -1, "scrollHeight == -1\n");
5633 l = elem_get_scroll_width((IUnknown*)body);
5634 ok(l != -1, "scrollWidth == -1\n");
5635 l = elem_get_scroll_top((IUnknown*)body);
5636 ok(!l, "scrollTop = %d\n", l);
5637 elem_get_scroll_left((IUnknown*)body);
5639 /* get_text tests */
5640 hres = IHTMLBodyElement_get_text(body, &v);
5641 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5642 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5643 ok(bstr == NULL, "bstr != NULL\n");
5645 /* get_text - Invalid Text */
5646 V_VT(&v) = VT_BSTR;
5647 V_BSTR(&v) = a2bstr("Invalid");
5648 hres = IHTMLBodyElement_put_text(body, v);
5649 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5650 VariantClear(&v);
5652 V_VT(&v) = VT_NULL;
5653 hres = IHTMLBodyElement_get_text(body, &v);
5654 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5655 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5656 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5657 VariantClear(&v);
5659 /* get_text - Valid Text */
5660 V_VT(&v) = VT_BSTR;
5661 V_BSTR(&v) = a2bstr("#FF0000");
5662 hres = IHTMLBodyElement_put_text(body, v);
5663 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5664 VariantClear(&v);
5666 V_VT(&v) = VT_NULL;
5667 hres = IHTMLBodyElement_get_text(body, &v);
5668 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5669 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5670 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5671 VariantClear(&v);
5674 static void test_body_funs(IHTMLBodyElement *body)
5676 VARIANT vbg, vDefaultbg;
5677 HRESULT hres;
5679 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5680 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5681 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5682 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5684 V_VT(&vbg) = VT_BSTR;
5685 V_BSTR(&vbg) = a2bstr("red");
5686 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5687 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5688 VariantClear(&vbg);
5690 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5691 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5692 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5693 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5694 VariantClear(&vbg);
5696 /* Restore Originial */
5697 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5698 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5699 VariantClear(&vDefaultbg);
5702 static void test_window(IHTMLDocument2 *doc)
5704 IHTMLWindow2 *window, *window2, *self;
5705 IHTMLDocument2 *doc2 = NULL;
5706 IDispatch *disp;
5707 IUnknown *unk;
5708 BSTR str;
5709 HRESULT hres;
5711 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5712 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5713 test_ifaces((IUnknown*)window, window_iids);
5714 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5716 hres = IHTMLWindow2_get_document(window, &doc2);
5717 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5718 ok(doc2 != NULL, "doc2 == NULL\n");
5720 test_ifaces((IUnknown*)doc2, doc_node_iids);
5721 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5723 test_ifaces((IUnknown*)doc, doc_obj_iids);
5724 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5726 unk = (void*)0xdeadbeef;
5727 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5728 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5729 ok(!unk, "unk = %p\n", unk);
5731 IHTMLDocument_Release(doc2);
5733 hres = IHTMLWindow2_get_window(window, &window2);
5734 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5735 ok(window2 != NULL, "window2 == NULL\n");
5737 hres = IHTMLWindow2_get_self(window, &self);
5738 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5739 ok(window2 != NULL, "self == NULL\n");
5741 ok(self == window2, "self != window2\n");
5743 IHTMLWindow2_Release(window2);
5744 IHTMLWindow2_Release(self);
5746 disp = NULL;
5747 hres = IHTMLDocument2_get_Script(doc, &disp);
5748 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5749 ok(disp == (void*)window, "disp != window\n");
5750 IDispatch_Release(disp);
5752 hres = IHTMLWindow2_toString(window, NULL);
5753 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5755 str = NULL;
5756 hres = IHTMLWindow2_toString(window, &str);
5757 ok(hres == S_OK, "toString failed: %08x\n", hres);
5758 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5759 SysFreeString(str);
5761 test_window_name(window, NULL);
5762 set_window_name(window, "test");
5763 test_window_length(window, 0);
5764 test_screen(window);
5766 IHTMLWindow2_Release(window);
5769 static void test_defaults(IHTMLDocument2 *doc)
5771 IHTMLStyleSheetsCollection *stylesheetcol;
5772 IHTMLCurrentStyle *cstyle;
5773 IHTMLBodyElement *body;
5774 IHTMLElement2 *elem2;
5775 IHTMLElement *elem;
5776 IHTMLStyle *style;
5777 LONG l;
5778 HRESULT hres;
5779 IHTMLElementCollection *collection;
5781 elem = doc_get_body(doc);
5783 hres = IHTMLDocument2_get_images(doc, NULL);
5784 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5786 hres = IHTMLDocument2_get_images(doc, &collection);
5787 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5788 if(hres == S_OK)
5790 test_elem_collection((IUnknown*)collection, NULL, 0);
5791 IHTMLElementCollection_Release(collection);
5794 hres = IHTMLDocument2_get_applets(doc, NULL);
5795 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5797 hres = IHTMLDocument2_get_applets(doc, &collection);
5798 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5799 if(hres == S_OK)
5801 test_elem_collection((IUnknown*)collection, NULL, 0);
5802 IHTMLElementCollection_Release(collection);
5805 hres = IHTMLDocument2_get_links(doc, NULL);
5806 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5808 hres = IHTMLDocument2_get_links(doc, &collection);
5809 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5810 if(hres == S_OK)
5812 test_elem_collection((IUnknown*)collection, NULL, 0);
5813 IHTMLElementCollection_Release(collection);
5816 hres = IHTMLDocument2_get_forms(doc, NULL);
5817 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5819 hres = IHTMLDocument2_get_forms(doc, &collection);
5820 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5821 if(hres == S_OK)
5823 test_elem_collection((IUnknown*)collection, NULL, 0);
5824 IHTMLElementCollection_Release(collection);
5827 hres = IHTMLDocument2_get_anchors(doc, NULL);
5828 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5830 hres = IHTMLDocument2_get_anchors(doc, &collection);
5831 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5832 if(hres == S_OK)
5834 test_elem_collection((IUnknown*)collection, NULL, 0);
5835 IHTMLElementCollection_Release(collection);
5838 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5839 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5840 test_default_body(body);
5841 test_body_funs(body);
5842 IHTMLBodyElement_Release(body);
5844 hres = IHTMLElement_get_style(elem, &style);
5845 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5847 test_default_style(style);
5848 test_window(doc);
5849 test_compatmode(doc);
5850 test_location(doc);
5851 test_navigator(doc);
5853 elem2 = get_elem2_iface((IUnknown*)elem);
5854 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5855 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5856 if(SUCCEEDED(hres)) {
5857 test_current_style(cstyle);
5858 IHTMLCurrentStyle_Release(cstyle);
5860 IHTMLElement2_Release(elem2);
5862 IHTMLElement_Release(elem);
5864 test_set_csstext(style);
5865 IHTMLStyle_Release(style);
5867 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5868 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5870 l = 0xdeadbeef;
5871 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5872 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5873 ok(l == 0, "length = %d\n", l);
5875 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5877 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5878 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5880 test_default_selection(doc);
5881 test_doc_title(doc, "");
5884 static void test_tr_elem(IHTMLElement *elem)
5886 IHTMLElementCollection *col;
5887 IHTMLTableRow *row;
5888 HRESULT hres;
5890 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5892 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5893 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5894 if(FAILED(hres))
5895 return;
5897 col = NULL;
5898 hres = IHTMLTableRow_get_cells(row, &col);
5899 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5900 ok(col != NULL, "get_cells returned NULL\n");
5902 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5903 IHTMLElementCollection_Release(col);
5905 IHTMLTable_Release(row);
5908 static void test_table_elem(IHTMLElement *elem)
5910 IHTMLElementCollection *col;
5911 IHTMLTable *table;
5912 IHTMLDOMNode *node;
5913 HRESULT hres;
5915 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5916 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5918 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5919 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5920 if(FAILED(hres))
5921 return;
5923 col = NULL;
5924 hres = IHTMLTable_get_rows(table, &col);
5925 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5926 ok(col != NULL, "get_ros returned NULL\n");
5928 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5929 IHTMLElementCollection_Release(col);
5931 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5933 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5934 test_elem_tag((IUnknown*)node, "TABLE");
5935 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5936 IHTMLDOMNode_Release(node);
5938 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5939 test_elem_tag((IUnknown*)node, "TABLE");
5940 test_elem_all((IUnknown*)node, NULL, 0);
5941 IHTMLDOMNode_Release(node);
5943 IHTMLTable_Release(table);
5946 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5948 SAFEARRAYBOUND dim;
5949 SAFEARRAY *sa;
5950 VARIANT *var;
5951 HRESULT hres;
5953 dim.lLbound = 0;
5954 dim.cElements = 1;
5955 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5956 SafeArrayAccessData(sa, (void**)&var);
5957 V_VT(var) = VT_BSTR;
5958 V_BSTR(var) = a2bstr(text);
5959 SafeArrayUnaccessData(sa);
5961 if(ln)
5962 hres = IHTMLDocument2_writeln(doc, sa);
5963 else
5964 hres = IHTMLDocument2_write(doc, sa);
5965 ok(hres == S_OK, "write failed: %08x\n", hres);
5967 SafeArrayDestroy(sa);
5970 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5972 IHTMLDocument2 *window_doc, *elem_doc;
5973 IHTMLFrameElement3 *frame_elem3;
5974 IHTMLWindow2 *content_window;
5975 HRESULT hres;
5977 content_window = get_frame_content_window(frame_elem);
5978 window_doc = get_window_doc(content_window);
5979 IHTMLWindow2_Release(content_window);
5981 elem_doc = get_elem_doc(frame_elem);
5982 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5984 if(!iframe) {
5985 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5986 if(SUCCEEDED(hres)) {
5987 IDispatch *disp = NULL;
5989 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5990 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5991 ok(disp != NULL, "contentDocument == NULL\n");
5992 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5994 IDispatch_Release(disp);
5995 IHTMLFrameElement3_Release(frame_elem3);
5996 }else {
5997 win_skip("IHTMLFrameElement3 not supported\n");
6001 IHTMLDocument2_Release(elem_doc);
6002 IHTMLDocument2_Release(window_doc);
6005 static void test_iframe_elem(IHTMLElement *elem)
6007 IHTMLDocument2 *content_doc, *owner_doc;
6008 IHTMLElementCollection *col;
6009 IHTMLWindow2 *content_window;
6010 IDispatch *disp;
6011 VARIANT errv;
6012 BSTR str;
6013 HRESULT hres;
6015 static const elem_type_t all_types[] = {
6016 ET_HTML,
6017 ET_HEAD,
6018 ET_TITLE,
6019 ET_BODY,
6020 ET_BR
6023 test_frame_doc((IUnknown*)elem, TRUE);
6025 content_window = get_frame_content_window((IUnknown*)elem);
6026 test_window_length(content_window, 0);
6028 content_doc = get_window_doc(content_window);
6029 IHTMLWindow2_Release(content_window);
6031 str = a2bstr("text/html");
6032 V_VT(&errv) = VT_ERROR;
6033 disp = NULL;
6034 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
6035 SysFreeString(str);
6036 ok(hres == S_OK, "open failed: %08x\n", hres);
6037 ok(disp != NULL, "disp == NULL\n");
6038 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
6039 IDispatch_Release(disp);
6041 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
6042 doc_write(content_doc, TRUE, "</html>");
6044 hres = IHTMLDocument2_get_all(content_doc, &col);
6045 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6046 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6047 IHTMLElementCollection_Release(col);
6049 hres = IHTMLDocument2_close(content_doc);
6050 ok(hres == S_OK, "close failed: %08x\n", hres);
6052 owner_doc = get_owner_doc((IUnknown*)content_doc);
6053 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
6055 IHTMLDocument2_Release(content_doc);
6058 static void test_stylesheet(IDispatch *disp)
6060 IHTMLStyleSheetRulesCollection *col = NULL;
6061 IHTMLStyleSheet *stylesheet;
6062 HRESULT hres;
6064 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
6065 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
6067 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
6068 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
6069 ok(col != NULL, "col == NULL\n");
6071 IHTMLStyleSheetRulesCollection_Release(col);
6072 IHTMLStyleSheet_Release(stylesheet);
6075 static void test_stylesheets(IHTMLDocument2 *doc)
6077 IHTMLStyleSheetsCollection *col = NULL;
6078 VARIANT idx, res;
6079 LONG len = 0;
6080 HRESULT hres;
6082 hres = IHTMLDocument2_get_styleSheets(doc, &col);
6083 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
6084 ok(col != NULL, "col == NULL\n");
6086 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
6088 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
6089 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6090 ok(len == 1, "len=%d\n", len);
6092 VariantInit(&res);
6093 V_VT(&idx) = VT_I4;
6094 V_I4(&idx) = 0;
6096 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6097 ok(hres == S_OK, "item failed: %08x\n", hres);
6098 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
6099 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6100 test_stylesheet(V_DISPATCH(&res));
6101 VariantClear(&res);
6103 V_VT(&res) = VT_I4;
6104 V_VT(&idx) = VT_I4;
6105 V_I4(&idx) = 1;
6107 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6108 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6109 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
6110 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6111 VariantClear(&res);
6113 IHTMLStyleSheetsCollection_Release(col);
6116 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
6118 IDispatchEx *dispex;
6119 IHTMLDOMNode *node;
6120 DISPPARAMS dp = {NULL, NULL, 0, 0};
6121 VARIANT var;
6122 EXCEPINFO ei;
6123 LONG type;
6124 DISPID id;
6125 BSTR bstr;
6126 HRESULT hres;
6128 static const WCHAR w0[] = {'0',0};
6129 static const WCHAR w100[] = {'1','0','0',0};
6131 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
6132 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
6134 bstr = SysAllocString(w0);
6135 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6136 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6137 SysFreeString(bstr);
6139 VariantInit(&var);
6140 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
6141 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
6142 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
6143 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
6144 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
6145 type = get_node_type((IUnknown*)node);
6146 ok(type == 3, "type=%d\n", type);
6147 IHTMLDOMNode_Release(node);
6148 VariantClear(&var);
6150 bstr = SysAllocString(w100);
6151 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6152 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
6153 SysFreeString(bstr);
6155 IDispatchEx_Release(dispex);
6160 static void test_elems(IHTMLDocument2 *doc)
6162 IHTMLElementCollection *col;
6163 IHTMLDOMChildrenCollection *child_col;
6164 IHTMLElement *elem, *elem2, *elem3;
6165 IHTMLDOMNode *node, *node2;
6166 IHTMLWindow2 *window;
6167 IDispatch *disp;
6168 LONG type;
6169 HRESULT hres;
6170 IHTMLElementCollection *collection;
6171 IHTMLDocument3 *doc3;
6172 BSTR str;
6174 static const elem_type_t all_types[] = {
6175 ET_HTML,
6176 ET_HEAD,
6177 ET_TITLE,
6178 ET_STYLE,
6179 ET_BODY,
6180 ET_COMMENT,
6181 ET_A,
6182 ET_INPUT,
6183 ET_SELECT,
6184 ET_OPTION,
6185 ET_OPTION,
6186 ET_TEXTAREA,
6187 ET_TABLE,
6188 ET_TBODY,
6189 ET_TR,
6190 ET_TR,
6191 ET_TD,
6192 ET_TD,
6193 ET_SCRIPT,
6194 ET_TEST,
6195 ET_OBJECT,
6196 ET_EMBED,
6197 ET_IMG,
6198 ET_IFRAME,
6199 ET_FORM
6202 static const elem_type_t item_types[] = {
6203 ET_A,
6204 ET_OPTION,
6205 ET_TEXTAREA
6208 hres = IHTMLDocument2_get_all(doc, &col);
6209 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6210 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6211 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
6212 IHTMLElementCollection_Release(col);
6214 hres = IHTMLDocument2_get_images(doc, &collection);
6215 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6216 if(hres == S_OK)
6218 static const elem_type_t images_types[] = {ET_IMG};
6219 test_elem_collection((IUnknown*)collection, images_types, 1);
6221 IHTMLElementCollection_Release(collection);
6224 hres = IHTMLDocument2_get_links(doc, &collection);
6225 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6226 if(hres == S_OK)
6228 static const elem_type_t images_types[] = {ET_A};
6229 test_elem_collection((IUnknown*)collection, images_types, 1);
6231 IHTMLElementCollection_Release(collection);
6234 hres = IHTMLDocument2_get_anchors(doc, &collection);
6235 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6236 if(hres == S_OK)
6238 static const elem_type_t anchor_types[] = {ET_A};
6239 test_elem_collection((IUnknown*)collection, anchor_types, 1);
6241 IHTMLElementCollection_Release(collection);
6244 elem = get_doc_elem(doc);
6245 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
6246 IHTMLElement_Release(elem);
6248 get_elem_by_id(doc, "xxx", FALSE);
6249 elem = get_doc_elem_by_id(doc, "xxx");
6250 ok(!elem, "elem != NULL\n");
6252 elem = get_doc_elem_by_id(doc, "s");
6253 ok(elem != NULL, "elem == NULL\n");
6254 if(elem) {
6255 test_elem_type((IUnknown*)elem, ET_SELECT);
6256 test_elem_attr(elem, "xxx", NULL);
6257 test_elem_attr(elem, "id", "s");
6258 test_elem_class((IUnknown*)elem, NULL);
6259 test_elem_set_class((IUnknown*)elem, "cl");
6260 test_elem_set_class((IUnknown*)elem, NULL);
6261 test_elem_tabindex((IUnknown*)elem, 0);
6262 test_elem_set_tabindex((IUnknown*)elem, 1);
6263 test_elem_filters((IUnknown*)elem);
6265 node = test_node_get_parent((IUnknown*)elem);
6266 ok(node != NULL, "node == NULL\n");
6267 test_node_name((IUnknown*)node, "BODY");
6268 node2 = test_node_get_parent((IUnknown*)node);
6269 IHTMLDOMNode_Release(node);
6270 ok(node2 != NULL, "node == NULL\n");
6271 test_node_name((IUnknown*)node2, "HTML");
6272 node = test_node_get_parent((IUnknown*)node2);
6273 IHTMLDOMNode_Release(node2);
6274 ok(node != NULL, "node == NULL\n");
6275 if (node)
6277 test_node_name((IUnknown*)node, "#document");
6278 type = get_node_type((IUnknown*)node);
6279 ok(type == 9, "type=%d, expected 9\n", type);
6280 node2 = test_node_get_parent((IUnknown*)node);
6281 IHTMLDOMNode_Release(node);
6282 ok(node2 == NULL, "node != NULL\n");
6285 elem2 = test_elem_get_parent((IUnknown*)elem);
6286 ok(elem2 != NULL, "elem2 == NULL\n");
6287 test_node_name((IUnknown*)elem2, "BODY");
6288 elem3 = test_elem_get_parent((IUnknown*)elem2);
6289 IHTMLElement_Release(elem2);
6290 ok(elem3 != NULL, "elem3 == NULL\n");
6291 test_node_name((IUnknown*)elem3, "HTML");
6292 elem2 = test_elem_get_parent((IUnknown*)elem3);
6293 IHTMLElement_Release(elem3);
6294 ok(elem2 == NULL, "elem2 != NULL\n");
6296 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6297 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6298 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6300 test_elem_innertext(elem, "opt1opt2");
6302 IHTMLElement_Release(elem);
6305 elem = get_elem_by_id(doc, "s", TRUE);
6306 if(elem) {
6307 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6308 IHTMLDocument2 *doc_node, *elem_doc;
6310 test_select_elem(select);
6312 test_elem_title((IUnknown*)select, NULL);
6313 test_elem_set_title((IUnknown*)select, "Title");
6314 test_elem_title((IUnknown*)select, "Title");
6315 test_elem_offset((IUnknown*)select);
6316 test_elem_bounding_client_rect((IUnknown*)select);
6318 node = get_first_child((IUnknown*)select);
6319 ok(node != NULL, "node == NULL\n");
6320 if(node) {
6321 test_elem_type((IUnknown*)node, ET_OPTION);
6322 IHTMLDOMNode_Release(node);
6325 type = get_node_type((IUnknown*)select);
6326 ok(type == 1, "type=%d\n", type);
6328 IHTMLSelectElement_Release(select);
6330 elem_doc = get_elem_doc((IUnknown*)elem);
6332 doc_node = get_doc_node(doc);
6333 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6334 IHTMLDocument2_Release(doc_node);
6335 IHTMLDocument2_Release(elem_doc);
6337 IHTMLElement_Release(elem);
6340 elem = get_elem_by_id(doc, "sc", TRUE);
6341 if(elem) {
6342 IHTMLScriptElement *script;
6343 BSTR type;
6345 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6346 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6348 if(hres == S_OK)
6350 VARIANT_BOOL vb;
6352 hres = IHTMLScriptElement_put_type (script, NULL);
6353 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6354 hres = IHTMLScriptElement_get_type(script, &type);
6355 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6356 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6358 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6359 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6360 hres = IHTMLScriptElement_get_type(script, &type);
6361 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6362 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6364 SysFreeString(type);
6366 /* test defer */
6367 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6368 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6370 hres = IHTMLScriptElement_get_defer(script, &vb);
6371 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6372 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6374 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6375 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6377 str = (BSTR)0xdeadbeef;
6378 hres = IHTMLScriptElement_get_src(script, &str);
6379 ok(hres == S_OK, "get_src failed: %08x\n", hres);
6380 ok(!str, "src = %s\n", wine_dbgstr_w(str));
6383 IHTMLScriptElement_Release(script);
6386 elem = get_elem_by_id(doc, "in", TRUE);
6387 if(elem) {
6388 IHTMLInputElement *input;
6390 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6391 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6393 test_elem_id((IUnknown*)elem, "in");
6394 test_elem_put_id((IUnknown*)elem, "newin");
6395 test_input_get_disabled(input, VARIANT_FALSE);
6396 test_input_set_disabled(input, VARIANT_TRUE);
6397 test_input_set_disabled(input, VARIANT_FALSE);
6398 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6399 test_input_get_disabled(input, VARIANT_TRUE);
6400 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6401 test_input_get_disabled(input, VARIANT_FALSE);
6402 test_elem_client_size((IUnknown*)elem);
6403 test_input_type(input, "text");
6405 test_node_get_value_str((IUnknown*)elem, NULL);
6406 test_node_put_value_str((IUnknown*)elem, "test");
6407 test_node_get_value_str((IUnknown*)elem, NULL);
6408 test_input_value((IUnknown*)elem, NULL);
6409 test_input_put_value((IUnknown*)elem, "test");
6410 test_input_value((IUnknown*)elem, NULL);
6411 test_elem_class((IUnknown*)elem, "testclass");
6412 test_elem_tabindex((IUnknown*)elem, 2);
6413 test_elem_set_tabindex((IUnknown*)elem, 3);
6414 test_elem_title((IUnknown*)elem, "test title");
6416 test_input_get_defaultchecked(input, VARIANT_FALSE);
6417 test_input_set_defaultchecked(input, VARIANT_TRUE);
6418 test_input_set_defaultchecked(input, VARIANT_FALSE);
6420 test_input_get_checked(input, VARIANT_FALSE);
6421 test_input_set_checked(input, VARIANT_TRUE);
6422 test_input_set_checked(input, VARIANT_FALSE);
6424 test_input_name(input, NULL);
6425 test_input_set_name(input, "test");
6427 test_input_src(input, NULL);
6428 test_input_set_src(input, "about:blank");
6430 IHTMLInputElement_Release(input);
6431 IHTMLElement_Release(elem);
6434 elem = get_elem_by_id(doc, "imgid", TRUE);
6435 if(elem) {
6436 test_img_src((IUnknown*)elem, "");
6437 test_img_set_src((IUnknown*)elem, "about:blank");
6438 test_img_alt((IUnknown*)elem, NULL);
6439 test_img_set_alt((IUnknown*)elem, "alt test");
6440 test_img_name((IUnknown*)elem, "WineImg");
6441 IHTMLElement_Release(elem);
6444 elem = get_elem_by_id(doc, "styleid", TRUE);
6445 if(elem) {
6446 test_style_media((IUnknown*)elem, NULL);
6447 test_style_put_media((IUnknown*)elem, "screen");
6448 test_style_type((IUnknown*)elem, NULL);
6449 test_style_put_type((IUnknown*)elem, "text/css");
6450 IHTMLElement_Release(elem);
6453 elem = get_doc_elem_by_id(doc, "tbl");
6454 ok(elem != NULL, "elem == NULL\n");
6455 if(elem) {
6456 test_table_elem(elem);
6457 IHTMLElement_Release(elem);
6460 elem = get_doc_elem_by_id(doc, "row2");
6461 ok(elem != NULL, "elem == NULL\n");
6462 if(elem) {
6463 test_tr_elem(elem);
6464 IHTMLElement_Release(elem);
6467 elem = get_doc_elem_by_id(doc, "ifr");
6468 ok(elem != NULL, "elem == NULL\n");
6469 if(elem) {
6470 test_iframe_elem(elem);
6471 IHTMLElement_Release(elem);
6474 elem = get_doc_elem_by_id(doc, "objid");
6475 ok(elem != NULL, "elem == NULL\n");
6476 if(elem) {
6477 test_object_vspace((IUnknown*)elem, 100);
6478 IHTMLElement_Release(elem);
6481 elem = get_elem_by_id(doc, "a", TRUE);
6482 if(elem) {
6483 test_anchor_href((IUnknown*)elem, "http://test/");
6484 IHTMLElement_Release(elem);
6487 elem = doc_get_body(doc);
6489 node = get_first_child((IUnknown*)elem);
6490 ok(node != NULL, "node == NULL\n");
6491 if(node) {
6492 test_ifaces((IUnknown*)node, text_iids);
6493 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6495 node2 = get_first_child((IUnknown*)node);
6496 ok(!node2, "node2 != NULL\n");
6498 type = get_node_type((IUnknown*)node);
6499 ok(type == 3, "type=%d\n", type);
6501 test_node_get_value_str((IUnknown*)node, "text test");
6502 test_node_put_value_str((IUnknown*)elem, "test text");
6503 test_node_get_value_str((IUnknown*)node, "text test");
6505 IHTMLDOMNode_Release(node);
6508 child_col = get_child_nodes((IUnknown*)elem);
6509 ok(child_col != NULL, "child_coll == NULL\n");
6510 if(child_col) {
6511 LONG length = 0;
6513 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6515 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6516 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6517 ok(length, "length=0\n");
6519 node2 = NULL;
6520 node = get_child_item(child_col, 0);
6521 ok(node != NULL, "node == NULL\n");
6522 if(node) {
6523 type = get_node_type((IUnknown*)node);
6524 ok(type == 3, "type=%d\n", type);
6525 node2 = node_get_next((IUnknown*)node);
6526 IHTMLDOMNode_Release(node);
6529 node = get_child_item(child_col, 1);
6530 ok(node != NULL, "node == NULL\n");
6531 if(node) {
6532 type = get_node_type((IUnknown*)node);
6533 ok(type == 8, "type=%d\n", type);
6535 test_elem_id((IUnknown*)node, NULL);
6536 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6537 IHTMLDOMNode_Release(node2);
6538 IHTMLDOMNode_Release(node);
6541 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6542 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6544 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6545 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6547 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6548 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6550 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6551 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6553 test_child_col_disp(child_col);
6555 IHTMLDOMChildrenCollection_Release(child_col);
6558 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6559 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6560 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6562 IHTMLElement_Release(elem);
6564 elem = get_doc_elem_by_id(doc, "frm");
6565 ok(elem != NULL, "elem == NULL\n");
6566 if(elem) {
6567 test_form_length((IUnknown*)elem, 0);
6568 IHTMLElement_Release(elem);
6571 test_stylesheets(doc);
6572 test_create_option_elem(doc);
6573 test_create_img_elem(doc);
6575 elem = get_doc_elem_by_id(doc, "tbl");
6576 ok(elem != NULL, "elem = NULL\n");
6577 test_elem_set_innertext(elem, "inner text");
6578 IHTMLElement_Release(elem);
6580 test_doc_title(doc, "test");
6581 test_doc_set_title(doc, "test title");
6582 test_doc_title(doc, "test title");
6584 disp = NULL;
6585 hres = IHTMLDocument2_get_Script(doc, &disp);
6586 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6587 if(hres == S_OK)
6589 IDispatchEx *dispex;
6590 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6591 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6592 if(hres == S_OK)
6594 DISPID pid = -1;
6595 BSTR str = a2bstr("Testing");
6596 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6597 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6598 ok(pid != -1, "pid == -1\n");
6599 SysFreeString(str);
6600 IDispatchEx_Release(dispex);
6603 IDispatch_Release(disp);
6605 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6606 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6608 str = a2bstr("img");
6609 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6610 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6611 SysFreeString(str);
6612 if(hres == S_OK)
6614 static const elem_type_t img_types[] = { ET_IMG };
6616 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6617 IHTMLElementCollection_Release(col);
6620 elem = get_doc_elem_by_id(doc, "y");
6621 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6622 test_elem_innerhtml((IUnknown*)elem, "inner html");
6623 test_elem_set_innerhtml((IUnknown*)elem, "");
6624 test_elem_innerhtml((IUnknown*)elem, NULL);
6625 node = node_get_next((IUnknown*)elem);
6626 ok(!node, "node = %p\n", node);
6628 elem2 = get_doc_elem_by_id(doc, "x");
6629 test_elem_tag((IUnknown*)elem2, "A");
6630 node = node_get_next((IUnknown*)elem2);
6631 IHTMLDOMNode_Release(node);
6632 IHTMLElement_Release(elem2);
6633 IHTMLElement_Release(elem);
6635 IHTMLDocument3_Release(doc3);
6637 elem = get_elem_by_id(doc, "s", TRUE);
6638 if(elem) {
6639 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6641 test_select_put_length((IUnknown*)elem, 3);
6642 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6643 test_select_put_length((IUnknown*)elem, 1);
6644 test_elem_all((IUnknown*)elem, select_types, 1);
6645 IHTMLElement_Release(elem);
6648 window = get_doc_window(doc);
6649 test_window_name(window, NULL);
6650 set_window_name(window, "test name");
6651 test_window_length(window, 1);
6652 IHTMLWindow2_Release(window);
6655 static void test_elems2(IHTMLDocument2 *doc)
6657 IHTMLElement *elem, *elem2, *div;
6659 static const elem_type_t outer_types[] = {
6660 ET_BR,
6661 ET_A
6664 div = get_doc_elem_by_id(doc, "divid");
6666 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6667 elem2 = get_doc_elem_by_id(doc, "innerid");
6668 ok(elem2 != NULL, "elem2 == NULL\n");
6669 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6670 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6671 IHTMLElement_Release(elem2);
6673 elem2 = get_doc_elem_by_id(doc, "aid");
6674 ok(elem2 != NULL, "elem2 == NULL\n");
6675 test_elem_set_outerhtml((IUnknown*)elem2, "");
6676 test_elem_all((IUnknown*)div, outer_types, 1);
6677 IHTMLElement_Release(elem2);
6679 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6680 elem = get_elem_by_id(doc, "ta", TRUE);
6681 if(elem) {
6682 test_textarea_value((IUnknown*)elem, NULL);
6683 test_textarea_put_value((IUnknown*)elem, "test");
6684 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6685 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6686 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6687 test_textarea_type((IUnknown*)elem);
6688 IHTMLElement_Release(elem);
6691 test_elem_set_innerhtml((IUnknown*)div,
6692 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6693 elem = get_elem_by_id(doc, "form", TRUE);
6694 if(elem) {
6695 test_form_length((IUnknown*)elem, 2);
6696 test_form_item(elem);
6697 test_form_action((IUnknown*)elem, NULL);
6698 test_form_put_action((IUnknown*)elem, "about:blank");
6699 test_form_method((IUnknown*)elem, "get");
6700 test_form_put_method((IUnknown*)elem, S_OK, "post");
6701 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
6702 test_form_method((IUnknown*)elem, "post");
6703 test_form_name((IUnknown*)elem, NULL);
6704 test_form_put_name((IUnknown*)elem, "Name");
6705 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
6706 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
6707 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
6708 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
6709 test_form_encoding((IUnknown*)elem, "multipart/form-data");
6710 IHTMLElement_Release(elem);
6713 IHTMLElement_Release(div);
6716 static void test_create_elems(IHTMLDocument2 *doc)
6718 IHTMLElement *elem, *body, *elem2;
6719 IHTMLDOMNode *node, *node2, *node3, *comment;
6720 IHTMLDocument5 *doc5;
6721 IDispatch *disp;
6722 VARIANT var;
6723 LONG type;
6724 HRESULT hres;
6725 BSTR str;
6727 static const elem_type_t types1[] = { ET_TESTG };
6729 elem = test_create_elem(doc, "TEST");
6730 test_elem_tag((IUnknown*)elem, "TEST");
6731 type = get_node_type((IUnknown*)elem);
6732 ok(type == 1, "type=%d\n", type);
6733 test_ifaces((IUnknown*)elem, elem_iids);
6734 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6736 body = doc_get_body(doc);
6737 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6739 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6740 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6741 elem2 = get_elem_iface((IUnknown*)node);
6742 IHTMLElement_Release(elem2);
6744 hres = IHTMLElement_get_all(body, &disp);
6745 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6746 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6747 IDispatch_Release(disp);
6749 test_node_remove_child((IUnknown*)body, node);
6751 hres = IHTMLElement_get_all(body, &disp);
6752 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6753 test_elem_collection((IUnknown*)disp, NULL, 0);
6754 IDispatch_Release(disp);
6755 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6757 IHTMLElement_Release(elem);
6758 IHTMLDOMNode_Release(node);
6760 node = test_create_text(doc, "test");
6761 test_ifaces((IUnknown*)node, text_iids);
6762 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6763 test_text_length((IUnknown*)node, 4);
6765 V_VT(&var) = VT_NULL;
6766 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6767 IHTMLDOMNode_Release(node);
6769 node = test_create_text(doc, "insert ");
6771 V_VT(&var) = VT_DISPATCH;
6772 V_DISPATCH(&var) = (IDispatch*)node2;
6773 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6774 IHTMLDOMNode_Release(node);
6775 IHTMLDOMNode_Release(node2);
6776 IHTMLDOMNode_Release(node3);
6778 test_elem_innertext(body, "insert test");
6779 test_elem_innerhtml((IUnknown*)body, "insert test");
6781 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6782 if(hres == S_OK)
6784 str = a2bstr("testing");
6785 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6786 SysFreeString(str);
6787 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6788 if(hres == S_OK)
6790 type = get_node_type((IUnknown*)comment);
6791 ok(type == 8, "type=%d, expected 8\n", type);
6793 test_node_get_value_str((IUnknown*)comment, "testing");
6794 test_elem_title((IUnknown*)comment, NULL);
6795 test_elem_set_title((IUnknown*)comment, "comment title");
6796 test_elem_title((IUnknown*)comment, "comment title");
6797 test_comment_text((IUnknown*)comment, "<!--testing-->");
6798 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6800 IHTMLDOMNode_Release(comment);
6803 IHTMLDocument5_Release(doc5);
6806 IHTMLElement_Release(body);
6809 static void test_null_write(IHTMLDocument2 *doc)
6811 HRESULT hres;
6813 doc_write(doc, FALSE, NULL);
6814 doc_write(doc, TRUE, NULL);
6816 hres = IHTMLDocument2_write(doc, NULL);
6817 ok(hres == S_OK,
6818 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6820 hres = IHTMLDocument2_writeln(doc, NULL);
6821 ok(hres == S_OK,
6822 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6825 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6827 IOleCommandTarget *cmdtrg;
6828 HRESULT hres;
6830 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6831 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6833 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6834 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6836 IOleCommandTarget_Release(cmdtrg);
6839 static void test_indent(IHTMLDocument2 *doc)
6841 IHTMLElementCollection *col;
6842 IHTMLTxtRange *range;
6843 HRESULT hres;
6845 static const elem_type_t all_types[] = {
6846 ET_HTML,
6847 ET_HEAD,
6848 ET_TITLE,
6849 ET_BODY,
6850 ET_BR,
6851 ET_A,
6854 static const elem_type_t indent_types[] = {
6855 ET_HTML,
6856 ET_HEAD,
6857 ET_TITLE,
6858 ET_BODY,
6859 ET_BLOCKQUOTE,
6860 ET_P,
6861 ET_BR,
6862 ET_A,
6865 hres = IHTMLDocument2_get_all(doc, &col);
6866 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6867 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6868 IHTMLElementCollection_Release(col);
6870 range = test_create_body_range(doc);
6871 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6872 IHTMLTxtRange_Release(range);
6874 hres = IHTMLDocument2_get_all(doc, &col);
6875 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6876 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6877 IHTMLElementCollection_Release(col);
6880 static void test_cond_comment(IHTMLDocument2 *doc)
6882 IHTMLElementCollection *col;
6883 HRESULT hres;
6885 static const elem_type_t all_types[] = {
6886 ET_HTML,
6887 ET_HEAD,
6888 ET_TITLE,
6889 ET_BODY,
6890 ET_BR
6893 hres = IHTMLDocument2_get_all(doc, &col);
6894 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6895 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6896 IHTMLElementCollection_Release(col);
6899 static void test_frame(IDispatch *disp, const char *exp_id)
6901 IHTMLWindow2 *frame2, *parent, *top;
6902 IHTMLDocument2 *parent_doc, *top_doc;
6903 IHTMLWindow4 *frame;
6904 IHTMLFrameBase *frame_elem;
6905 HRESULT hres;
6907 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6908 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6909 if(FAILED(hres))
6910 return;
6912 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6913 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6914 IHTMLWindow4_Release(frame);
6915 if(FAILED(hres))
6916 return;
6918 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6919 test_frame_doc((IUnknown*)frame_elem, FALSE);
6920 test_elem_id((IUnknown*)frame_elem, exp_id);
6921 IHTMLElement_Release(frame_elem);
6923 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6924 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6925 if(FAILED(hres))
6926 return;
6928 hres = IHTMLWindow2_get_parent(frame2, &parent);
6929 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6930 if(FAILED(hres)){
6931 IHTMLWindow2_Release(frame2);
6932 return;
6935 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6936 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6937 IHTMLWindow2_Release(parent);
6938 if(FAILED(hres)){
6939 IHTMLWindow2_Release(frame2);
6940 return;
6943 test_doc_title(parent_doc, "frameset test");
6944 IHTMLDocument2_Release(parent_doc);
6946 /* test get_top */
6947 hres = IHTMLWindow2_get_top(frame2, &top);
6948 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6949 IHTMLWindow2_Release(frame2);
6950 if(FAILED(hres))
6951 return;
6953 hres = IHTMLWindow2_get_document(top, &top_doc);
6954 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6955 IHTMLWindow2_Release(top);
6956 if(FAILED(hres))
6957 return;
6959 test_doc_title(top_doc, "frameset test");
6960 IHTMLDocument2_Release(top_doc);
6963 static void test_frameset(IHTMLDocument2 *doc)
6965 IHTMLWindow2 *window;
6966 IHTMLFramesCollection2 *frames;
6967 IHTMLElement *elem;
6968 IHTMLFrameBase *fbase;
6969 LONG length;
6970 VARIANT index_var, result_var;
6971 BSTR str;
6972 HRESULT hres;
6974 window = get_doc_window(doc);
6976 /* test using IHTMLFramesCollection object */
6978 hres = IHTMLWindow2_get_frames(window, &frames);
6979 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6980 IHTMLWindow2_Release(window);
6981 if(FAILED(hres))
6982 return;
6984 /* test result length */
6985 hres = IHTMLFramesCollection2_get_length(frames, &length);
6986 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6987 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6989 /* test first frame */
6990 V_VT(&index_var) = VT_I4;
6991 V_I4(&index_var) = 0;
6992 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6993 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6994 if(SUCCEEDED(hres)) {
6995 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6996 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6998 VariantClear(&result_var);
7000 /* test second frame */
7001 V_I4(&index_var) = 1;
7002 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7003 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7004 if(SUCCEEDED(hres)) {
7005 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7006 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7008 VariantClear(&result_var);
7010 /* fail on next frame */
7011 V_I4(&index_var) = 3;
7012 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7013 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
7014 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7015 VariantClear(&result_var);
7017 /* string argument (element id lookup) */
7018 V_VT(&index_var) = VT_BSTR;
7019 V_BSTR(&index_var) = a2bstr("fr1");
7020 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7021 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7022 if(SUCCEEDED(hres)) {
7023 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7024 test_frame(V_DISPATCH(&result_var), "fr1");
7026 VariantClear(&result_var);
7027 VariantClear(&index_var);
7029 /* invalid argument */
7030 V_VT(&index_var) = VT_BOOL;
7031 V_BOOL(&index_var) = VARIANT_TRUE;
7032 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7033 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
7034 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7035 VariantClear(&result_var);
7037 IHTMLFramesCollection2_Release(frames);
7039 /* test using IHTMLWindow2 inheritance */
7041 /* test result length */
7042 hres = IHTMLWindow2_get_length(window, &length);
7043 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
7044 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
7046 /* test first frame */
7047 V_VT(&index_var) = VT_I4;
7048 V_I4(&index_var) = 0;
7049 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7050 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7051 if(SUCCEEDED(hres)) {
7052 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7053 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7055 VariantClear(&result_var);
7057 /* test second frame */
7058 V_I4(&index_var) = 1;
7059 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7060 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7061 if(SUCCEEDED(hres)) {
7062 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7063 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7065 VariantClear(&result_var);
7067 /* fail on next frame */
7068 V_I4(&index_var) = 3;
7069 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7070 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
7071 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7072 VariantClear(&result_var);
7074 /* string argument (element id lookup) */
7075 V_VT(&index_var) = VT_BSTR;
7076 V_BSTR(&index_var) = a2bstr("fr2");
7077 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7078 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7079 if(SUCCEEDED(hres)) {
7080 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7081 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7083 VariantClear(&result_var);
7084 VariantClear(&index_var);
7086 /* invalid argument */
7087 V_VT(&index_var) = VT_BOOL;
7088 V_BOOL(&index_var) = VARIANT_TRUE;
7089 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7090 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
7091 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7092 VariantClear(&result_var);
7094 /* getElementById with node name attributes */
7095 elem = get_doc_elem_by_id(doc, "nm1");
7096 test_elem_id((IUnknown*)elem, "fr1");
7098 /* get/put scrolling */
7099 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7100 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7102 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7103 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7104 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
7105 SysFreeString(str);
7107 str = a2bstr("no");
7108 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7109 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
7110 SysFreeString(str);
7112 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7113 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7114 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7115 SysFreeString(str);
7117 str = a2bstr("junk");
7118 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7119 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
7120 "with E_INVALIDARG, instead: 0x%08x\n", hres);
7121 SysFreeString(str);
7123 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7124 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7125 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7126 SysFreeString(str);
7128 /* get_name */
7129 hres = IHTMLFrameBase_get_name(fbase, &str);
7130 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7131 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
7132 SysFreeString(str);
7134 IHTMLFrameBase_Release(fbase);
7135 IHTMLElement_Release(elem);
7137 /* get_name with no name attr */
7138 elem = get_doc_elem_by_id(doc, "fr3");
7139 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7140 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7142 hres = IHTMLFrameBase_get_name(fbase, &str);
7143 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7144 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
7145 SysFreeString(str);
7147 IHTMLFrameBase_Release(fbase);
7148 IHTMLElement_Release(elem);
7151 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
7153 IHTMLDocument2 *frag;
7154 IHTMLDocument3 *doc3;
7155 HRESULT hres;
7157 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
7158 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
7160 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
7161 IHTMLDocument3_Release(doc3);
7162 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
7163 ok(frag != NULL, "frag == NULL\n");
7165 return frag;
7168 static void test_docfrag(IHTMLDocument2 *doc)
7170 IHTMLElement *div, *body, *br;
7171 IHTMLElementCollection *col;
7172 IHTMLLocation *location;
7173 IHTMLDocument2 *frag;
7174 HRESULT hres;
7176 static const elem_type_t all_types[] = {
7177 ET_HTML,
7178 ET_HEAD,
7179 ET_TITLE,
7180 ET_BODY,
7181 ET_DIV,
7182 ET_BR
7185 frag = create_docfrag(doc);
7187 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
7189 body = (void*)0xdeadbeef;
7190 hres = IHTMLDocument2_get_body(frag, &body);
7191 ok(hres == S_OK, "get_body failed: %08x\n", hres);
7192 ok(!body, "body != NULL\n");
7194 location = (void*)0xdeadbeef;
7195 hres = IHTMLDocument2_get_location(frag, &location);
7196 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
7197 ok(location == (void*)0xdeadbeef, "location changed\n");
7199 br = test_create_elem(doc, "BR");
7200 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
7201 IHTMLElement_Release(br);
7203 div = get_elem_by_id(doc, "divid", TRUE);
7204 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
7205 IHTMLElement_Release(div);
7207 hres = IHTMLDocument2_get_all(doc, &col);
7208 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7209 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7210 IHTMLElementCollection_Release(col);
7212 IHTMLDocument2_Release(frag);
7215 static IHTMLDocument2 *notif_doc;
7216 static BOOL doc_complete;
7218 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
7219 REFIID riid, void**ppv)
7221 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
7222 *ppv = iface;
7223 return S_OK;
7226 ok(0, "unexpected call\n");
7227 return E_NOINTERFACE;
7230 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
7232 return 2;
7235 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
7237 return 1;
7240 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
7242 if(dispID == DISPID_READYSTATE){
7243 BSTR state;
7244 HRESULT hres;
7246 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
7247 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
7249 if(!strcmp_wa(state, "complete"))
7250 doc_complete = TRUE;
7252 SysFreeString(state);
7255 return S_OK;
7258 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
7260 ok(0, "unexpected call\n");
7261 return E_NOTIMPL;
7264 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
7265 PropertyNotifySink_QueryInterface,
7266 PropertyNotifySink_AddRef,
7267 PropertyNotifySink_Release,
7268 PropertyNotifySink_OnChanged,
7269 PropertyNotifySink_OnRequestEdit
7272 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
7274 static IHTMLDocument2 *create_doc_with_string(const char *str)
7276 IPersistStreamInit *init;
7277 IStream *stream;
7278 IHTMLDocument2 *doc;
7279 HGLOBAL mem;
7280 SIZE_T len;
7282 notif_doc = doc = create_document();
7283 if(!doc)
7284 return NULL;
7286 doc_complete = FALSE;
7287 len = strlen(str);
7288 mem = GlobalAlloc(0, len);
7289 memcpy(mem, str, len);
7290 CreateStreamOnHGlobal(mem, TRUE, &stream);
7292 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
7294 IPersistStreamInit_Load(init, stream);
7295 IPersistStreamInit_Release(init);
7296 IStream_Release(stream);
7298 return doc;
7301 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
7303 IConnectionPointContainer *container;
7304 IConnectionPoint *cp;
7305 DWORD cookie;
7306 HRESULT hres;
7308 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
7309 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
7311 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
7312 IConnectionPointContainer_Release(container);
7313 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
7315 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
7316 IConnectionPoint_Release(cp);
7317 ok(hres == S_OK, "Advise failed: %08x\n", hres);
7320 typedef void (*domtest_t)(IHTMLDocument2*);
7322 static void run_domtest(const char *str, domtest_t test)
7324 IHTMLDocument2 *doc;
7325 ULONG ref;
7326 MSG msg;
7328 doc = create_doc_with_string(str);
7329 if(!doc)
7330 return;
7332 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
7334 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
7335 TranslateMessage(&msg);
7336 DispatchMessage(&msg);
7339 test(doc);
7341 ref = IHTMLDocument2_Release(doc);
7342 ok(!ref || broken(ref == 1), /* Vista */
7343 "ref = %d\n", ref);
7346 START_TEST(dom)
7348 CoInitialize(NULL);
7350 run_domtest(doc_str1, test_doc_elem);
7351 run_domtest(doc_str1, test_get_set_attr);
7352 run_domtest(range_test_str, test_txtrange);
7353 run_domtest(range_test2_str, test_txtrange2);
7354 if (winetest_interactive || ! is_ie_hardened()) {
7355 run_domtest(elem_test_str, test_elems);
7356 }else {
7357 skip("IE running in Enhanced Security Configuration\n");
7359 run_domtest(elem_test2_str, test_elems2);
7360 run_domtest(doc_blank, test_create_elems);
7361 run_domtest(doc_blank, test_defaults);
7362 run_domtest(doc_blank, test_null_write);
7363 run_domtest(indent_test_str, test_indent);
7364 run_domtest(cond_comment_str, test_cond_comment);
7365 run_domtest(frameset_str, test_frameset);
7366 run_domtest(emptydiv_str, test_docfrag);
7368 CoUninitialize();