mshtml: Fixed platform test on 64-bit IE6.
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blob4f954a8ba302b19d4283303f8a46716a73831648
1 /*
2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "mshtml.h"
30 #include "mshtmcid.h"
31 #include "mshtmhst.h"
32 #include "docobj.h"
33 #include "dispex.h"
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test />"
52 "<img id=\"imgid\" name=\"WineImg\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "<form id=\"frm\"></form>"
55 "</body></html>";
56 static const char elem_test2_str[] =
57 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
58 "<body><div id=\"divid\"></div></body>"
59 "</html>";
61 static const char indent_test_str[] =
62 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
63 static const char cond_comment_str[] =
64 "<html><head><title>test</title></head><body>"
65 "<!--[if gte IE 4]> <br> <![endif]-->"
66 "</body></html>";
67 static const char frameset_str[] =
68 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
69 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
70 "<frame src=\"about:blank\" id=\"fr3\">"
71 "</frameset></html>";
73 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
74 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
75 static WCHAR wordW[] = {'w','o','r','d',0};
77 typedef enum {
78 ET_NONE,
79 ET_HTML,
80 ET_HEAD,
81 ET_TITLE,
82 ET_BODY,
83 ET_A,
84 ET_INPUT,
85 ET_SELECT,
86 ET_TEXTAREA,
87 ET_OPTION,
88 ET_STYLE,
89 ET_BLOCKQUOTE,
90 ET_P,
91 ET_BR,
92 ET_TABLE,
93 ET_TBODY,
94 ET_SCRIPT,
95 ET_TEST,
96 ET_TESTG,
97 ET_COMMENT,
98 ET_IMG,
99 ET_TR,
100 ET_TD,
101 ET_IFRAME,
102 ET_FORM,
103 ET_FRAME
104 } elem_type_t;
106 static const IID * const none_iids[] = {
107 &IID_IUnknown,
108 NULL
111 static const IID * const doc_node_iids[] = {
112 &IID_IHTMLDOMNode,
113 &IID_IHTMLDOMNode2,
114 &IID_IHTMLDocument,
115 &IID_IHTMLDocument2,
116 &IID_IHTMLDocument3,
117 &IID_IHTMLDocument4,
118 &IID_IHTMLDocument5,
119 &IID_IDispatchEx,
120 &IID_IConnectionPointContainer,
121 &IID_IInternetHostSecurityManager,
122 NULL
125 static const IID * const doc_obj_iids[] = {
126 &IID_IHTMLDocument,
127 &IID_IHTMLDocument2,
128 &IID_IHTMLDocument3,
129 &IID_IHTMLDocument4,
130 &IID_IHTMLDocument5,
131 &IID_IDispatchEx,
132 &IID_IConnectionPointContainer,
133 &IID_ICustomDoc,
134 NULL
137 static const IID * const elem_iids[] = {
138 &IID_IHTMLDOMNode,
139 &IID_IHTMLDOMNode2,
140 &IID_IHTMLElement,
141 &IID_IHTMLElement2,
142 &IID_IHTMLElement3,
143 &IID_IDispatchEx,
144 &IID_IConnectionPointContainer,
145 NULL
148 static const IID * const body_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IHTMLTextContainer,
155 &IID_IHTMLBodyElement,
156 &IID_IDispatchEx,
157 &IID_IConnectionPointContainer,
158 NULL
161 static const IID * const anchor_iids[] = {
162 &IID_IHTMLDOMNode,
163 &IID_IHTMLDOMNode2,
164 &IID_IHTMLElement,
165 &IID_IHTMLElement2,
166 &IID_IHTMLElement3,
167 &IID_IHTMLAnchorElement,
168 &IID_IDispatchEx,
169 &IID_IConnectionPointContainer,
170 NULL
173 static const IID * const input_iids[] = {
174 &IID_IHTMLDOMNode,
175 &IID_IHTMLDOMNode2,
176 &IID_IHTMLElement,
177 &IID_IHTMLElement2,
178 &IID_IHTMLElement3,
179 &IID_IHTMLInputElement,
180 &IID_IHTMLInputTextElement,
181 &IID_IDispatchEx,
182 &IID_IConnectionPointContainer,
183 NULL
186 static const IID * const select_iids[] = {
187 &IID_IHTMLDOMNode,
188 &IID_IHTMLDOMNode2,
189 &IID_IHTMLElement,
190 &IID_IHTMLElement2,
191 &IID_IHTMLElement3,
192 &IID_IHTMLSelectElement,
193 &IID_IDispatchEx,
194 &IID_IConnectionPointContainer,
195 NULL
198 static const IID * const textarea_iids[] = {
199 &IID_IHTMLDOMNode,
200 &IID_IHTMLDOMNode2,
201 &IID_IHTMLElement,
202 &IID_IHTMLElement2,
203 &IID_IHTMLElement3,
204 &IID_IHTMLTextAreaElement,
205 &IID_IDispatchEx,
206 &IID_IConnectionPointContainer,
207 NULL
210 static const IID * const option_iids[] = {
211 &IID_IHTMLDOMNode,
212 &IID_IHTMLDOMNode2,
213 &IID_IHTMLElement,
214 &IID_IHTMLElement2,
215 &IID_IHTMLElement3,
216 &IID_IHTMLOptionElement,
217 &IID_IDispatchEx,
218 &IID_IConnectionPointContainer,
219 NULL
222 static const IID * const table_iids[] = {
223 &IID_IHTMLDOMNode,
224 &IID_IHTMLDOMNode2,
225 &IID_IHTMLElement,
226 &IID_IHTMLElement2,
227 &IID_IHTMLElement3,
228 &IID_IHTMLTable,
229 &IID_IDispatchEx,
230 &IID_IConnectionPointContainer,
231 NULL
234 static const IID * const script_iids[] = {
235 &IID_IHTMLDOMNode,
236 &IID_IHTMLDOMNode2,
237 &IID_IHTMLElement,
238 &IID_IHTMLElement2,
239 &IID_IHTMLElement3,
240 &IID_IHTMLScriptElement,
241 &IID_IDispatchEx,
242 &IID_IConnectionPointContainer,
243 NULL
246 static const IID * const text_iids[] = {
247 &IID_IHTMLDOMNode,
248 &IID_IHTMLDOMNode2,
249 &IID_IHTMLDOMTextNode,
250 NULL
253 static const IID * const location_iids[] = {
254 &IID_IDispatch,
255 &IID_IHTMLLocation,
256 NULL
259 static const IID * const window_iids[] = {
260 &IID_IDispatch,
261 &IID_IHTMLWindow2,
262 &IID_IHTMLWindow3,
263 &IID_IDispatchEx,
264 NULL
267 static const IID * const comment_iids[] = {
268 &IID_IHTMLDOMNode,
269 &IID_IHTMLDOMNode2,
270 &IID_IHTMLElement,
271 &IID_IHTMLElement2,
272 &IID_IHTMLElement3,
273 &IID_IHTMLCommentElement,
274 &IID_IDispatchEx,
275 &IID_IConnectionPointContainer,
276 NULL
279 static const IID * const img_iids[] = {
280 &IID_IHTMLDOMNode,
281 &IID_IHTMLDOMNode2,
282 &IID_IHTMLElement,
283 &IID_IHTMLElement2,
284 &IID_IHTMLElement3,
285 &IID_IDispatchEx,
286 &IID_IHTMLImgElement,
287 &IID_IConnectionPointContainer,
288 NULL
291 static const IID * const tr_iids[] = {
292 &IID_IHTMLDOMNode,
293 &IID_IHTMLDOMNode2,
294 &IID_IHTMLElement,
295 &IID_IHTMLElement2,
296 &IID_IHTMLElement3,
297 &IID_IDispatchEx,
298 &IID_IHTMLTableRow,
299 &IID_IConnectionPointContainer,
300 NULL
303 static const IID * const td_iids[] = {
304 &IID_IHTMLDOMNode,
305 &IID_IHTMLDOMNode2,
306 &IID_IHTMLElement,
307 &IID_IHTMLElement2,
308 &IID_IHTMLElement3,
309 &IID_IDispatchEx,
310 &IID_IConnectionPointContainer,
311 NULL
314 static const IID * const frame_iids[] = {
315 &IID_IHTMLDOMNode,
316 &IID_IHTMLDOMNode2,
317 &IID_IHTMLElement,
318 &IID_IHTMLElement2,
319 &IID_IHTMLElement3,
320 &IID_IHTMLFrameBase,
321 &IID_IHTMLFrameBase2,
322 &IID_IDispatchEx,
323 &IID_IConnectionPointContainer,
324 NULL
327 static const IID * const iframe_iids[] = {
328 &IID_IHTMLDOMNode,
329 &IID_IHTMLDOMNode2,
330 &IID_IHTMLElement,
331 &IID_IHTMLElement2,
332 &IID_IHTMLElement3,
333 &IID_IHTMLFrameBase,
334 &IID_IHTMLFrameBase2,
335 &IID_IHTMLIFrameElement,
336 &IID_IDispatchEx,
337 &IID_IConnectionPointContainer,
338 NULL
341 static const IID * const form_iids[] = {
342 &IID_IHTMLDOMNode,
343 &IID_IHTMLDOMNode2,
344 &IID_IHTMLElement,
345 &IID_IHTMLElement2,
346 &IID_IHTMLElement3,
347 &IID_IHTMLFormElement,
348 &IID_IDispatchEx,
349 &IID_IConnectionPointContainer,
350 NULL
353 static const IID * const generic_iids[] = {
354 &IID_IHTMLDOMNode,
355 &IID_IHTMLDOMNode2,
356 &IID_IHTMLElement,
357 &IID_IHTMLElement2,
358 &IID_IHTMLElement3,
359 &IID_IHTMLGenericElement,
360 &IID_IDispatchEx,
361 &IID_IConnectionPointContainer,
362 NULL
365 static const IID * const style_iids[] = {
366 &IID_IUnknown,
367 &IID_IDispatch,
368 &IID_IDispatchEx,
369 &IID_IHTMLStyle,
370 &IID_IHTMLStyle2,
371 &IID_IHTMLStyle3,
372 &IID_IHTMLStyle4,
373 NULL
376 static const IID * const cstyle_iids[] = {
377 &IID_IUnknown,
378 &IID_IDispatch,
379 &IID_IDispatchEx,
380 &IID_IHTMLCurrentStyle,
381 NULL
384 static const IID * const img_factory_iids[] = {
385 &IID_IUnknown,
386 &IID_IDispatch,
387 &IID_IDispatchEx,
388 &IID_IHTMLImageElementFactory,
389 NULL
392 typedef struct {
393 const char *tag;
394 REFIID *iids;
395 const IID *dispiid;
396 } elem_type_info_t;
398 static const elem_type_info_t elem_type_infos[] = {
399 {"", none_iids, NULL},
400 {"HTML", elem_iids, NULL},
401 {"HEAD", elem_iids, NULL},
402 {"TITLE", elem_iids, NULL},
403 {"BODY", body_iids, &DIID_DispHTMLBody},
404 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
405 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
406 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
407 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
408 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
409 {"STYLE", elem_iids, NULL},
410 {"BLOCKQUOTE",elem_iids, NULL},
411 {"P", elem_iids, NULL},
412 {"BR", elem_iids, NULL},
413 {"TABLE", table_iids, &DIID_DispHTMLTable},
414 {"TBODY", elem_iids, NULL},
415 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
416 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
417 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
418 {"!", comment_iids, &DIID_DispHTMLCommentElement},
419 {"IMG", img_iids, &DIID_DispHTMLImg},
420 {"TR", tr_iids, &DIID_DispHTMLTableRow},
421 {"TD", td_iids, NULL},
422 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
423 {"FORM", form_iids, &DIID_DispHTMLFormElement},
424 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement}
427 static const char *dbgstr_guid(REFIID riid)
429 static char buf[50];
431 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
432 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
433 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
434 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
436 return buf;
439 static int strcmp_wa(LPCWSTR strw, const char *stra)
441 CHAR buf[512];
442 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
443 return lstrcmpA(stra, buf);
446 static BSTR a2bstr(const char *str)
448 BSTR ret;
449 int len;
451 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
452 ret = SysAllocStringLen(NULL, len);
453 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
455 return ret;
458 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
460 IUnknown *unk1, *unk2;
462 if(iface1 == iface2)
463 return TRUE;
465 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
466 IUnknown_Release(unk1);
467 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
468 IUnknown_Release(unk2);
470 return unk1 == unk2;
473 static IHTMLDocument2 *create_document(void)
475 IHTMLDocument2 *doc;
476 IHTMLDocument5 *doc5;
477 HRESULT hres;
479 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
480 &IID_IHTMLDocument2, (void**)&doc);
481 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
482 if(FAILED(hres))
483 return NULL;
485 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
486 if(FAILED(hres)) {
487 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
488 IHTMLDocument2_Release(doc);
489 return NULL;
492 IHTMLDocument5_Release(doc5);
493 return doc;
496 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
497 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
499 const IID * const *piid;
500 IUnknown *unk;
501 HRESULT hres;
503 for(piid = iids; *piid; piid++) {
504 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
505 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
506 if(SUCCEEDED(hres))
507 IUnknown_Release(unk);
511 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
512 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
514 IDispatchEx *dispex;
515 ITypeInfo *typeinfo;
516 BOOL ret = FALSE;
517 UINT ticnt;
518 HRESULT hres;
520 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
521 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
522 if(FAILED(hres))
523 return FALSE;
525 ticnt = 0xdeadbeef;
526 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
527 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
528 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
530 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
531 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
533 if(SUCCEEDED(hres)) {
534 TYPEATTR *type_attr;
536 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
537 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
538 if(hres == S_OK) {
539 *iid = type_attr->guid;
540 ret = TRUE;
543 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
544 ITypeInfo_Release(typeinfo);
547 IDispatchEx_Release(dispex);
548 return ret;
551 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
552 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
554 DISPPARAMS dp = {NULL,NULL,0,0};
555 IDispatchEx *dispex;
556 EXCEPINFO ei;
557 VARIANT var;
558 HRESULT hres;
560 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
561 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
562 if(FAILED(hres))
563 return;
565 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
566 IDispatchEx_Release(dispex);
567 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
569 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
570 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
571 VariantClear(&var);
574 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
575 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
577 IID iid;
579 if(_test_get_dispid(line, unk, &iid))
580 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
582 if(val)
583 _test_disp_value(line, unk, val);
586 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
587 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
589 IID iid;
591 if(_test_get_dispid(line, unk, &iid))
592 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
593 "unexpected guid %s\n", dbgstr_guid(&iid));
595 if(val)
596 _test_disp_value(line, unk, val);
599 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
600 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
602 IHTMLElement *elem;
603 HRESULT hres;
605 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
606 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
607 return elem;
610 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
611 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
613 IHTMLElement2 *elem;
614 HRESULT hres;
616 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
617 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
618 return elem;
621 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
622 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
624 IHTMLElement3 *elem;
625 HRESULT hres;
627 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
628 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
629 return elem;
632 #define get_node_iface(u) _get_node_iface(__LINE__,u)
633 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
635 IHTMLDOMNode *node;
636 HRESULT hres;
638 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
639 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
640 return node;
643 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
644 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
646 IHTMLDOMNode2 *node;
647 HRESULT hres;
649 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
650 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
651 return node;
654 #define get_img_iface(u) _get_img_iface(__LINE__,u)
655 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
657 IHTMLImgElement *img;
658 HRESULT hres;
660 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
661 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
662 return img;
665 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
666 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
668 IHTMLAnchorElement *anchor;
669 HRESULT hres;
671 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
672 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
673 return anchor;
676 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
677 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
679 IHTMLTextAreaElement *textarea;
680 HRESULT hres;
682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
683 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
684 return textarea;
687 #define get_select_iface(u) _get_select_iface(__LINE__,u)
688 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
690 IHTMLSelectElement *select;
691 HRESULT hres;
693 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
694 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
695 return select;
698 #define get_form_iface(u) _get_form_iface(__LINE__,u)
699 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
701 IHTMLFormElement *form;
702 HRESULT hres;
704 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
705 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
706 return form;
709 #define get_text_iface(u) _get_text_iface(__LINE__,u)
710 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
712 IHTMLDOMTextNode *text;
713 HRESULT hres;
715 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
716 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
717 return text;
720 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
721 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
723 IHTMLCommentElement *comment;
724 HRESULT hres;
726 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
727 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
728 return comment;
731 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
732 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
734 IHTMLDOMNode *node = _get_node_iface(line, unk);
735 BSTR name;
736 HRESULT hres;
738 hres = IHTMLDOMNode_get_nodeName(node, &name);
739 IHTMLDOMNode_Release(node);
740 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
741 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
743 SysFreeString(name);
746 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
747 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
749 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
750 IDispatch *disp = (void*)0xdeadbeef;
751 IHTMLDocument2 *doc = NULL;
752 HRESULT hres;
754 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
755 IHTMLDOMNode2_Release(node);
756 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
758 if(disp) {
759 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
760 IDispatch_Release(disp);
761 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
764 return doc;
767 #define get_doc_window(d) _get_doc_window(__LINE__,d)
768 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
770 IHTMLWindow2 *window;
771 HRESULT hres;
773 window = NULL;
774 hres = IHTMLDocument2_get_parentWindow(doc, &window);
775 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
776 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
778 return window;
781 #define clone_node(n,d) _clone_node(__LINE__,n,d)
782 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
784 IHTMLDOMNode *node = _get_node_iface(line, unk);
785 IHTMLDOMNode *ret = NULL;
786 HRESULT hres;
788 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
789 IHTMLDOMNode_Release(node);
790 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
791 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
793 return ret;
797 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
798 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
800 IHTMLElement *elem = _get_elem_iface(line, unk);
801 BSTR tag;
802 HRESULT hres;
804 hres = IHTMLElement_get_tagName(elem, &tag);
805 IHTMLElement_Release(elem);
806 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
807 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
809 SysFreeString(tag);
812 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
813 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
815 _test_elem_tag(line, unk, elem_type_infos[type].tag);
816 _test_ifaces(line, unk, elem_type_infos[type].iids);
818 if(elem_type_infos[type].dispiid && type != ET_A)
819 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
822 #define get_node_type(n) _get_node_type(__LINE__,n)
823 static LONG _get_node_type(unsigned line, IUnknown *unk)
825 IHTMLDOMNode *node = _get_node_iface(line, unk);
826 LONG type = -1;
827 HRESULT hres;
829 hres = IHTMLDOMNode_get_nodeType(node, &type);
830 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
832 IHTMLDOMNode_Release(node);
834 return type;
837 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
838 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
840 IHTMLDOMNode *node = _get_node_iface(line, unk);
841 IHTMLDOMChildrenCollection *col = NULL;
842 IDispatch *disp;
843 HRESULT hres;
845 hres = IHTMLDOMNode_get_childNodes(node, &disp);
846 IHTMLDOMNode_Release(node);
847 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
848 if(FAILED(hres))
849 return NULL;
851 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
852 IDispatch_Release(disp);
853 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
855 return col;
858 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
859 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
861 IHTMLDOMNode *node = NULL;
862 IDispatch *disp;
863 HRESULT hres;
865 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
866 ok(hres == S_OK, "item failed: %08x\n", hres);
868 node = _get_node_iface(line, (IUnknown*)disp);
869 IDispatch_Release(disp);
871 return node;
874 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
875 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
877 VARIANT value;
878 BSTR tmp;
879 HRESULT hres;
881 VariantInit(&value);
883 tmp = a2bstr(name);
884 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
885 SysFreeString(tmp);
886 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
888 if(exval) {
889 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
890 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
891 }else {
892 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
895 VariantClear(&value);
898 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
899 static void _test_elem_offset(unsigned line, IUnknown *unk)
901 IHTMLElement *elem = _get_elem_iface(line, unk);
902 LONG l;
903 HRESULT hres;
905 hres = IHTMLElement_get_offsetTop(elem, &l);
906 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
908 hres = IHTMLElement_get_offsetHeight(elem, &l);
909 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
911 hres = IHTMLElement_get_offsetWidth(elem, &l);
912 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
914 IHTMLElement_Release(elem);
917 #define get_doc_node(d) _get_doc_node(__LINE__,d)
918 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
920 IHTMLWindow2 *window;
921 IHTMLDocument2 *ret;
922 HRESULT hres;
924 hres = IHTMLDocument2_get_parentWindow(doc, &window);
925 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
927 hres = IHTMLWindow2_get_document(window, &ret);
928 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
929 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
931 return ret;
934 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
935 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
937 BSTR name;
938 HRESULT hres;
940 hres = IHTMLWindow2_get_name(window, &name);
941 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
942 if(exname)
943 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
944 else
945 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
948 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
949 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
951 BSTR str;
952 HRESULT hres;
954 str = a2bstr(name);
955 hres = IHTMLWindow2_put_name(window, str);
956 SysFreeString(str);
957 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
959 _test_window_name(line, window, name);
962 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
963 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
965 LONG length = -1;
966 HRESULT hres;
968 hres = IHTMLWindow2_get_length(window, &length);
969 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
970 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
973 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
974 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
976 IHTMLFrameBase2 *base2;
977 IHTMLWindow2 *window;
978 HRESULT hres;
980 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
981 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
983 window = NULL;
984 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
985 IHTMLFrameBase2_Release(base2);
986 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
987 ok(window != NULL, "contentWindow = NULL\n");
989 return window;
992 static void test_get_set_attr(IHTMLDocument2 *doc)
994 IHTMLElement *elem;
995 IHTMLDocument3 *doc3;
996 HRESULT hres;
997 BSTR bstr;
998 VARIANT val;
1000 /* grab an element to test with */
1001 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1002 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1004 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1005 IHTMLDocument3_Release(doc3);
1006 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1008 /* get a non-present attribute */
1009 bstr = a2bstr("notAnAttribute");
1010 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1011 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1012 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1013 VariantClear(&val);
1014 SysFreeString(bstr);
1016 /* get a present attribute */
1017 bstr = a2bstr("scrollHeight");
1018 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1019 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1020 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1021 VariantClear(&val);
1022 SysFreeString(bstr);
1024 /* create a new BSTR attribute */
1025 bstr = a2bstr("newAttribute");
1027 V_VT(&val) = VT_BSTR;
1028 V_BSTR(&val) = a2bstr("the value");
1029 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1030 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1031 VariantClear(&val);
1033 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1034 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1035 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1036 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)));
1037 VariantClear(&val);
1039 /* overwrite the attribute with a BOOL */
1040 V_VT(&val) = VT_BOOL;
1041 V_BOOL(&val) = VARIANT_TRUE;
1042 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1043 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1044 VariantClear(&val);
1046 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1047 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1048 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1049 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1050 VariantClear(&val);
1052 SysFreeString(bstr);
1054 /* case-insensitive */
1055 bstr = a2bstr("newattribute");
1056 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1057 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1058 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1059 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1060 VariantClear(&val);
1061 SysFreeString(bstr);
1063 IHTMLElement_Release(elem);
1066 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1067 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1069 IHTMLElement *elem;
1070 IHTMLDocument3 *doc3;
1071 HRESULT hres;
1073 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1074 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1075 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1076 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1077 IHTMLDocument3_Release(doc3);
1079 return elem;
1082 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1083 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1085 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1086 BSTR str;
1087 HRESULT hres;
1089 hres = IHTMLAnchorElement_get_href(anchor, &str);
1090 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1091 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1092 SysFreeString(str);
1094 _test_disp_value(line, unk, exhref);
1097 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1098 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1100 BSTR bstr;
1101 HRESULT hres;
1103 hres = IHTMLOptionElement_get_text(option, &bstr);
1104 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1105 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1106 SysFreeString(bstr);
1109 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1110 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1112 BSTR bstr;
1113 HRESULT hres;
1115 bstr = a2bstr(text);
1116 hres = IHTMLOptionElement_put_text(option, bstr);
1117 SysFreeString(bstr);
1118 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1120 _test_option_text(line, option, text);
1123 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1124 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1126 BSTR bstr;
1127 HRESULT hres;
1129 hres = IHTMLOptionElement_get_value(option, &bstr);
1130 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1131 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1132 SysFreeString(bstr);
1135 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1136 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1138 BSTR bstr;
1139 HRESULT hres;
1141 bstr = a2bstr(value);
1142 hres = IHTMLOptionElement_put_value(option, bstr);
1143 SysFreeString(bstr);
1144 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1146 _test_option_value(line, option, value);
1149 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1150 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1152 VARIANT_BOOL b = 0x100;
1153 HRESULT hres;
1155 hres = IHTMLOptionElement_get_selected(option, &b);
1156 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1157 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1160 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1161 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1163 HRESULT hres;
1165 hres = IHTMLOptionElement_put_selected(option, b);
1166 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1167 _test_option_selected(line, option, b);
1170 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1171 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1173 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1174 BSTR value = (void*)0xdeadbeef;
1175 HRESULT hres;
1177 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1178 IHTMLTextAreaElement_Release(textarea);
1179 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1180 if(exval)
1181 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1182 else
1183 ok_(__FILE__,line)(!value, "value = %p\n", value);
1184 SysFreeString(value);
1187 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1188 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1190 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1191 BSTR tmp = a2bstr(value);
1192 HRESULT hres;
1194 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1195 IHTMLTextAreaElement_Release(textarea);
1196 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1197 SysFreeString(tmp);
1199 _test_textarea_value(line, unk, value);
1202 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1203 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1205 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1206 VARIANT_BOOL b = 0x100;
1207 HRESULT hres;
1209 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1210 IHTMLTextAreaElement_Release(textarea);
1211 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1212 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1215 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1216 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1218 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1219 HRESULT hres;
1221 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1222 IHTMLTextAreaElement_Release(textarea);
1223 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1225 _test_textarea_readonly(line, unk, b);
1228 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1229 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1231 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1232 BSTR text;
1233 HRESULT hres;
1235 text = a2bstr(extext);
1236 hres = IHTMLCommentElement_get_text(comment, &text);
1237 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1238 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1240 IHTMLCommentElement_Release(comment);
1241 SysFreeString(text);
1244 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1245 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1246 const char *txt, const char *val)
1248 IHTMLOptionElementFactory *factory;
1249 IHTMLOptionElement *option;
1250 IHTMLWindow2 *window;
1251 VARIANT text, value, empty;
1252 HRESULT hres;
1254 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1255 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1257 hres = IHTMLWindow2_get_Option(window, &factory);
1258 IHTMLWindow2_Release(window);
1259 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1261 V_VT(&text) = VT_BSTR;
1262 V_BSTR(&text) = a2bstr(txt);
1263 V_VT(&value) = VT_BSTR;
1264 V_BSTR(&value) = a2bstr(val);
1265 V_VT(&empty) = VT_EMPTY;
1267 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1268 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1270 IHTMLOptionElementFactory_Release(factory);
1271 VariantClear(&text);
1272 VariantClear(&value);
1274 _test_option_text(line, option, txt);
1275 _test_option_value(line, option, val);
1276 _test_option_selected(line, option, VARIANT_FALSE);
1278 return option;
1281 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1282 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1284 LONG found = -1;
1285 HRESULT hres;
1287 hres = IHTMLImgElement_get_width(img, &found);
1288 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1289 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1292 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1293 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1295 HRESULT hres;
1297 hres = IHTMLImgElement_put_width(img, width);
1298 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1300 _test_img_width(line, img, width);
1303 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1304 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1306 LONG found = -1;
1307 HRESULT hres;
1309 hres = IHTMLImgElement_get_height(img, &found);
1310 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1311 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1314 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1315 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1317 HRESULT hres;
1319 hres = IHTMLImgElement_put_height(img, height);
1320 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1322 _test_img_height(line, img, height);
1325 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1326 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1327 LONG wdth, LONG hght)
1329 IHTMLImageElementFactory *factory;
1330 IHTMLImgElement *img;
1331 IHTMLWindow2 *window;
1332 VARIANT width, height;
1333 char buf[16];
1334 HRESULT hres;
1336 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1337 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1339 hres = IHTMLWindow2_get_Image(window, &factory);
1340 IHTMLWindow2_Release(window);
1341 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1343 test_ifaces((IUnknown*)factory, img_factory_iids);
1344 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1346 if(wdth >= 0){
1347 snprintf(buf, 16, "%d", wdth);
1348 V_VT(&width) = VT_BSTR;
1349 V_BSTR(&width) = a2bstr(buf);
1350 }else{
1351 V_VT(&width) = VT_EMPTY;
1352 wdth = 0;
1355 if(hght >= 0){
1356 snprintf(buf, 16, "%d", hght);
1357 V_VT(&height) = VT_BSTR;
1358 V_BSTR(&height) = a2bstr(buf);
1359 }else{
1360 V_VT(&height) = VT_EMPTY;
1361 hght = 0;
1364 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1365 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1367 IHTMLImageElementFactory_Release(factory);
1368 VariantClear(&width);
1369 VariantClear(&height);
1371 if(SUCCEEDED(hres)) {
1372 _test_img_width(line, img, wdth);
1373 _test_img_height(line, img, hght);
1374 return img;
1377 return NULL;
1380 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1381 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1383 LONG len = 0xdeadbeef;
1384 HRESULT hres;
1386 hres = IHTMLSelectElement_get_length(select, &len);
1387 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1388 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1391 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1392 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1394 IHTMLSelectElement *select = _get_select_iface(line, unk);
1395 HRESULT hres;
1397 hres = IHTMLSelectElement_put_length(select, length);
1398 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1399 _test_select_length(line, select, length);
1400 IHTMLSelectElement_Release(select);
1403 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1404 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1406 LONG idx = 0xdeadbeef;
1407 HRESULT hres;
1409 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1410 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1411 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1414 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1415 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1417 HRESULT hres;
1419 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1420 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1421 _test_select_selidx(line, select, index);
1424 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1425 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1427 BSTR val;
1428 HRESULT hres;
1430 hres = IHTMLSelectElement_get_value(select, &val);
1431 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1432 if(exval)
1433 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1434 else
1435 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1438 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1439 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1441 BSTR bstr;
1442 HRESULT hres;
1444 bstr = a2bstr(val);
1445 hres = IHTMLSelectElement_put_value(select, bstr);
1446 SysFreeString(bstr);
1447 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1450 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1451 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1453 BSTR type;
1454 HRESULT hres;
1456 hres = IHTMLSelectElement_get_type(select, &type);
1457 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1458 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1461 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1462 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1464 BSTR text;
1465 HRESULT hres;
1467 hres = IHTMLTxtRange_get_text(range, &text);
1468 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1470 if(extext) {
1471 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1472 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1473 }else {
1474 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1477 SysFreeString(text);
1481 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1482 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1484 HRESULT hres;
1486 hres = IHTMLTxtRange_collapse(range, b);
1487 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1488 _test_range_text(line, range, NULL);
1491 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1492 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1493 VARIANT_BOOL exb, const char *extext)
1495 VARIANT_BOOL b = 0xe0e0;
1496 HRESULT hres;
1498 hres = IHTMLTxtRange_expand(range, unit, &b);
1499 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1500 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1501 _test_range_text(line, range, extext);
1504 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1505 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1507 LONG c = 0xdeadbeef;
1508 HRESULT hres;
1510 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1511 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1512 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1513 _test_range_text(line, range, NULL);
1516 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1517 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1518 LPWSTR unit, LONG cnt, LONG excnt)
1520 LONG c = 0xdeadbeef;
1521 HRESULT hres;
1523 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1524 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1525 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1528 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1529 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1531 LONG c = 0xdeadbeef;
1532 HRESULT hres;
1534 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1535 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1536 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1539 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1540 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1542 HRESULT hres;
1543 BSTR bstr = a2bstr(text);
1545 hres = IHTMLTxtRange_put_text(range, bstr);
1546 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1547 SysFreeString(bstr);
1548 _test_range_text(line, range, NULL);
1551 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1552 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1554 VARIANT_BOOL b;
1555 HRESULT hres;
1557 b = 0xe0e0;
1558 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1559 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1560 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1563 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1564 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1566 VARIANT_BOOL b;
1567 HRESULT hres;
1569 b = 0xe0e0;
1570 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1571 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1572 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1574 b = 0xe0e0;
1575 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1576 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1577 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1579 if(exb) {
1580 test_range_inrange(range1, range2, VARIANT_TRUE);
1581 test_range_inrange(range2, range1, VARIANT_TRUE);
1585 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1586 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1588 IHTMLElement *elem;
1589 HRESULT hres;
1591 hres = IHTMLTxtRange_parentElement(range, &elem);
1592 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1594 _test_elem_type(line, (IUnknown*)elem, type);
1596 IHTMLElement_Release(elem);
1599 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1600 static void _test_elem_collection(unsigned line, IUnknown *unk,
1601 const elem_type_t *elem_types, LONG exlen)
1603 IHTMLElementCollection *col;
1604 LONG len;
1605 DWORD i;
1606 VARIANT name, index;
1607 IDispatch *disp, *disp2;
1608 HRESULT hres;
1610 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1611 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1613 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1615 hres = IHTMLElementCollection_get_length(col, &len);
1616 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1617 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1619 if(len > exlen)
1620 len = exlen;
1622 V_VT(&index) = VT_EMPTY;
1624 for(i=0; i<len; i++) {
1625 V_VT(&name) = VT_I4;
1626 V_I4(&name) = i;
1627 disp = (void*)0xdeadbeef;
1628 hres = IHTMLElementCollection_item(col, name, index, &disp);
1629 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1630 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1631 if(FAILED(hres) || !disp)
1632 continue;
1634 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1636 if(!i) {
1637 V_VT(&name) = VT_UINT;
1638 V_I4(&name) = 0;
1639 disp2 = (void*)0xdeadbeef;
1640 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1641 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1642 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1643 if(disp2)
1644 IDispatch_Release(disp2);
1647 IDispatch_Release(disp);
1650 V_VT(&name) = VT_I4;
1651 V_I4(&name) = len;
1652 disp = (void*)0xdeadbeef;
1653 hres = IHTMLElementCollection_item(col, name, index, &disp);
1654 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1655 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1657 V_VT(&name) = VT_I4;
1658 V_I4(&name) = -1;
1659 disp = (void*)0xdeadbeef;
1660 hres = IHTMLElementCollection_item(col, name, index, &disp);
1661 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1662 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1664 IHTMLElementCollection_Release(col);
1667 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1668 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1670 IHTMLElement *elem = _get_elem_iface(line, unk);
1671 IDispatch *disp;
1672 HRESULT hres;
1674 hres = IHTMLElement_get_all(elem, &disp);
1675 IHTMLElement_Release(elem);
1676 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1678 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1679 IDispatch_Release(disp);
1682 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1683 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1685 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1686 IHTMLElementCollection *col = NULL;
1687 elem_type_t *types = NULL;
1688 BSTR tmp;
1689 int i;
1690 HRESULT hres;
1692 tmp = a2bstr(elem_type_infos[type].tag);
1693 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1694 SysFreeString(tmp);
1695 IHTMLElement2_Release(elem);
1696 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1697 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1699 if(exlen) {
1700 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1701 for(i=0; i<exlen; i++)
1702 types[i] = type;
1705 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1707 HeapFree(GetProcessHeap(), 0, types);
1710 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1711 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1713 BSTR text = NULL;
1714 HRESULT hres;
1716 hres = IHTMLElement_get_innerText(elem, &text);
1717 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1718 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1719 wine_dbgstr_w(text), extext);
1720 SysFreeString(text);
1723 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1724 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1726 IHTMLDOMChildrenCollection *col;
1727 BSTR str;
1728 HRESULT hres;
1730 str = a2bstr(text);
1731 hres = IHTMLElement_put_innerText(elem, str);
1732 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1733 SysFreeString(str);
1735 _test_elem_innertext(line, elem, text);
1738 col = _get_child_nodes(line, (IUnknown*)elem);
1739 ok(col != NULL, "col == NULL\n");
1740 if(col) {
1741 LONG length = 0, type;
1742 IHTMLDOMNode *node;
1744 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1745 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1746 ok(length == 1, "length = %d\n", length);
1748 node = _get_child_item(line, col, 0);
1749 ok(node != NULL, "node == NULL\n");
1750 if(node) {
1751 type = _get_node_type(line, (IUnknown*)node);
1752 ok(type == 3, "type=%d\n", type);
1753 IHTMLDOMNode_Release(node);
1756 IHTMLDOMChildrenCollection_Release(col);
1761 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1762 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1764 IHTMLElement *elem = _get_elem_iface(line, unk);
1765 BSTR html;
1766 HRESULT hres;
1768 hres = IHTMLElement_get_innerHTML(elem, &html);
1769 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1770 if(inner_html)
1771 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1772 else
1773 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1775 IHTMLElement_Release(elem);
1776 SysFreeString(html);
1779 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1780 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1782 IHTMLElement *elem = _get_elem_iface(line, unk);
1783 BSTR html;
1784 HRESULT hres;
1786 html = a2bstr(inner_html);
1787 hres = IHTMLElement_put_innerHTML(elem, html);
1788 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1790 IHTMLElement_Release(elem);
1791 SysFreeString(html);
1794 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1795 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1797 IHTMLElement *elem = _get_elem_iface(line, unk);
1798 BSTR html;
1799 HRESULT hres;
1801 html = a2bstr(outer_html);
1802 hres = IHTMLElement_put_outerHTML(elem, html);
1803 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1805 IHTMLElement_Release(elem);
1806 SysFreeString(html);
1809 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1810 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1812 IHTMLElement *elem = _get_elem_iface(line, unk);
1813 BSTR html;
1814 HRESULT hres;
1816 hres = IHTMLElement_get_outerHTML(elem, &html);
1817 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1818 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1820 IHTMLElement_Release(elem);
1821 SysFreeString(html);
1824 #define get_first_child(n) _get_first_child(__LINE__,n)
1825 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1827 IHTMLDOMNode *node = _get_node_iface(line, unk);
1828 IHTMLDOMNode *child = NULL;
1829 HRESULT hres;
1831 hres = IHTMLDOMNode_get_firstChild(node, &child);
1832 IHTMLDOMNode_Release(node);
1833 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1835 return child;
1838 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1839 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1841 IHTMLDOMNode *node = _get_node_iface(line, unk);
1842 VARIANT_BOOL b = 0xdead;
1843 HRESULT hres;
1845 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1846 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1847 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1849 IHTMLDOMNode_Release(node);
1852 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1853 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1855 IHTMLDOMNode *node = _get_node_iface(line, unk);
1856 IHTMLDOMNode *parent;
1857 HRESULT hres;
1859 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1860 IHTMLDOMNode_Release(node);
1861 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1863 return parent;
1866 #define node_get_next(u) _node_get_next(__LINE__,u)
1867 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1869 IHTMLDOMNode *node = _get_node_iface(line, unk);
1870 IHTMLDOMNode *next;
1871 HRESULT hres;
1873 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1874 IHTMLDOMNode_Release(node);
1875 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1877 return next;
1880 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1881 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1883 IHTMLElement *elem = _get_elem_iface(line, unk);
1884 IHTMLElement *parent;
1885 HRESULT hres;
1887 hres = IHTMLElement_get_parentElement(elem, &parent);
1888 IHTMLElement_Release(elem);
1889 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1891 return parent;
1894 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1895 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1897 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1898 VARIANT_BOOL disabled = 100;
1899 HRESULT hres;
1901 if (!elem3) return;
1902 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1903 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1904 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1905 IHTMLElement3_Release(elem3);
1908 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1909 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1911 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1912 HRESULT hres;
1914 if (!elem3) return;
1915 hres = IHTMLElement3_put_disabled(elem3, b);
1916 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1918 IHTMLElement3_Release(elem3);
1919 _test_elem3_get_disabled(line, unk, b);
1922 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1923 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1925 VARIANT_BOOL disabled = 100;
1926 HRESULT hres;
1928 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1929 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1930 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1932 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1935 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1936 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1938 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
1939 LONG length;
1940 HRESULT hres;
1942 hres = IHTMLDOMTextNode_get_length(text, &length);
1943 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1944 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
1945 IHTMLDOMTextNode_Release(text);
1948 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1949 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1951 HRESULT hres;
1953 hres = IHTMLSelectElement_put_disabled(select, b);
1954 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1956 _test_select_get_disabled(line, select, b);
1959 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1960 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1962 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1963 IHTMLTextContainer *txtcont;
1964 LONG l = -1, l2 = -1;
1965 HRESULT hres;
1967 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1968 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1969 IHTMLElement2_Release(elem);
1971 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1972 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1974 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1975 IHTMLTextContainer_Release(txtcont);
1976 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1977 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1979 return l;
1982 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1983 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1985 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1986 IHTMLTextContainer *txtcont;
1987 LONG l = -1, l2 = -1;
1988 HRESULT hres;
1990 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1991 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1992 IHTMLElement2_Release(elem);
1994 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1995 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1997 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1998 IHTMLTextContainer_Release(txtcont);
1999 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2000 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2002 return l;
2005 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2006 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2008 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2009 IHTMLTextContainer *txtcont;
2010 LONG l = -1, l2 = -1;
2011 HRESULT hres;
2013 hres = IHTMLElement2_get_scrollTop(elem, &l);
2014 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2015 IHTMLElement2_Release(elem);
2017 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2018 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2020 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2021 IHTMLTextContainer_Release(txtcont);
2022 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2023 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2025 return l;
2028 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2029 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2031 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2032 IHTMLTextContainer *txtcont;
2033 LONG l = -1, l2 = -1;
2034 HRESULT hres;
2036 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2037 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2039 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2040 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2041 IHTMLElement2_Release(elem);
2043 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2044 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2046 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2047 IHTMLTextContainer_Release(txtcont);
2048 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2049 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2052 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2053 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2055 IHTMLImgElement *img = _get_img_iface(line, unk);
2056 BSTR src;
2057 HRESULT hres;
2059 hres = IHTMLImgElement_get_src(img, &src);
2060 IHTMLImgElement_Release(img);
2061 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2062 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2063 SysFreeString(src);
2066 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2067 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2069 IHTMLImgElement *img = _get_img_iface(line, unk);
2070 BSTR tmp;
2071 HRESULT hres;
2073 tmp = a2bstr(src);
2074 hres = IHTMLImgElement_put_src(img, tmp);
2075 IHTMLImgElement_Release(img);
2076 SysFreeString(tmp);
2077 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2079 _test_img_src(line, unk, src);
2082 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2083 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2085 IHTMLImgElement *img = _get_img_iface(line, unk);
2086 BSTR alt;
2087 HRESULT hres;
2089 hres = IHTMLImgElement_get_alt(img, &alt);
2090 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2091 if(exalt)
2092 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2093 else
2094 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2095 SysFreeString(alt);
2098 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2099 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2101 IHTMLImgElement *img = _get_img_iface(line, unk);
2102 BSTR tmp;
2103 HRESULT hres;
2105 tmp = a2bstr(alt);
2106 hres = IHTMLImgElement_put_alt(img, tmp);
2107 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2108 SysFreeString(tmp);
2110 _test_img_alt(line, unk, alt);
2113 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2114 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2116 IHTMLImgElement *img = _get_img_iface(line, unk);
2117 BSTR sName;
2118 HRESULT hres;
2120 hres = IHTMLImgElement_get_name(img, &sName);
2121 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2122 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2123 IHTMLImgElement_Release(img);
2124 SysFreeString(sName);
2127 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2128 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2130 BSTR type;
2131 HRESULT hres;
2133 hres = IHTMLInputElement_get_type(input, &type);
2134 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2135 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2136 SysFreeString(type);
2139 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2140 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2142 BSTR name = (BSTR)0xdeadbeef;
2143 HRESULT hres;
2145 hres = IHTMLInputElement_get_name(input, &name);
2146 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2147 if(exname)
2148 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2149 else
2150 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2151 SysFreeString(name);
2154 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2155 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2157 BSTR tmp = a2bstr(name);
2158 HRESULT hres;
2160 hres = IHTMLInputElement_put_name(input, tmp);
2161 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2162 SysFreeString(tmp);
2164 _test_input_name(line, input, name);
2167 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2168 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2170 VARIANT_BOOL disabled = 100;
2171 HRESULT hres;
2173 hres = IHTMLInputElement_get_disabled(input, &disabled);
2174 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2175 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2177 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2180 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2181 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2183 HRESULT hres;
2185 hres = IHTMLInputElement_put_disabled(input, b);
2186 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2188 _test_input_get_disabled(line, input, b);
2191 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2192 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2194 VARIANT_BOOL checked = 100;
2195 HRESULT hres;
2197 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2198 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2199 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2202 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2203 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2205 HRESULT hres;
2207 hres = IHTMLInputElement_put_defaultChecked(input, b);
2208 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2210 _test_input_get_defaultchecked(line, input, b);
2213 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2214 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2216 VARIANT_BOOL checked = 100;
2217 HRESULT hres;
2219 hres = IHTMLInputElement_get_checked(input, &checked);
2220 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2221 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2224 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2225 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2227 HRESULT hres;
2229 hres = IHTMLInputElement_put_checked(input, b);
2230 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2232 _test_input_get_checked(line, input, b);
2235 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2236 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2238 IHTMLInputElement *input;
2239 BSTR bstr;
2240 HRESULT hres;
2242 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2243 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2244 if(FAILED(hres))
2245 return;
2247 hres = IHTMLInputElement_get_value(input, &bstr);
2248 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2249 if(exval)
2250 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2251 else
2252 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2253 SysFreeString(bstr);
2254 IHTMLInputElement_Release(input);
2257 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2258 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2260 IHTMLInputElement *input;
2261 BSTR bstr;
2262 HRESULT hres;
2264 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2265 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2266 if(FAILED(hres))
2267 return;
2269 bstr = a2bstr(val);
2270 hres = IHTMLInputElement_get_value(input, &bstr);
2271 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2272 SysFreeString(bstr);
2273 IHTMLInputElement_Release(input);
2276 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2277 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2279 BSTR src;
2280 HRESULT hres;
2282 hres = IHTMLInputElement_get_src(input, &src);
2283 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2284 if(exsrc)
2285 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2286 else
2287 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2288 SysFreeString(src);
2291 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2292 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2294 BSTR tmp;
2295 HRESULT hres;
2297 tmp = a2bstr(src);
2298 hres = IHTMLInputElement_put_src(input, tmp);
2299 SysFreeString(tmp);
2300 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2302 _test_input_src(line, input, src);
2305 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2306 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2308 IHTMLElement *elem = _get_elem_iface(line, unk);
2309 BSTR class = (void*)0xdeadbeef;
2310 HRESULT hres;
2312 hres = IHTMLElement_get_className(elem, &class);
2313 IHTMLElement_Release(elem);
2314 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2315 if(exclass)
2316 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2317 else
2318 ok_(__FILE__,line) (!class, "class != NULL\n");
2319 SysFreeString(class);
2322 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2323 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2325 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2326 short index = -3;
2327 HRESULT hres;
2329 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2330 IHTMLElement2_Release(elem2);
2331 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2332 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2335 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2336 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2338 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2339 HRESULT hres;
2341 hres = IHTMLElement2_put_tabIndex(elem2, index);
2342 IHTMLElement2_Release(elem2);
2343 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2345 _test_elem_tabindex(line, unk, index);
2348 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2349 static void _test_elem_filters(unsigned line, IUnknown *unk)
2351 IHTMLElement *elem = _get_elem_iface(line, unk);
2352 HRESULT hres;
2353 IHTMLFiltersCollection *filters;
2355 hres = IHTMLElement_get_filters(elem, &filters);
2356 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2357 "get_filters failed: %08x\n", hres);
2358 if(hres == S_OK)
2360 LONG len;
2361 IDispatchEx *dispex;
2363 hres = IHTMLFiltersCollection_get_length(filters, &len);
2364 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2365 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2367 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2368 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2369 "Could not get IDispatchEx interface: %08x\n", hres);
2370 if(SUCCEEDED(hres)) {
2371 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2372 IDispatchEx_Release(dispex);
2375 IHTMLFiltersCollection_Release(filters);
2378 IHTMLElement_Release(elem);
2381 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2382 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2384 IHTMLElement *elem = _get_elem_iface(line, unk);
2385 BSTR tmp;
2386 HRESULT hres;
2388 tmp = class ? a2bstr(class) : NULL;
2389 hres = IHTMLElement_put_className(elem, tmp);
2390 IHTMLElement_Release(elem);
2391 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2392 SysFreeString(tmp);
2394 _test_elem_class(line, unk, class);
2397 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2398 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2400 IHTMLElement *elem = _get_elem_iface(line, unk);
2401 BSTR id = (void*)0xdeadbeef;
2402 HRESULT hres;
2404 hres = IHTMLElement_get_id(elem, &id);
2405 IHTMLElement_Release(elem);
2406 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2408 if(exid)
2409 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2410 else
2411 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2413 SysFreeString(id);
2416 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2417 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2419 IHTMLElement *elem = _get_elem_iface(line, unk);
2420 BSTR tmp = a2bstr(new_id);
2421 HRESULT hres;
2423 hres = IHTMLElement_put_id(elem, tmp);
2424 IHTMLElement_Release(elem);
2425 SysFreeString(tmp);
2426 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2428 _test_elem_id(line, unk, new_id);
2431 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2432 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2434 IHTMLElement *elem = _get_elem_iface(line, unk);
2435 BSTR title;
2436 HRESULT hres;
2438 hres = IHTMLElement_get_title(elem, &title);
2439 IHTMLElement_Release(elem);
2440 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2441 if(extitle)
2442 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2443 else
2444 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2446 SysFreeString(title);
2449 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2450 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2452 IHTMLElement *elem = _get_elem_iface(line, unk);
2453 BSTR tmp;
2454 HRESULT hres;
2456 tmp = a2bstr(title);
2457 hres = IHTMLElement_put_title(elem, tmp);
2458 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2460 IHTMLElement_Release(elem);
2461 SysFreeString(tmp);
2464 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2465 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2467 IHTMLDOMNode *node = _get_node_iface(line, unk);
2468 VARIANT var;
2469 HRESULT hres;
2471 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2472 IHTMLDOMNode_Release(node);
2473 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2475 if(exval) {
2476 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2477 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2478 }else {
2479 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2482 VariantClear(&var);
2485 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2486 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2488 IHTMLDOMNode *node = _get_node_iface(line, unk);
2489 VARIANT var;
2490 HRESULT hres;
2492 V_VT(&var) = VT_BSTR;
2493 V_BSTR(&var) = a2bstr(val);
2495 hres = IHTMLDOMNode_put_nodeValue(node, var);
2496 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2497 IHTMLDOMNode_Release(node);
2498 VariantClear(&var);
2501 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2502 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2504 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2505 LONG l;
2506 HRESULT hres;
2508 hres = IHTMLElement2_get_clientWidth(elem, &l);
2509 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2510 hres = IHTMLElement2_get_clientHeight(elem, &l);
2511 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2513 IHTMLElement2_Release(elem);
2516 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2517 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2519 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2520 LONG l;
2521 HRESULT hres;
2523 hres = IHTMLElement2_get_clientLeft(elem, &l);
2524 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2525 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2527 hres = IHTMLElement2_get_clientTop(elem, &l);
2528 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2529 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2531 IHTMLElement2_Release(elem);
2534 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2535 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2537 IHTMLFormElement *form = _get_form_iface(line, unk);
2538 LONG len = 0xdeadbeef;
2539 HRESULT hres;
2541 hres = IHTMLFormElement_get_length(form, &len);
2542 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2543 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2545 IHTMLFormElement_Release(form);
2548 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2549 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2551 IHTMLFormElement *form = _get_form_iface(line, unk);
2552 BSTR action = (void*)0xdeadbeef;
2553 HRESULT hres;
2555 hres = IHTMLFormElement_get_action(form, &action);
2556 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2557 if(ex)
2558 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2559 else
2560 ok_(__FILE__,line)(!action, "action=%p\n", action);
2562 IHTMLFormElement_Release(form);
2565 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2566 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2568 IHTMLFormElement *form = _get_form_iface(line, unk);
2569 BSTR tmp = a2bstr(action);
2570 HRESULT hres;
2572 hres = IHTMLFormElement_put_action(form, tmp);
2573 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2574 SysFreeString(tmp);
2575 IHTMLFormElement_Release(form);
2577 _test_form_action(line, unk, action);
2580 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2581 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2583 IHTMLElement *elem = _get_elem_iface(line, unk);
2584 IHTMLDocument2 *doc;
2585 IDispatch *disp;
2586 HRESULT hres;
2588 disp = NULL;
2589 hres = IHTMLElement_get_document(elem, &disp);
2590 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2591 ok(disp != NULL, "disp == NULL\n");
2593 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2594 IDispatch_Release(disp);
2595 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2597 return doc;
2600 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2601 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2603 IHTMLDocument2 *doc;
2604 HRESULT hres;
2606 doc = NULL;
2607 hres = IHTMLWindow2_get_document(window, &doc);
2608 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2609 ok(doc != NULL, "disp == NULL\n");
2611 return doc;
2614 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2615 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2617 IHTMLElement *elem = NULL;
2618 BSTR tmp;
2619 HRESULT hres;
2621 tmp = a2bstr(tag);
2622 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2623 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2624 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2626 return elem;
2629 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2630 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2632 IHTMLDocument3 *doc3;
2633 IHTMLDOMNode *node = NULL;
2634 BSTR tmp;
2635 HRESULT hres;
2637 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2638 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2640 tmp = a2bstr(text);
2641 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2642 IHTMLDocument3_Release(doc3);
2643 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2644 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2646 return node;
2649 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2650 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2652 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2653 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2654 IHTMLDOMNode *new_child = NULL;
2655 HRESULT hres;
2657 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2658 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2659 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2660 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2662 IHTMLDOMNode_Release(node);
2663 IHTMLDOMNode_Release(child);
2665 return new_child;
2668 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2669 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2671 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2672 IHTMLDOMNode *new_child = NULL;
2673 HRESULT hres;
2675 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2676 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2677 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2678 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2680 IHTMLDOMNode_Release(node);
2682 return new_child;
2685 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2686 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2688 IHTMLDOMNode *node = _get_node_iface(line, unk);
2689 IHTMLDOMNode *new_node = NULL;
2690 HRESULT hres;
2692 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2693 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2694 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2695 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2697 IHTMLDOMNode_Release(node);
2698 IHTMLDOMNode_Release(new_node);
2701 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2702 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2704 BSTR title = NULL;
2705 HRESULT hres;
2707 hres = IHTMLDocument2_get_title(doc, &title);
2708 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2709 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2710 SysFreeString(title);
2713 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2714 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2716 BSTR tmp;
2717 HRESULT hres;
2719 tmp = a2bstr(title);
2720 hres = IHTMLDocument2_put_title(doc, tmp);
2721 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2722 SysFreeString(tmp);
2725 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2726 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2728 HRESULT hres;
2729 DISPID dispid;
2731 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2732 LOCALE_USER_DEFAULT, &dispid);
2733 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2734 if(hres == S_OK)
2736 DISPPARAMS params = {NULL,NULL,0,0};
2737 DISPID dispidNamed = DISPID_PROPERTYPUT;
2738 VARIANT ret;
2739 VARIANT vDefault;
2740 VARIANTARG arg;
2742 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2743 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2744 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2746 params.cArgs = 1;
2747 params.cNamedArgs = 1;
2748 params.rgdispidNamedArgs = &dispidNamed;
2749 V_VT(&arg) = VT_BSTR;
2750 V_BSTR(&arg) = a2bstr("none");
2751 params.rgvarg = &arg;
2752 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2753 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2754 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2755 VariantClear(&arg);
2757 V_VT(&arg) = VT_BSTR;
2758 V_BSTR(&arg) = a2bstr("dotted");
2759 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2760 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2761 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2762 VariantClear(&arg);
2764 V_VT(&arg) = VT_BSTR;
2765 V_BSTR(&arg) = a2bstr("dashed");
2766 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2767 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2768 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2769 VariantClear(&arg);
2771 V_VT(&arg) = VT_BSTR;
2772 V_BSTR(&arg) = a2bstr("solid");
2773 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2774 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2775 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2776 VariantClear(&arg);
2778 V_VT(&arg) = VT_BSTR;
2779 V_BSTR(&arg) = a2bstr("double");
2780 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2781 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2782 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2783 VariantClear(&arg);
2785 V_VT(&arg) = VT_BSTR;
2786 V_BSTR(&arg) = a2bstr("groove");
2787 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2788 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2789 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2790 VariantClear(&arg);
2792 V_VT(&arg) = VT_BSTR;
2793 V_BSTR(&arg) = a2bstr("ridge");
2794 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2795 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2796 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2797 VariantClear(&arg);
2799 V_VT(&arg) = VT_BSTR;
2800 V_BSTR(&arg) = a2bstr("inset");
2801 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2802 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2803 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2804 VariantClear(&arg);
2806 V_VT(&arg) = VT_BSTR;
2807 V_BSTR(&arg) = a2bstr("outset");
2808 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2809 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2810 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2811 VariantClear(&arg);
2813 V_VT(&arg) = VT_BSTR;
2814 V_BSTR(&arg) = a2bstr("invalid");
2815 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2816 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2817 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2818 VariantClear(&arg);
2820 params.rgvarg = &vDefault;
2821 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2822 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2823 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2827 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2828 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2830 BSTR text = (void*)0xdeadbeef;
2831 HRESULT hres;
2833 hres = IHTMLStyle_get_cssText(style, &text);
2834 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2835 if(extext)
2836 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2837 else
2838 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2840 SysFreeString(text);
2843 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2844 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2846 BSTR tmp;
2847 HRESULT hres;
2849 tmp = a2bstr(text);
2850 hres = IHTMLStyle_put_cssText(style, tmp);
2851 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2852 SysFreeString(tmp);
2855 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2856 const elem_type_t *elem_types, LONG len)
2858 IDispatch *disp;
2859 VARIANT name, index;
2860 DWORD i;
2861 HRESULT hres;
2863 V_VT(&index) = VT_EMPTY;
2864 V_VT(&name) = VT_BSTR;
2865 V_BSTR(&name) = a2bstr(n);
2867 hres = IHTMLElementCollection_item(col, name, index, &disp);
2868 ok(hres == S_OK, "item failed: %08x\n", hres);
2870 test_elem_collection((IUnknown*)disp, elem_types, len);
2871 IDispatch_Release(disp);
2872 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2873 if(hres != S_OK)
2874 goto cleanup;
2876 V_VT(&index) = VT_I4;
2878 for(i=0; i<len; i++) {
2879 V_I4(&index) = i;
2880 disp = (void*)0xdeadbeef;
2881 hres = IHTMLElementCollection_item(col, name, index, &disp);
2882 ok(hres == S_OK, "item failed: %08x\n", hres);
2883 ok(disp != NULL, "disp == NULL\n");
2884 if(FAILED(hres) || !disp)
2885 continue;
2887 test_elem_type((IUnknown*)disp, elem_types[i]);
2889 IDispatch_Release(disp);
2892 V_I4(&index) = len;
2893 disp = (void*)0xdeadbeef;
2894 hres = IHTMLElementCollection_item(col, name, index, &disp);
2895 ok(hres == S_OK, "item failed: %08x\n", hres);
2896 ok(disp == NULL, "disp != NULL\n");
2898 V_I4(&index) = -1;
2899 disp = (void*)0xdeadbeef;
2900 hres = IHTMLElementCollection_item(col, name, index, &disp);
2901 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2902 ok(disp == NULL, "disp != NULL\n");
2904 cleanup:
2905 SysFreeString(V_BSTR(&name));
2908 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2910 IHTMLElementCollection *col;
2911 IHTMLElement *elem;
2912 IDispatch *disp = (void*)0xdeadbeef;
2913 VARIANT name, index;
2914 HRESULT hres;
2916 hres = IHTMLDocument2_get_all(doc, &col);
2917 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2918 ok(col != NULL, "col == NULL\n");
2919 if(FAILED(hres) || !col)
2920 return NULL;
2922 V_VT(&index) = VT_EMPTY;
2923 V_VT(&name) = VT_BSTR;
2924 V_BSTR(&name) = a2bstr(id);
2926 hres = IHTMLElementCollection_item(col, name, index, &disp);
2927 IHTMLElementCollection_Release(col);
2928 SysFreeString(V_BSTR(&name));
2929 ok(hres == S_OK, "item failed: %08x\n", hres);
2930 if(!expect_success) {
2931 ok(disp == NULL, "disp != NULL\n");
2932 return NULL;
2935 ok(disp != NULL, "disp == NULL\n");
2936 if(!disp)
2937 return NULL;
2939 elem = get_elem_iface((IUnknown*)disp);
2940 IDispatch_Release(disp);
2942 return elem;
2945 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2947 IHTMLDocument3 *doc3;
2948 IHTMLElement *elem;
2949 BSTR tmp;
2950 HRESULT hres;
2952 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2953 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2955 tmp = a2bstr(id);
2956 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2957 SysFreeString(tmp);
2958 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2960 IHTMLDocument3_Release(doc3);
2962 return elem;
2965 static void test_select_elem(IHTMLSelectElement *select)
2967 IDispatch *disp, *disp2;
2968 VARIANT name, index;
2969 HRESULT hres;
2971 test_select_type(select, "select-one");
2972 test_select_length(select, 2);
2973 test_select_selidx(select, 0);
2974 test_select_put_selidx(select, 1);
2976 test_select_set_value(select, "val1");
2977 test_select_value(select, "val1");
2979 test_select_get_disabled(select, VARIANT_FALSE);
2980 test_select_set_disabled(select, VARIANT_TRUE);
2981 test_select_set_disabled(select, VARIANT_FALSE);
2983 disp = NULL;
2984 hres = IHTMLSelectElement_get_options(select, &disp);
2985 ok(hres == S_OK, "get_options failed: %08x\n", hres);
2986 ok(disp != NULL, "options == NULL\n");
2987 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
2988 IDispatch_Release(disp);
2990 V_VT(&index) = VT_EMPTY;
2991 V_VT(&name) = VT_I4;
2992 V_I4(&name) = -1;
2993 disp = (void*)0xdeadbeef;
2994 hres = IHTMLSelectElement_item(select, name, index, &disp);
2995 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2996 ok(!disp, "disp = %p\n", disp);
2998 V_I4(&name) = 2;
2999 disp = (void*)0xdeadbeef;
3000 hres = IHTMLSelectElement_item(select, name, index, &disp);
3001 ok(hres == S_OK, "item failed: %08x\n", hres);
3002 ok(!disp, "disp = %p\n", disp);
3004 V_I4(&name) = 1;
3005 hres = IHTMLSelectElement_item(select, name, index, NULL);
3006 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3008 disp = NULL;
3009 hres = IHTMLSelectElement_item(select, name, index, &disp);
3010 ok(hres == S_OK, "item failed: %08x\n", hres);
3011 ok(disp != NULL, "disp = NULL\n");
3012 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3014 V_VT(&index) = VT_I4;
3015 V_I4(&index) = 1;
3016 disp2 = NULL;
3017 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3018 ok(hres == S_OK, "item failed: %08x\n", hres);
3019 ok(disp2 != NULL, "disp = NULL\n");
3020 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3021 IDispatch_Release(disp2);
3022 IDispatch_Release(disp);
3025 static void test_form_item(IHTMLElement *elem)
3027 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3028 IDispatch *disp, *disp2;
3029 VARIANT name, index;
3030 HRESULT hres;
3032 V_VT(&index) = VT_EMPTY;
3033 V_VT(&name) = VT_I4;
3034 V_I4(&name) = -1;
3035 disp = (void*)0xdeadbeef;
3036 hres = IHTMLFormElement_item(form, name, index, &disp);
3037 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3038 ok(!disp, "disp = %p\n", disp);
3040 V_I4(&name) = 2;
3041 disp = (void*)0xdeadbeef;
3042 hres = IHTMLFormElement_item(form, name, index, &disp);
3043 ok(hres == S_OK, "item failed: %08x\n", hres);
3044 ok(!disp, "disp = %p\n", disp);
3046 V_I4(&name) = 1;
3047 hres = IHTMLFormElement_item(form, name, index, NULL);
3048 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3050 disp = NULL;
3051 hres = IHTMLFormElement_item(form, name, index, &disp);
3052 ok(hres == S_OK, "item failed: %08x\n", hres);
3053 ok(disp != NULL, "disp = NULL\n");
3054 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3056 V_VT(&index) = VT_I4;
3057 V_I4(&index) = 1;
3058 disp2 = NULL;
3059 hres = IHTMLFormElement_item(form, name, index, &disp2);
3060 ok(hres == S_OK, "item failed: %08x\n", hres);
3061 ok(disp2 != NULL, "disp = NULL\n");
3062 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3063 IDispatch_Release(disp2);
3064 IDispatch_Release(disp);
3067 static void test_create_option_elem(IHTMLDocument2 *doc)
3069 IHTMLOptionElement *option;
3071 option = create_option_elem(doc, "test text", "test value");
3073 test_option_put_text(option, "new text");
3074 test_option_put_value(option, "new value");
3075 test_option_put_selected(option, VARIANT_TRUE);
3076 test_option_put_selected(option, VARIANT_FALSE);
3078 IHTMLOptionElement_Release(option);
3081 static void test_create_img_elem(IHTMLDocument2 *doc)
3083 IHTMLImgElement *img;
3085 img = create_img_elem(doc, 10, 15);
3087 if(img){
3088 test_img_put_width(img, 5);
3089 test_img_put_height(img, 20);
3091 IHTMLImgElement_Release(img);
3092 img = NULL;
3095 img = create_img_elem(doc, -1, -1);
3097 if(img){
3098 test_img_put_width(img, 5);
3099 test_img_put_height(img, 20);
3101 IHTMLImgElement_Release(img);
3105 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3107 IHTMLBodyElement *body;
3108 IHTMLTxtRange *range;
3109 IHTMLElement *elem;
3110 HRESULT hres;
3112 hres = IHTMLDocument2_get_body(doc, &elem);
3113 ok(hres == S_OK, "get_body failed: %08x\n", hres);
3115 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3116 IHTMLElement_Release(elem);
3118 hres = IHTMLBodyElement_createTextRange(body, &range);
3119 IHTMLBodyElement_Release(body);
3120 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3122 return range;
3125 static void test_txtrange(IHTMLDocument2 *doc)
3127 IHTMLTxtRange *body_range, *range, *range2;
3128 IHTMLSelectionObject *selection;
3129 IDispatch *disp_range;
3130 HRESULT hres;
3132 body_range = test_create_body_range(doc);
3134 test_range_text(body_range, "test abc 123\r\nit's text");
3136 hres = IHTMLTxtRange_duplicate(body_range, &range);
3137 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3139 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3140 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3141 test_range_isequal(range, range2, VARIANT_TRUE);
3143 test_range_text(range, "test abc 123\r\nit's text");
3144 test_range_text(body_range, "test abc 123\r\nit's text");
3146 test_range_collapse(range, TRUE);
3147 test_range_isequal(range, range2, VARIANT_FALSE);
3148 test_range_inrange(range, range2, VARIANT_FALSE);
3149 test_range_inrange(range2, range, VARIANT_TRUE);
3150 IHTMLTxtRange_Release(range2);
3152 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3153 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3154 test_range_move(range, characterW, 2, 2);
3155 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3157 test_range_collapse(range, FALSE);
3158 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3160 test_range_collapse(range, FALSE);
3161 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3162 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3163 test_range_move(range, characterW, 2, 2);
3164 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3165 test_range_moveend(range, characterW, -5, -5);
3166 test_range_text(range, NULL);
3167 test_range_moveend(range, characterW, 3, 3);
3168 test_range_text(range, "c 1");
3169 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3170 test_range_collapse(range, TRUE);
3171 test_range_move(range, characterW, 4, 4);
3172 test_range_moveend(range, characterW, 1, 1);
3173 test_range_text(range, " ");
3174 test_range_move(range, wordW, 1, 1);
3175 test_range_moveend(range, characterW, 2, 2);
3176 test_range_text(range, "ab");
3178 IHTMLTxtRange_Release(range);
3180 hres = IHTMLTxtRange_duplicate(body_range, &range);
3181 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3183 test_range_text(range, "test abc 123\r\nit's text");
3184 test_range_move(range, characterW, 3, 3);
3185 test_range_moveend(range, characterW, 1, 1);
3186 test_range_text(range, "t");
3187 test_range_moveend(range, characterW, 3, 3);
3188 test_range_text(range, "t ab");
3189 test_range_moveend(range, characterW, -2, -2);
3190 test_range_text(range, "t ");
3191 test_range_move(range, characterW, 6, 6);
3192 test_range_moveend(range, characterW, 3, 3);
3193 test_range_text(range, "123");
3194 test_range_moveend(range, characterW, 2, 2);
3195 test_range_text(range, "123\r\ni");
3197 IHTMLTxtRange_Release(range);
3199 hres = IHTMLTxtRange_duplicate(body_range, &range);
3200 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3202 test_range_move(range, wordW, 1, 1);
3203 test_range_moveend(range, characterW, 2, 2);
3204 test_range_text(range, "ab");
3206 test_range_move(range, characterW, -2, -2);
3207 test_range_moveend(range, characterW, 2, 2);
3208 test_range_text(range, "t ");
3210 test_range_move(range, wordW, 3, 3);
3211 test_range_move(range, wordW, -2, -2);
3212 test_range_moveend(range, characterW, 2, 2);
3213 test_range_text(range, "ab");
3215 test_range_move(range, characterW, -6, -5);
3216 test_range_moveend(range, characterW, -1, 0);
3217 test_range_moveend(range, characterW, -6, 0);
3218 test_range_move(range, characterW, 2, 2);
3219 test_range_moveend(range, characterW, 2, 2);
3220 test_range_text(range, "st");
3221 test_range_moveend(range, characterW, -6, -4);
3222 test_range_moveend(range, characterW, 2, 2);
3224 IHTMLTxtRange_Release(range);
3226 hres = IHTMLTxtRange_duplicate(body_range, &range);
3227 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3229 test_range_move(range, wordW, 2, 2);
3230 test_range_moveend(range, characterW, 2, 2);
3231 test_range_text(range, "12");
3233 test_range_move(range, characterW, 15, 14);
3234 test_range_move(range, characterW, -2, -2);
3235 test_range_moveend(range, characterW, 3, 2);
3236 test_range_text(range, "t");
3237 test_range_moveend(range, characterW, -1, -1);
3238 test_range_text(range, "t");
3239 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3240 test_range_move(range, characterW, -2, -2);
3241 test_range_moveend(range, characterW, 2, 2);
3242 test_range_text(range, "s ");
3243 test_range_move(range, characterW, 100, 7);
3244 test_range_move(range, wordW, 1, 0);
3245 test_range_move(range, characterW, -2, -2);
3246 test_range_moveend(range, characterW, 3, 2);
3247 test_range_text(range, "t");
3249 IHTMLTxtRange_Release(range);
3251 hres = IHTMLTxtRange_duplicate(body_range, &range);
3252 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3254 test_range_collapse(range, TRUE);
3255 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3256 test_range_put_text(range, "word");
3257 test_range_text(body_range, "wordabc 123\r\nit's text");
3258 test_range_text(range, NULL);
3259 test_range_moveend(range, characterW, 3, 3);
3260 test_range_text(range, "abc");
3261 test_range_movestart(range, characterW, -2, -2);
3262 test_range_text(range, "rdabc");
3263 test_range_movestart(range, characterW, 3, 3);
3264 test_range_text(range, "bc");
3265 test_range_movestart(range, characterW, 4, 4);
3266 test_range_text(range, NULL);
3267 test_range_movestart(range, characterW, -3, -3);
3268 test_range_text(range, "c 1");
3269 test_range_movestart(range, characterW, -7, -6);
3270 test_range_text(range, "wordabc 1");
3271 test_range_movestart(range, characterW, 100, 22);
3272 test_range_text(range, NULL);
3274 IHTMLTxtRange_Release(range);
3275 IHTMLTxtRange_Release(body_range);
3277 hres = IHTMLDocument2_get_selection(doc, &selection);
3278 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3280 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3281 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3282 IHTMLSelectionObject_Release(selection);
3284 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3285 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3286 IDispatch_Release(disp_range);
3288 test_range_text(range, NULL);
3289 test_range_moveend(range, characterW, 3, 3);
3290 test_range_text(range, "wor");
3291 test_range_parent(range, ET_BODY);
3292 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3293 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3294 test_range_move(range, characterW, 3, 3);
3295 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3296 test_range_moveend(range, characterW, -4, -4);
3297 test_range_put_text(range, "abc def ");
3298 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3299 test_range_move(range, wordW, 1, 1);
3300 test_range_movestart(range, characterW, -1, -1);
3301 test_range_text(range, " ");
3302 test_range_move(range, wordW, 1, 1);
3303 test_range_moveend(range, characterW, 3, 3);
3304 test_range_text(range, "def");
3305 test_range_put_text(range, "xyz");
3306 test_range_moveend(range, characterW, 1, 1);
3307 test_range_move(range, wordW, 1, 1);
3308 test_range_moveend(range, characterW, 2, 2);
3309 test_range_text(range, "ab");
3311 IHTMLTxtRange_Release(range);
3314 static void test_txtrange2(IHTMLDocument2 *doc)
3316 IHTMLTxtRange *range;
3318 range = test_create_body_range(doc);
3320 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3321 test_range_move(range, characterW, 5, 5);
3322 test_range_moveend(range, characterW, 1, 1);
3323 test_range_text(range, "2");
3324 test_range_move(range, characterW, -3, -3);
3325 test_range_moveend(range, characterW, 3, 3);
3326 test_range_text(range, "c\r\n\r\n1");
3327 test_range_collapse(range, VARIANT_FALSE);
3328 test_range_moveend(range, characterW, 4, 4);
3329 test_range_text(range, "23");
3330 test_range_moveend(range, characterW, 1, 1);
3331 test_range_text(range, "23\r\n\r\n\r\nd");
3332 test_range_moveend(range, characterW, -1, -1);
3333 test_range_text(range, "23");
3334 test_range_moveend(range, characterW, -1, -1);
3335 test_range_text(range, "23");
3336 test_range_moveend(range, characterW, -2, -2);
3337 test_range_text(range, "2");
3339 IHTMLTxtRange_Release(range);
3342 static void test_compatmode(IHTMLDocument2 *doc)
3344 IHTMLDocument5 *doc5;
3345 BSTR mode;
3346 HRESULT hres;
3348 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3349 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3350 if(FAILED(hres))
3351 return;
3353 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3354 IHTMLDocument5_Release(doc5);
3355 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3356 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3357 SysFreeString(mode);
3360 static void test_location(IHTMLDocument2 *doc)
3362 IHTMLLocation *location, *location2;
3363 IHTMLWindow2 *window;
3364 BSTR str;
3365 ULONG ref;
3366 HRESULT hres;
3368 hres = IHTMLDocument2_get_location(doc, &location);
3369 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3371 hres = IHTMLDocument2_get_location(doc, &location2);
3372 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3374 ok(location == location2, "location != location2\n");
3375 IHTMLLocation_Release(location2);
3377 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3378 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3380 hres = IHTMLWindow2_get_location(window, &location2);
3381 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3382 ok(location == location2, "location != location2\n");
3383 IHTMLLocation_Release(location2);
3385 test_ifaces((IUnknown*)location, location_iids);
3386 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3388 hres = IHTMLLocation_get_pathname(location, &str);
3389 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3390 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3392 hres = IHTMLLocation_get_href(location, NULL);
3393 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3395 hres = IHTMLLocation_get_href(location, &str);
3396 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3397 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3399 ref = IHTMLLocation_Release(location);
3400 ok(!ref, "location chould be destroyed here\n");
3403 static void test_navigator(IHTMLDocument2 *doc)
3405 IHTMLWindow2 *window;
3406 IOmNavigator *navigator, *navigator2;
3407 char buf[512];
3408 DWORD size;
3409 ULONG ref;
3410 BSTR bstr;
3411 HRESULT hres;
3413 static const WCHAR v40[] = {'4','.','0'};
3415 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3416 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3418 hres = IHTMLWindow2_get_navigator(window, &navigator);
3419 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3420 ok(navigator != NULL, "navigator == NULL\n");
3421 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3423 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3424 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3425 ok(navigator != navigator2, "navigator2 != navihgator\n");
3427 IHTMLWindow2_Release(window);
3428 IOmNavigator_Release(navigator2);
3430 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3431 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3432 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3433 SysFreeString(bstr);
3435 bstr = NULL;
3436 hres = IOmNavigator_get_appName(navigator, &bstr);
3437 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3438 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3439 SysFreeString(bstr);
3441 bstr = NULL;
3442 hres = IOmNavigator_get_platform(navigator, &bstr);
3443 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3444 #ifdef _WIN64
3445 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3446 #else
3447 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3448 #endif
3449 SysFreeString(bstr);
3451 bstr = NULL;
3452 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3453 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3454 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3455 SysFreeString(bstr);
3457 hres = IOmNavigator_toString(navigator, NULL);
3458 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3460 bstr = NULL;
3461 hres = IOmNavigator_toString(navigator, &bstr);
3462 ok(hres == S_OK, "toString failed: %08x\n", hres);
3463 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3464 SysFreeString(bstr);
3466 size = sizeof(buf);
3467 hres = ObtainUserAgentString(0, buf, &size);
3468 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3470 bstr = NULL;
3471 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3472 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3473 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3474 SysFreeString(bstr);
3476 if(!strncmp(buf, "Mozilla/", 8)) {
3477 bstr = NULL;
3478 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3479 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3480 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3481 SysFreeString(bstr);
3482 }else {
3483 skip("nonstandard user agent\n");
3486 ref = IOmNavigator_Release(navigator);
3487 ok(!ref, "navigator should be destroyed here\n");
3490 static void test_screen(IHTMLWindow2 *window)
3492 IHTMLScreen *screen, *screen2;
3493 IDispatchEx *dispex;
3494 LONG l, exl;
3495 HDC hdc;
3496 HRESULT hres;
3498 screen = NULL;
3499 hres = IHTMLWindow2_get_screen(window, &screen);
3500 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3501 ok(screen != NULL, "screen == NULL\n");
3503 screen2 = NULL;
3504 hres = IHTMLWindow2_get_screen(window, &screen2);
3505 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3506 ok(screen2 != NULL, "screen == NULL\n");
3507 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3508 IHTMLScreen_Release(screen2);
3510 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3511 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3512 if(SUCCEEDED(hres)) {
3513 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3514 IDispatchEx_Release(dispex);
3517 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3519 exl = GetDeviceCaps(hdc, HORZRES);
3520 l = 0xdeadbeef;
3521 hres = IHTMLScreen_get_width(screen, &l);
3522 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3523 ok(l == exl, "width = %d, expected %d\n", l, exl);
3525 exl = GetDeviceCaps(hdc, VERTRES);
3526 l = 0xdeadbeef;
3527 hres = IHTMLScreen_get_height(screen, &l);
3528 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3529 ok(l == exl, "height = %d, expected %d\n", l, exl);
3531 exl = GetDeviceCaps(hdc, BITSPIXEL);
3532 l = 0xdeadbeef;
3533 hres = IHTMLScreen_get_colorDepth(screen, &l);
3534 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3535 ok(l == exl, "height = %d, expected %d\n", l, exl);
3537 DeleteObject(hdc);
3539 IHTMLScreen_Release(screen);
3542 static void test_current_style(IHTMLCurrentStyle *current_style)
3544 BSTR str;
3545 HRESULT hres;
3546 VARIANT v;
3548 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3549 test_ifaces((IUnknown*)current_style, cstyle_iids);
3551 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3552 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3553 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3554 SysFreeString(str);
3556 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3557 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3558 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3559 SysFreeString(str);
3561 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3562 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3563 SysFreeString(str);
3565 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3566 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3567 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3568 SysFreeString(str);
3570 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3571 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3572 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3573 SysFreeString(str);
3575 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3576 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3577 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3578 SysFreeString(str);
3580 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3581 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3582 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3583 SysFreeString(str);
3585 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3586 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3587 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3588 SysFreeString(str);
3590 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3591 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3592 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3593 SysFreeString(str);
3595 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3596 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3597 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3598 SysFreeString(str);
3600 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3601 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3602 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3603 SysFreeString(str);
3605 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3606 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3607 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3608 SysFreeString(str);
3610 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3611 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3612 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3613 SysFreeString(str);
3615 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3616 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3617 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3618 SysFreeString(str);
3620 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3621 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3622 SysFreeString(str);
3624 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3625 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3626 SysFreeString(str);
3628 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3629 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3630 SysFreeString(str);
3632 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3633 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3634 SysFreeString(str);
3636 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3637 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3638 SysFreeString(str);
3640 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3641 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3642 SysFreeString(str);
3644 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3645 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3646 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3647 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3648 VariantClear(&v);
3650 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3651 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3652 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3653 VariantClear(&v);
3655 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3656 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3657 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3658 VariantClear(&v);
3660 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3661 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3662 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3663 VariantClear(&v);
3665 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3666 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3667 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3668 VariantClear(&v);
3670 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3671 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3672 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3673 VariantClear(&v);
3675 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3676 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3677 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3678 VariantClear(&v);
3680 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3681 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3682 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3683 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3684 VariantClear(&v);
3686 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3687 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3688 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3689 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3690 VariantClear(&v);
3692 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3693 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3694 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3695 VariantClear(&v);
3697 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3698 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3699 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3700 VariantClear(&v);
3702 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3703 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3704 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3705 VariantClear(&v);
3707 V_BSTR(&v) = NULL;
3708 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3709 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3710 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3711 VariantClear(&v);
3713 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3714 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3715 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3716 VariantClear(&v);
3718 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3719 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3720 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3721 VariantClear(&v);
3723 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3724 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3725 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3726 VariantClear(&v);
3728 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3729 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3730 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3731 VariantClear(&v);
3733 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3734 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3735 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3736 VariantClear(&v);
3738 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3739 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3740 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3741 VariantClear(&v);
3743 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3744 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3745 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3746 VariantClear(&v);
3748 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3749 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3750 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3751 VariantClear(&v);
3753 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3754 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3755 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3756 VariantClear(&v);
3758 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3759 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3760 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3761 VariantClear(&v);
3763 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3764 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3765 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3766 VariantClear(&v);
3768 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3769 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3770 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3771 VariantClear(&v);
3773 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3774 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3775 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3776 VariantClear(&v);
3778 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3779 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3780 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3781 VariantClear(&v);
3783 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3784 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3785 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3786 VariantClear(&v);
3788 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3789 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3790 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3791 VariantClear(&v);
3793 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3794 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3795 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3796 VariantClear(&v);
3798 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3799 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3800 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3801 VariantClear(&v);
3804 static void test_style2(IHTMLStyle2 *style2)
3806 VARIANT v;
3807 BSTR str;
3808 HRESULT hres;
3810 str = (void*)0xdeadbeef;
3811 hres = IHTMLStyle2_get_position(style2, &str);
3812 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3813 ok(!str, "str != NULL\n");
3815 str = a2bstr("absolute");
3816 hres = IHTMLStyle2_put_position(style2, str);
3817 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3818 SysFreeString(str);
3820 str = NULL;
3821 hres = IHTMLStyle2_get_position(style2, &str);
3822 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3823 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3824 SysFreeString(str);
3826 /* Test right */
3827 V_VT(&v) = VT_EMPTY;
3828 hres = IHTMLStyle2_get_right(style2, &v);
3829 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3830 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
3831 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
3832 VariantClear(&v);
3834 V_VT(&v) = VT_BSTR;
3835 V_BSTR(&v) = a2bstr("3px");
3836 hres = IHTMLStyle2_put_right(style2, v);
3837 ok(hres == S_OK, "put_right failed: %08x\n", hres);
3838 VariantClear(&v);
3840 V_VT(&v) = VT_EMPTY;
3841 hres = IHTMLStyle2_get_right(style2, &v);
3842 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3843 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3844 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3845 VariantClear(&v);
3848 static void test_style3(IHTMLStyle3 *style3)
3850 BSTR str;
3851 HRESULT hres;
3853 str = (void*)0xdeadbeef;
3854 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3855 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3856 ok(!str, "str != NULL\n");
3858 str = a2bstr("break-word");
3859 hres = IHTMLStyle3_put_wordWrap(style3, str);
3860 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3861 SysFreeString(str);
3863 str = NULL;
3864 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3865 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3866 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3867 SysFreeString(str);
3870 static void test_style4(IHTMLStyle4 *style4)
3872 HRESULT hres;
3873 VARIANT v;
3874 VARIANT vdefault;
3876 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3877 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3879 V_VT(&v) = VT_BSTR;
3880 V_BSTR(&v) = a2bstr("10px");
3881 hres = IHTMLStyle4_put_minHeight(style4, v);
3882 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3883 VariantClear(&v);
3885 hres = IHTMLStyle4_get_minHeight(style4, &v);
3886 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3887 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3888 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3890 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3891 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3892 VariantClear(&vdefault);
3895 static void test_default_style(IHTMLStyle *style)
3897 IHTMLStyle2 *style2;
3898 IHTMLStyle3 *style3;
3899 IHTMLStyle4 *style4;
3900 VARIANT_BOOL b;
3901 VARIANT v;
3902 BSTR str;
3903 HRESULT hres;
3904 float f;
3905 BSTR sOverflowDefault;
3906 BSTR sDefault;
3907 VARIANT vDefault;
3909 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3910 test_ifaces((IUnknown*)style, style_iids);
3912 test_style_csstext(style, NULL);
3914 hres = IHTMLStyle_get_position(style, &str);
3915 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3916 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3918 V_VT(&v) = VT_NULL;
3919 hres = IHTMLStyle_get_marginRight(style, &v);
3920 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3921 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3922 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3924 V_VT(&v) = VT_NULL;
3925 hres = IHTMLStyle_get_marginLeft(style, &v);
3926 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3927 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3928 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3930 str = (void*)0xdeadbeef;
3931 hres = IHTMLStyle_get_fontFamily(style, &str);
3932 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3933 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3935 str = (void*)0xdeadbeef;
3936 hres = IHTMLStyle_get_fontWeight(style, &str);
3937 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3938 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3940 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3941 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3943 str = a2bstr("test");
3944 hres = IHTMLStyle_put_fontWeight(style, str);
3945 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3946 SysFreeString(str);
3948 str = a2bstr("bold");
3949 hres = IHTMLStyle_put_fontWeight(style, str);
3950 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3951 SysFreeString(str);
3953 str = a2bstr("bolder");
3954 hres = IHTMLStyle_put_fontWeight(style, str);
3955 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3956 SysFreeString(str);
3958 str = a2bstr("lighter");
3959 hres = IHTMLStyle_put_fontWeight(style, str);
3960 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3961 SysFreeString(str);
3963 str = a2bstr("100");
3964 hres = IHTMLStyle_put_fontWeight(style, str);
3965 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3966 SysFreeString(str);
3968 str = a2bstr("200");
3969 hres = IHTMLStyle_put_fontWeight(style, str);
3970 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3971 SysFreeString(str);
3973 str = a2bstr("300");
3974 hres = IHTMLStyle_put_fontWeight(style, str);
3975 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3976 SysFreeString(str);
3978 str = a2bstr("400");
3979 hres = IHTMLStyle_put_fontWeight(style, str);
3980 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3981 SysFreeString(str);
3983 str = a2bstr("500");
3984 hres = IHTMLStyle_put_fontWeight(style, str);
3985 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3986 SysFreeString(str);
3988 str = a2bstr("600");
3989 hres = IHTMLStyle_put_fontWeight(style, str);
3990 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3991 SysFreeString(str);
3993 str = a2bstr("700");
3994 hres = IHTMLStyle_put_fontWeight(style, str);
3995 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3996 SysFreeString(str);
3998 str = a2bstr("800");
3999 hres = IHTMLStyle_put_fontWeight(style, str);
4000 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4001 SysFreeString(str);
4003 str = a2bstr("900");
4004 hres = IHTMLStyle_put_fontWeight(style, str);
4005 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4006 SysFreeString(str);
4008 hres = IHTMLStyle_get_fontWeight(style, &str);
4009 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4010 ok(!strcmp_wa(str, "900"), "str != style900\n");
4011 SysFreeString(str);
4013 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4014 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4015 SysFreeString(sDefault);
4017 /* font Variant */
4018 hres = IHTMLStyle_get_fontVariant(style, NULL);
4019 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4021 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4022 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4024 str = a2bstr("test");
4025 hres = IHTMLStyle_put_fontVariant(style, str);
4026 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4027 SysFreeString(str);
4029 str = a2bstr("small-caps");
4030 hres = IHTMLStyle_put_fontVariant(style, str);
4031 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4032 SysFreeString(str);
4034 str = a2bstr("normal");
4035 hres = IHTMLStyle_put_fontVariant(style, str);
4036 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4037 SysFreeString(str);
4039 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4040 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4041 SysFreeString(sDefault);
4043 str = (void*)0xdeadbeef;
4044 hres = IHTMLStyle_get_display(style, &str);
4045 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4046 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4048 str = (void*)0xdeadbeef;
4049 hres = IHTMLStyle_get_visibility(style, &str);
4050 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4051 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4053 V_VT(&v) = VT_NULL;
4054 hres = IHTMLStyle_get_fontSize(style, &v);
4055 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4056 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4057 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4059 V_VT(&v) = VT_NULL;
4060 hres = IHTMLStyle_get_color(style, &v);
4061 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4062 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4063 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4065 b = 0xfefe;
4066 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4067 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4068 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4070 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4071 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4072 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4074 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4075 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4076 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4078 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4079 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4081 b = 0xfefe;
4082 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4083 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4084 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4086 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4087 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4088 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4090 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4091 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4092 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4094 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4095 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4097 b = 0xfefe;
4098 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4099 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4100 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4102 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4103 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4104 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4106 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4107 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4108 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4110 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4111 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4113 b = 0xfefe;
4114 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4115 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4116 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4118 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4119 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4120 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4122 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4123 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4124 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4126 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4127 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4129 b = 0xfefe;
4130 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4131 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4132 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4134 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4135 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4136 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4138 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4139 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4140 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4142 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4143 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4145 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4146 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4148 str = a2bstr("invalid");
4149 hres = IHTMLStyle_put_textDecoration(style, str);
4150 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4151 SysFreeString(str);
4153 str = a2bstr("none");
4154 hres = IHTMLStyle_put_textDecoration(style, str);
4155 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4156 SysFreeString(str);
4158 str = a2bstr("underline");
4159 hres = IHTMLStyle_put_textDecoration(style, str);
4160 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4161 SysFreeString(str);
4163 str = a2bstr("overline");
4164 hres = IHTMLStyle_put_textDecoration(style, str);
4165 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4166 SysFreeString(str);
4168 str = a2bstr("line-through");
4169 hres = IHTMLStyle_put_textDecoration(style, str);
4170 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4171 SysFreeString(str);
4173 str = a2bstr("blink");
4174 hres = IHTMLStyle_put_textDecoration(style, str);
4175 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4176 SysFreeString(str);
4178 hres = IHTMLStyle_get_textDecoration(style, &str);
4179 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4180 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4181 SysFreeString(str);
4183 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4184 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4185 SysFreeString(sDefault);
4187 hres = IHTMLStyle_get_posWidth(style, NULL);
4188 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4190 hres = IHTMLStyle_get_posWidth(style, &f);
4191 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4192 ok(f == 0.0f, "f = %f\n", f);
4194 V_VT(&v) = VT_EMPTY;
4195 hres = IHTMLStyle_get_width(style, &v);
4196 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4197 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4198 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4200 hres = IHTMLStyle_put_posWidth(style, 2.2);
4201 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4203 hres = IHTMLStyle_get_posWidth(style, &f);
4204 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4205 ok(f == 2.0f ||
4206 f == 2.2f, /* IE8 */
4207 "f = %f\n", f);
4209 V_VT(&v) = VT_BSTR;
4210 V_BSTR(&v) = a2bstr("auto");
4211 hres = IHTMLStyle_put_width(style, v);
4212 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4213 VariantClear(&v);
4215 V_VT(&v) = VT_EMPTY;
4216 hres = IHTMLStyle_get_width(style, &v);
4217 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4218 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4219 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4220 VariantClear(&v);
4222 V_VT(&v) = VT_I4;
4223 V_I4(&v) = 100;
4224 hres = IHTMLStyle_put_width(style, v);
4225 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4227 V_VT(&v) = VT_EMPTY;
4228 hres = IHTMLStyle_get_width(style, &v);
4229 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4230 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4231 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4232 VariantClear(&v);
4234 /* margin tests */
4235 str = (void*)0xdeadbeef;
4236 hres = IHTMLStyle_get_margin(style, &str);
4237 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4238 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4240 str = a2bstr("1");
4241 hres = IHTMLStyle_put_margin(style, str);
4242 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4243 SysFreeString(str);
4245 hres = IHTMLStyle_get_margin(style, &str);
4246 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4247 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4249 hres = IHTMLStyle_put_margin(style, NULL);
4250 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4252 str = (void*)0xdeadbeef;
4253 hres = IHTMLStyle_get_marginTop(style, &v);
4254 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4255 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4256 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4258 V_VT(&v) = VT_BSTR;
4259 V_BSTR(&v) = a2bstr("6px");
4260 hres = IHTMLStyle_put_marginTop(style, v);
4261 SysFreeString(V_BSTR(&v));
4262 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4264 str = (void*)0xdeadbeef;
4265 hres = IHTMLStyle_get_marginTop(style, &v);
4266 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4267 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4268 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4270 str = NULL;
4271 hres = IHTMLStyle_get_border(style, &str);
4272 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4273 ok(!str || !*str, "str is not empty\n");
4274 SysFreeString(str);
4276 str = a2bstr("1px");
4277 hres = IHTMLStyle_put_border(style, str);
4278 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4279 SysFreeString(str);
4281 V_VT(&v) = VT_EMPTY;
4282 hres = IHTMLStyle_get_left(style, &v);
4283 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4284 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4285 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4286 VariantClear(&v);
4288 /* Test posLeft */
4289 hres = IHTMLStyle_get_posLeft(style, NULL);
4290 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4292 f = 1.0f;
4293 hres = IHTMLStyle_get_posLeft(style, &f);
4294 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4295 ok(f == 0.0, "expected 0.0 got %f\n", f);
4297 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4298 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4300 hres = IHTMLStyle_get_posLeft(style, &f);
4301 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4302 ok(f == 4.0 ||
4303 f == 4.9f, /* IE8 */
4304 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4306 /* Ensure left is updated correctly. */
4307 V_VT(&v) = VT_EMPTY;
4308 hres = IHTMLStyle_get_left(style, &v);
4309 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4310 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4311 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4312 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4313 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4314 VariantClear(&v);
4316 /* Test left */
4317 V_VT(&v) = VT_BSTR;
4318 V_BSTR(&v) = a2bstr("3px");
4319 hres = IHTMLStyle_put_left(style, v);
4320 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4321 VariantClear(&v);
4323 hres = IHTMLStyle_get_posLeft(style, &f);
4324 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4325 ok(f == 3.0, "expected 3.0 got %f\n", f);
4327 V_VT(&v) = VT_EMPTY;
4328 hres = IHTMLStyle_get_left(style, &v);
4329 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4330 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4331 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4332 VariantClear(&v);
4334 V_VT(&v) = VT_NULL;
4335 hres = IHTMLStyle_put_left(style, v);
4336 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4338 V_VT(&v) = VT_EMPTY;
4339 hres = IHTMLStyle_get_left(style, &v);
4340 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4341 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4342 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4343 VariantClear(&v);
4345 V_VT(&v) = VT_EMPTY;
4346 hres = IHTMLStyle_get_top(style, &v);
4347 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4348 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4349 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4350 VariantClear(&v);
4352 /* Test posTop */
4353 hres = IHTMLStyle_get_posTop(style, NULL);
4354 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4356 f = 1.0f;
4357 hres = IHTMLStyle_get_posTop(style, &f);
4358 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4359 ok(f == 0.0, "expected 0.0 got %f\n", f);
4361 hres = IHTMLStyle_put_posTop(style, 4.9f);
4362 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4364 hres = IHTMLStyle_get_posTop(style, &f);
4365 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4366 ok(f == 4.0 ||
4367 f == 4.9f, /* IE8 */
4368 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4370 V_VT(&v) = VT_BSTR;
4371 V_BSTR(&v) = a2bstr("3px");
4372 hres = IHTMLStyle_put_top(style, v);
4373 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4374 VariantClear(&v);
4376 V_VT(&v) = VT_EMPTY;
4377 hres = IHTMLStyle_get_top(style, &v);
4378 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4379 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4380 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4381 VariantClear(&v);
4383 hres = IHTMLStyle_get_posTop(style, &f);
4384 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4385 ok(f == 3.0, "expected 3.0 got %f\n", f);
4387 V_VT(&v) = VT_NULL;
4388 hres = IHTMLStyle_put_top(style, v);
4389 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4391 V_VT(&v) = VT_EMPTY;
4392 hres = IHTMLStyle_get_top(style, &v);
4393 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4394 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4395 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4396 VariantClear(&v);
4398 /* Test posHeight */
4399 hres = IHTMLStyle_get_posHeight(style, NULL);
4400 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4402 V_VT(&v) = VT_EMPTY;
4403 hres = IHTMLStyle_get_height(style, &v);
4404 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4405 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4406 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4407 VariantClear(&v);
4409 f = 1.0f;
4410 hres = IHTMLStyle_get_posHeight(style, &f);
4411 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4412 ok(f == 0.0, "expected 0.0 got %f\n", f);
4414 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4415 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4417 hres = IHTMLStyle_get_posHeight(style, &f);
4418 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4419 ok(f == 4.0 ||
4420 f == 4.9f, /* IE8 */
4421 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4423 V_VT(&v) = VT_BSTR;
4424 V_BSTR(&v) = a2bstr("64px");
4425 hres = IHTMLStyle_put_height(style, v);
4426 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4427 VariantClear(&v);
4429 V_VT(&v) = VT_EMPTY;
4430 hres = IHTMLStyle_get_height(style, &v);
4431 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4432 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4433 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4434 VariantClear(&v);
4436 hres = IHTMLStyle_get_posHeight(style, &f);
4437 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4438 ok(f == 64.0, "expected 64.0 got %f\n", f);
4440 str = (void*)0xdeadbeef;
4441 hres = IHTMLStyle_get_cursor(style, &str);
4442 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4443 ok(!str, "get_cursor != NULL\n");
4444 SysFreeString(str);
4446 str = a2bstr("default");
4447 hres = IHTMLStyle_put_cursor(style, str);
4448 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4449 SysFreeString(str);
4451 str = NULL;
4452 hres = IHTMLStyle_get_cursor(style, &str);
4453 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4454 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4455 SysFreeString(str);
4457 V_VT(&v) = VT_EMPTY;
4458 hres = IHTMLStyle_get_verticalAlign(style, &v);
4459 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4460 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4461 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4462 VariantClear(&v);
4464 V_VT(&v) = VT_BSTR;
4465 V_BSTR(&v) = a2bstr("middle");
4466 hres = IHTMLStyle_put_verticalAlign(style, v);
4467 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4468 VariantClear(&v);
4470 V_VT(&v) = VT_EMPTY;
4471 hres = IHTMLStyle_get_verticalAlign(style, &v);
4472 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4473 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4474 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4475 VariantClear(&v);
4477 str = (void*)0xdeadbeef;
4478 hres = IHTMLStyle_get_textAlign(style, &str);
4479 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4480 ok(!str, "textAlign != NULL\n");
4482 str = a2bstr("center");
4483 hres = IHTMLStyle_put_textAlign(style, str);
4484 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4485 SysFreeString(str);
4487 str = NULL;
4488 hres = IHTMLStyle_get_textAlign(style, &str);
4489 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4490 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4491 SysFreeString(str);
4493 str = (void*)0xdeadbeef;
4494 hres = IHTMLStyle_get_filter(style, &str);
4495 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4496 ok(!str, "filter != NULL\n");
4498 str = a2bstr("alpha(opacity=100)");
4499 hres = IHTMLStyle_put_filter(style, str);
4500 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4501 SysFreeString(str);
4503 V_VT(&v) = VT_EMPTY;
4504 hres = IHTMLStyle_get_zIndex(style, &v);
4505 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4506 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4507 ok(!V_I4(&v), "V_I4(v) != 0\n");
4508 VariantClear(&v);
4510 V_VT(&v) = VT_BSTR;
4511 V_BSTR(&v) = a2bstr("1");
4512 hres = IHTMLStyle_put_zIndex(style, v);
4513 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4514 VariantClear(&v);
4516 V_VT(&v) = VT_EMPTY;
4517 hres = IHTMLStyle_get_zIndex(style, &v);
4518 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4519 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4520 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4521 VariantClear(&v);
4523 /* fontStyle */
4524 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4525 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4527 str = a2bstr("test");
4528 hres = IHTMLStyle_put_fontStyle(style, str);
4529 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4530 SysFreeString(str);
4532 str = a2bstr("italic");
4533 hres = IHTMLStyle_put_fontStyle(style, str);
4534 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4535 SysFreeString(str);
4537 str = a2bstr("oblique");
4538 hres = IHTMLStyle_put_fontStyle(style, str);
4539 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4540 SysFreeString(str);
4542 str = a2bstr("normal");
4543 hres = IHTMLStyle_put_fontStyle(style, str);
4544 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4545 SysFreeString(str);
4547 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4548 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4549 SysFreeString(sDefault);
4551 /* overflow */
4552 hres = IHTMLStyle_get_overflow(style, NULL);
4553 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4555 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4556 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4558 str = a2bstr("test");
4559 hres = IHTMLStyle_put_overflow(style, str);
4560 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4561 SysFreeString(str);
4563 str = a2bstr("visible");
4564 hres = IHTMLStyle_put_overflow(style, str);
4565 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4566 SysFreeString(str);
4568 str = a2bstr("scroll");
4569 hres = IHTMLStyle_put_overflow(style, str);
4570 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4571 SysFreeString(str);
4573 str = a2bstr("hidden");
4574 hres = IHTMLStyle_put_overflow(style, str);
4575 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4576 SysFreeString(str);
4578 str = a2bstr("auto");
4579 hres = IHTMLStyle_put_overflow(style, str);
4580 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4581 SysFreeString(str);
4583 hres = IHTMLStyle_get_overflow(style, &str);
4584 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4585 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4586 SysFreeString(str);
4588 str = a2bstr("");
4589 hres = IHTMLStyle_put_overflow(style, str);
4590 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4591 SysFreeString(str);
4593 hres = IHTMLStyle_get_overflow(style, &str);
4594 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4595 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4596 SysFreeString(str);
4598 /* restore overflow default */
4599 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4600 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4601 SysFreeString(sOverflowDefault);
4603 /* Attribute Tests*/
4604 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4605 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4607 str = a2bstr("position");
4608 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4609 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4611 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4612 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4613 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4614 VariantClear(&v);
4616 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4617 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4619 V_VT(&v) = VT_BSTR;
4620 V_BSTR(&v) = a2bstr("absolute");
4621 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4622 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4623 VariantClear(&v);
4625 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4626 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4627 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4628 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4629 VariantClear(&v);
4631 V_VT(&v) = VT_BSTR;
4632 V_BSTR(&v) = NULL;
4633 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4634 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4635 VariantClear(&v);
4637 SysFreeString(str);
4639 str = a2bstr("borderLeftStyle");
4640 test_border_styles(style, str);
4641 SysFreeString(str);
4643 str = a2bstr("borderbottomstyle");
4644 test_border_styles(style, str);
4645 SysFreeString(str);
4647 str = a2bstr("borderrightstyle");
4648 test_border_styles(style, str);
4649 SysFreeString(str);
4651 str = a2bstr("bordertopstyle");
4652 test_border_styles(style, str);
4653 SysFreeString(str);
4655 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4656 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4658 str = a2bstr("none dotted dashed solid");
4659 hres = IHTMLStyle_put_borderStyle(style, str);
4660 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4661 SysFreeString(str);
4663 str = a2bstr("none dotted dashed solid");
4664 hres = IHTMLStyle_get_borderStyle(style, &str);
4665 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4666 ok(!strcmp_wa(str, "none dotted dashed solid"),
4667 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4668 SysFreeString(str);
4670 str = a2bstr("double groove ridge inset");
4671 hres = IHTMLStyle_put_borderStyle(style, str);
4672 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4673 SysFreeString(str);
4675 str = a2bstr("window-inset outset ridge inset");
4676 hres = IHTMLStyle_put_borderStyle(style, str);
4677 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4678 SysFreeString(str);
4680 str = a2bstr("window-inset");
4681 hres = IHTMLStyle_put_borderStyle(style, str);
4682 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4683 SysFreeString(str);
4685 str = a2bstr("none none none none none");
4686 hres = IHTMLStyle_put_borderStyle(style, str);
4687 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4688 SysFreeString(str);
4690 str = a2bstr("invalid none none none");
4691 hres = IHTMLStyle_put_borderStyle(style, str);
4692 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4693 SysFreeString(str);
4695 str = a2bstr("none invalid none none");
4696 hres = IHTMLStyle_put_borderStyle(style, str);
4697 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4698 SysFreeString(str);
4700 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4701 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4702 SysFreeString(sDefault);
4704 /* backgoundColor */
4705 hres = IHTMLStyle_get_backgroundColor(style, &v);
4706 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4707 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4708 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4709 VariantClear(&v);
4711 /* PaddingLeft */
4712 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4713 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4715 V_VT(&v) = VT_BSTR;
4716 V_BSTR(&v) = a2bstr("10");
4717 hres = IHTMLStyle_put_paddingLeft(style, v);
4718 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4719 VariantClear(&v);
4721 hres = IHTMLStyle_get_paddingLeft(style, &v);
4722 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4723 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4725 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4726 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4728 /* BackgroundRepeat */
4729 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4730 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4732 str = a2bstr("invalid");
4733 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4734 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4735 SysFreeString(str);
4737 str = a2bstr("repeat");
4738 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4739 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4740 SysFreeString(str);
4742 str = a2bstr("no-repeat");
4743 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4744 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4745 SysFreeString(str);
4747 str = a2bstr("repeat-x");
4748 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4749 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4750 SysFreeString(str);
4752 str = a2bstr("repeat-y");
4753 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4754 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4755 SysFreeString(str);
4757 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4758 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4759 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4760 SysFreeString(str);
4762 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4763 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4764 SysFreeString(sDefault);
4766 /* BorderColor */
4767 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4768 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4770 str = a2bstr("red green red blue");
4771 hres = IHTMLStyle_put_borderColor(style, str);
4772 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4773 SysFreeString(str);
4775 hres = IHTMLStyle_get_borderColor(style, &str);
4776 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4777 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4778 SysFreeString(str);
4780 hres = IHTMLStyle_put_borderColor(style, sDefault);
4781 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4782 SysFreeString(sDefault);
4784 /* BorderRight */
4785 hres = IHTMLStyle_get_borderRight(style, &sDefault);
4786 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
4788 str = a2bstr("thick dotted red");
4789 hres = IHTMLStyle_put_borderRight(style, str);
4790 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4791 SysFreeString(str);
4793 /* IHTMLStyle_get_borderRight appears to have a bug where
4794 it returns the first letter of the color. So we check
4795 each style individually.
4797 V_BSTR(&v) = NULL;
4798 hres = IHTMLStyle_get_borderRightColor(style, &v);
4799 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4800 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4801 VariantClear(&v);
4803 V_BSTR(&v) = NULL;
4804 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4805 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4806 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4807 VariantClear(&v);
4809 hres = IHTMLStyle_get_borderRightStyle(style, &str);
4810 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
4811 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4812 SysFreeString(str);
4814 hres = IHTMLStyle_put_borderRight(style, sDefault);
4815 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4816 SysFreeString(sDefault);
4818 /* BorderTop */
4819 hres = IHTMLStyle_get_borderTop(style, &sDefault);
4820 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
4822 str = a2bstr("thick dotted red");
4823 hres = IHTMLStyle_put_borderTop(style, str);
4824 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4825 SysFreeString(str);
4827 /* IHTMLStyle_get_borderTop appears to have a bug where
4828 it returns the first letter of the color. So we check
4829 each style individually.
4831 V_BSTR(&v) = NULL;
4832 hres = IHTMLStyle_get_borderTopColor(style, &v);
4833 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4834 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4835 VariantClear(&v);
4837 V_BSTR(&v) = NULL;
4838 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4839 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4840 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4841 VariantClear(&v);
4843 hres = IHTMLStyle_get_borderTopStyle(style, &str);
4844 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
4845 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4846 SysFreeString(str);
4848 hres = IHTMLStyle_put_borderTop(style, sDefault);
4849 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4850 SysFreeString(sDefault);
4852 /* BorderBottom */
4853 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
4854 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
4856 str = a2bstr("thick dotted red");
4857 hres = IHTMLStyle_put_borderBottom(style, str);
4858 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4859 SysFreeString(str);
4861 /* IHTMLStyle_get_borderBottom appears to have a bug where
4862 it returns the first letter of the color. So we check
4863 each style individually.
4865 V_BSTR(&v) = NULL;
4866 hres = IHTMLStyle_get_borderBottomColor(style, &v);
4867 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4868 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4869 VariantClear(&v);
4871 V_BSTR(&v) = NULL;
4872 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4873 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4874 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4875 VariantClear(&v);
4877 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
4878 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
4879 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4880 SysFreeString(str);
4882 hres = IHTMLStyle_put_borderBottom(style, sDefault);
4883 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4884 SysFreeString(sDefault);
4886 /* BorderLeft */
4887 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4888 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4890 str = a2bstr("thick dotted red");
4891 hres = IHTMLStyle_put_borderLeft(style, str);
4892 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4893 SysFreeString(str);
4895 /* IHTMLStyle_get_borderLeft appears to have a bug where
4896 it returns the first letter of the color. So we check
4897 each style individually.
4899 V_BSTR(&v) = NULL;
4900 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4901 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4902 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4903 VariantClear(&v);
4905 V_BSTR(&v) = NULL;
4906 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4907 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4908 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4909 VariantClear(&v);
4911 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4912 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4913 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4914 SysFreeString(str);
4916 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4917 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4918 SysFreeString(sDefault);
4920 /* backgroundPositionX */
4921 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4922 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4924 V_VT(&v) = VT_BSTR;
4925 V_BSTR(&v) = a2bstr("10px");
4926 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4927 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4928 VariantClear(&v);
4930 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4931 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4932 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4933 VariantClear(&v);
4935 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4936 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4937 VariantClear(&vDefault);
4939 /* backgroundPositionY */
4940 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4941 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4943 V_VT(&v) = VT_BSTR;
4944 V_BSTR(&v) = a2bstr("10px");
4945 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4946 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4947 VariantClear(&v);
4949 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4950 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4951 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4952 VariantClear(&v);
4954 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4955 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4956 VariantClear(&vDefault);
4958 /* borderTopWidth */
4959 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4960 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4962 V_VT(&v) = VT_BSTR;
4963 V_BSTR(&v) = a2bstr("10px");
4964 hres = IHTMLStyle_put_borderTopWidth(style, v);
4965 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4966 VariantClear(&v);
4968 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4969 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4970 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4971 VariantClear(&v);
4973 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4974 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4975 VariantClear(&vDefault);
4977 /* borderRightWidth */
4978 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4979 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4981 V_VT(&v) = VT_BSTR;
4982 V_BSTR(&v) = a2bstr("10");
4983 hres = IHTMLStyle_put_borderRightWidth(style, v);
4984 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4985 VariantClear(&v);
4987 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4988 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4989 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4990 VariantClear(&v);
4992 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4993 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4994 VariantClear(&vDefault);
4996 /* borderBottomWidth */
4997 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4998 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5000 V_VT(&v) = VT_BSTR;
5001 V_BSTR(&v) = a2bstr("10");
5002 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5003 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5004 VariantClear(&v);
5006 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5007 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5008 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5009 VariantClear(&v);
5011 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5012 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5013 VariantClear(&vDefault);
5015 /* borderLeftWidth */
5016 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5017 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5019 V_VT(&v) = VT_BSTR;
5020 V_BSTR(&v) = a2bstr("10");
5021 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5022 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5023 VariantClear(&v);
5025 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5026 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5027 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5028 VariantClear(&v);
5030 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5031 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5032 VariantClear(&vDefault);
5034 /* wordSpacing */
5035 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5036 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5038 V_VT(&v) = VT_BSTR;
5039 V_BSTR(&v) = a2bstr("10");
5040 hres = IHTMLStyle_put_wordSpacing(style, v);
5041 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5042 VariantClear(&v);
5044 hres = IHTMLStyle_get_wordSpacing(style, &v);
5045 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5046 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5047 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5048 VariantClear(&v);
5050 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5051 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5052 VariantClear(&vDefault);
5054 /* letterSpacing */
5055 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5056 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5058 V_VT(&v) = VT_BSTR;
5059 V_BSTR(&v) = a2bstr("11");
5060 hres = IHTMLStyle_put_letterSpacing(style, v);
5061 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5062 VariantClear(&v);
5064 hres = IHTMLStyle_get_letterSpacing(style, &v);
5065 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5066 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5067 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5068 VariantClear(&v);
5070 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5071 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5072 VariantClear(&vDefault);
5074 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5075 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5076 if(SUCCEEDED(hres)) {
5077 test_style2(style2);
5078 IHTMLStyle2_Release(style2);
5081 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5082 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5083 if(SUCCEEDED(hres)) {
5084 test_style3(style3);
5085 IHTMLStyle3_Release(style3);
5088 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5089 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5090 if(SUCCEEDED(hres)) {
5091 test_style4(style4);
5092 IHTMLStyle4_Release(style4);
5096 static void test_set_csstext(IHTMLStyle *style)
5098 VARIANT v;
5099 HRESULT hres;
5101 test_style_set_csstext(style, "background-color: black;");
5103 hres = IHTMLStyle_get_backgroundColor(style, &v);
5104 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5105 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5106 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5107 VariantClear(&v);
5110 static void test_default_selection(IHTMLDocument2 *doc)
5112 IHTMLSelectionObject *selection;
5113 IHTMLTxtRange *range;
5114 IDispatch *disp;
5115 BSTR str;
5116 HRESULT hres;
5118 hres = IHTMLDocument2_get_selection(doc, &selection);
5119 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5121 hres = IHTMLSelectionObject_get_type(selection, &str);
5122 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5123 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5124 SysFreeString(str);
5126 hres = IHTMLSelectionObject_createRange(selection, &disp);
5127 IHTMLSelectionObject_Release(selection);
5128 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5130 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5131 IDispatch_Release(disp);
5132 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5134 test_range_text(range, NULL);
5135 IHTMLTxtRange_Release(range);
5138 static void test_doc_elem(IHTMLDocument2 *doc)
5140 IHTMLDocument2 *doc_node, *owner_doc;
5141 IHTMLElement *elem;
5142 IHTMLDocument3 *doc3;
5143 HRESULT hres;
5145 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5146 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5148 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5149 IHTMLDocument3_Release(doc3);
5150 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5152 test_node_name((IUnknown*)elem, "HTML");
5153 test_elem_tag((IUnknown*)elem, "HTML");
5155 doc_node = get_doc_node(doc);
5156 owner_doc = get_owner_doc((IUnknown*)elem);
5157 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5158 IHTMLDocument2_Release(owner_doc);
5160 owner_doc = get_owner_doc((IUnknown*)doc_node);
5161 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5162 IHTMLDocument2_Release(doc_node);
5164 test_elem_client_rect((IUnknown*)elem);
5166 IHTMLElement_Release(elem);
5169 static void test_default_body(IHTMLBodyElement *body)
5171 LONG l;
5172 BSTR bstr;
5173 HRESULT hres;
5174 VARIANT v;
5176 bstr = (void*)0xdeadbeef;
5177 hres = IHTMLBodyElement_get_background(body, &bstr);
5178 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5179 ok(bstr == NULL, "bstr != NULL\n");
5181 l = elem_get_scroll_height((IUnknown*)body);
5182 ok(l != -1, "scrollHeight == -1\n");
5183 l = elem_get_scroll_width((IUnknown*)body);
5184 ok(l != -1, "scrollWidth == -1\n");
5185 l = elem_get_scroll_top((IUnknown*)body);
5186 ok(!l, "scrollTop = %d\n", l);
5187 elem_get_scroll_left((IUnknown*)body);
5189 /* get_text tests */
5190 hres = IHTMLBodyElement_get_text(body, &v);
5191 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5192 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5193 ok(bstr == NULL, "bstr != NULL\n");
5195 /* get_text - Invalid Text */
5196 V_VT(&v) = VT_BSTR;
5197 V_BSTR(&v) = a2bstr("Invalid");
5198 hres = IHTMLBodyElement_put_text(body, v);
5199 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5200 VariantClear(&v);
5202 V_VT(&v) = VT_NULL;
5203 hres = IHTMLBodyElement_get_text(body, &v);
5204 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5205 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5206 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5207 VariantClear(&v);
5209 /* get_text - Valid Text */
5210 V_VT(&v) = VT_BSTR;
5211 V_BSTR(&v) = a2bstr("#FF0000");
5212 hres = IHTMLBodyElement_put_text(body, v);
5213 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5214 VariantClear(&v);
5216 V_VT(&v) = VT_NULL;
5217 hres = IHTMLBodyElement_get_text(body, &v);
5218 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5219 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5220 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5221 VariantClear(&v);
5224 static void test_body_funs(IHTMLBodyElement *body)
5226 VARIANT vbg, vDefaultbg;
5227 HRESULT hres;
5229 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5230 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5231 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5232 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5234 V_VT(&vbg) = VT_BSTR;
5235 V_BSTR(&vbg) = a2bstr("red");
5236 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5237 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5238 VariantClear(&vbg);
5240 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5241 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5242 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5243 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5244 VariantClear(&vbg);
5246 /* Restore Originial */
5247 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5248 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5249 VariantClear(&vDefaultbg);
5252 static void test_window(IHTMLDocument2 *doc)
5254 IHTMLWindow2 *window, *window2, *self;
5255 IHTMLDocument2 *doc2 = NULL;
5256 IDispatch *disp;
5257 IUnknown *unk;
5258 BSTR str;
5259 HRESULT hres;
5261 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5262 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5263 test_ifaces((IUnknown*)window, window_iids);
5264 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5266 hres = IHTMLWindow2_get_document(window, &doc2);
5267 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5268 ok(doc2 != NULL, "doc2 == NULL\n");
5270 test_ifaces((IUnknown*)doc2, doc_node_iids);
5271 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5273 test_ifaces((IUnknown*)doc, doc_obj_iids);
5274 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5276 unk = (void*)0xdeadbeef;
5277 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5278 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5279 ok(!unk, "unk = %p\n", unk);
5281 IHTMLDocument_Release(doc2);
5283 hres = IHTMLWindow2_get_window(window, &window2);
5284 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5285 ok(window2 != NULL, "window2 == NULL\n");
5287 hres = IHTMLWindow2_get_self(window, &self);
5288 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5289 ok(window2 != NULL, "self == NULL\n");
5291 ok(self == window2, "self != window2\n");
5293 IHTMLWindow2_Release(window2);
5294 IHTMLWindow2_Release(self);
5296 disp = NULL;
5297 hres = IHTMLDocument2_get_Script(doc, &disp);
5298 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5299 ok(disp == (void*)window, "disp != window\n");
5300 IDispatch_Release(disp);
5302 hres = IHTMLWindow2_toString(window, NULL);
5303 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5305 str = NULL;
5306 hres = IHTMLWindow2_toString(window, &str);
5307 ok(hres == S_OK, "toString failed: %08x\n", hres);
5308 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5309 SysFreeString(str);
5311 test_window_name(window, NULL);
5312 set_window_name(window, "test");
5313 test_window_length(window, 0);
5314 test_screen(window);
5316 IHTMLWindow2_Release(window);
5319 static void test_defaults(IHTMLDocument2 *doc)
5321 IHTMLStyleSheetsCollection *stylesheetcol;
5322 IHTMLCurrentStyle *cstyle;
5323 IHTMLBodyElement *body;
5324 IHTMLElement2 *elem2;
5325 IHTMLElement *elem;
5326 IHTMLStyle *style;
5327 LONG l;
5328 HRESULT hres;
5329 IHTMLElementCollection *collection;
5331 hres = IHTMLDocument2_get_body(doc, &elem);
5332 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5334 hres = IHTMLDocument2_get_images(doc, NULL);
5335 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5337 hres = IHTMLDocument2_get_images(doc, &collection);
5338 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5339 if(hres == S_OK)
5341 test_elem_collection((IUnknown*)collection, NULL, 0);
5342 IHTMLElementCollection_Release(collection);
5345 hres = IHTMLDocument2_get_applets(doc, NULL);
5346 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5348 hres = IHTMLDocument2_get_applets(doc, &collection);
5349 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5350 if(hres == S_OK)
5352 test_elem_collection((IUnknown*)collection, NULL, 0);
5353 IHTMLElementCollection_Release(collection);
5356 hres = IHTMLDocument2_get_links(doc, NULL);
5357 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5359 hres = IHTMLDocument2_get_links(doc, &collection);
5360 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5361 if(hres == S_OK)
5363 test_elem_collection((IUnknown*)collection, NULL, 0);
5364 IHTMLElementCollection_Release(collection);
5367 hres = IHTMLDocument2_get_forms(doc, NULL);
5368 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5370 hres = IHTMLDocument2_get_forms(doc, &collection);
5371 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5372 if(hres == S_OK)
5374 test_elem_collection((IUnknown*)collection, NULL, 0);
5375 IHTMLElementCollection_Release(collection);
5378 hres = IHTMLDocument2_get_anchors(doc, NULL);
5379 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5381 hres = IHTMLDocument2_get_anchors(doc, &collection);
5382 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5383 if(hres == S_OK)
5385 test_elem_collection((IUnknown*)collection, NULL, 0);
5386 IHTMLElementCollection_Release(collection);
5389 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5390 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5391 test_default_body(body);
5392 test_body_funs(body);
5393 IHTMLBodyElement_Release(body);
5395 hres = IHTMLElement_get_style(elem, &style);
5396 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5398 test_default_style(style);
5399 test_window(doc);
5400 test_compatmode(doc);
5401 test_location(doc);
5402 test_navigator(doc);
5404 elem2 = get_elem2_iface((IUnknown*)elem);
5405 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5406 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5407 if(SUCCEEDED(hres)) {
5408 test_current_style(cstyle);
5409 IHTMLCurrentStyle_Release(cstyle);
5411 IHTMLElement2_Release(elem2);
5413 IHTMLElement_Release(elem);
5415 test_set_csstext(style);
5416 IHTMLStyle_Release(style);
5418 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5419 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5421 l = 0xdeadbeef;
5422 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5423 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5424 ok(l == 0, "length = %d\n", l);
5426 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5428 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5429 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5431 test_default_selection(doc);
5432 test_doc_title(doc, "");
5435 static void test_tr_elem(IHTMLElement *elem)
5437 IHTMLElementCollection *col;
5438 IHTMLTableRow *row;
5439 HRESULT hres;
5441 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5443 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5444 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5445 if(FAILED(hres))
5446 return;
5448 col = NULL;
5449 hres = IHTMLTableRow_get_cells(row, &col);
5450 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5451 ok(col != NULL, "get_cells returned NULL\n");
5453 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5454 IHTMLElementCollection_Release(col);
5456 IHTMLTable_Release(row);
5459 static void test_table_elem(IHTMLElement *elem)
5461 IHTMLElementCollection *col;
5462 IHTMLTable *table;
5463 IHTMLDOMNode *node;
5464 HRESULT hres;
5466 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5467 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5469 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5470 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5471 if(FAILED(hres))
5472 return;
5474 col = NULL;
5475 hres = IHTMLTable_get_rows(table, &col);
5476 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5477 ok(col != NULL, "get_ros returned NULL\n");
5479 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5480 IHTMLElementCollection_Release(col);
5482 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5484 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5485 test_elem_tag((IUnknown*)node, "TABLE");
5486 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5487 IHTMLDOMNode_Release(node);
5489 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5490 test_elem_tag((IUnknown*)node, "TABLE");
5491 test_elem_all((IUnknown*)node, NULL, 0);
5492 IHTMLDOMNode_Release(node);
5494 IHTMLTable_Release(table);
5497 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5499 SAFEARRAYBOUND dim;
5500 SAFEARRAY *sa;
5501 VARIANT *var;
5502 BSTR str;
5503 HRESULT hres;
5505 dim.lLbound = 0;
5506 dim.cElements = 1;
5507 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5508 SafeArrayAccessData(sa, (void**)&var);
5509 V_VT(var) = VT_BSTR;
5510 V_BSTR(var) = str = a2bstr(text);
5511 SafeArrayUnaccessData(sa);
5513 if(ln)
5514 hres = IHTMLDocument2_writeln(doc, sa);
5515 else
5516 hres = IHTMLDocument2_write(doc, sa);
5517 ok(hres == S_OK, "write failed: %08x\n", hres);
5519 SysFreeString(str);
5520 SafeArrayDestroy(sa);
5523 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5525 IHTMLDocument2 *window_doc, *elem_doc;
5526 IHTMLFrameElement3 *frame_elem3;
5527 IHTMLWindow2 *content_window;
5528 HRESULT hres;
5530 content_window = get_frame_content_window(frame_elem);
5531 window_doc = get_window_doc(content_window);
5532 IHTMLWindow2_Release(content_window);
5534 elem_doc = get_elem_doc(frame_elem);
5535 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5537 if(!iframe) {
5538 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5539 if(SUCCEEDED(hres)) {
5540 IDispatch *disp = NULL;
5542 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5543 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5544 ok(disp != NULL, "contentDocument == NULL\n");
5545 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5547 IDispatch_Release(disp);
5548 IHTMLFrameElement3_Release(frame_elem3);
5549 }else {
5550 win_skip("IHTMLFrameElement3 not supported\n");
5554 IHTMLDocument2_Release(elem_doc);
5555 IHTMLDocument2_Release(window_doc);
5558 static void test_iframe_elem(IHTMLElement *elem)
5560 IHTMLDocument2 *content_doc, *owner_doc;
5561 IHTMLElementCollection *col;
5562 IHTMLWindow2 *content_window;
5563 IDispatch *disp;
5564 VARIANT errv;
5565 BSTR str;
5566 HRESULT hres;
5568 static const elem_type_t all_types[] = {
5569 ET_HTML,
5570 ET_HEAD,
5571 ET_TITLE,
5572 ET_BODY,
5573 ET_BR
5576 test_frame_doc((IUnknown*)elem, TRUE);
5578 content_window = get_frame_content_window((IUnknown*)elem);
5579 test_window_length(content_window, 0);
5581 content_doc = get_window_doc(content_window);
5582 IHTMLWindow2_Release(content_window);
5584 str = a2bstr("text/html");
5585 V_VT(&errv) = VT_ERROR;
5586 disp = NULL;
5587 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5588 SysFreeString(str);
5589 ok(hres == S_OK, "open failed: %08x\n", hres);
5590 ok(disp != NULL, "disp == NULL\n");
5591 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5592 IDispatch_Release(disp);
5594 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5595 doc_write(content_doc, TRUE, "</html>");
5597 hres = IHTMLDocument2_get_all(content_doc, &col);
5598 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5599 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5600 IHTMLElementCollection_Release(col);
5602 hres = IHTMLDocument2_close(content_doc);
5603 ok(hres == S_OK, "close failed: %08x\n", hres);
5605 owner_doc = get_owner_doc((IUnknown*)content_doc);
5606 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5608 IHTMLDocument2_Release(content_doc);
5611 static void test_stylesheet(IDispatch *disp)
5613 IHTMLStyleSheetRulesCollection *col = NULL;
5614 IHTMLStyleSheet *stylesheet;
5615 HRESULT hres;
5617 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5618 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5620 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5621 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5622 ok(col != NULL, "col == NULL\n");
5624 IHTMLStyleSheetRulesCollection_Release(col);
5625 IHTMLStyleSheet_Release(stylesheet);
5628 static void test_stylesheets(IHTMLDocument2 *doc)
5630 IHTMLStyleSheetsCollection *col = NULL;
5631 VARIANT idx, res;
5632 LONG len = 0;
5633 HRESULT hres;
5635 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5636 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5637 ok(col != NULL, "col == NULL\n");
5639 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5640 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5641 ok(len == 1, "len=%d\n", len);
5643 VariantInit(&res);
5644 V_VT(&idx) = VT_I4;
5645 V_I4(&idx) = 0;
5647 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5648 ok(hres == S_OK, "item failed: %08x\n", hres);
5649 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5650 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5651 test_stylesheet(V_DISPATCH(&res));
5652 VariantClear(&res);
5654 V_VT(&res) = VT_I4;
5655 V_VT(&idx) = VT_I4;
5656 V_I4(&idx) = 1;
5658 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5659 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5660 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5661 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5662 VariantClear(&res);
5664 IHTMLStyleSheetsCollection_Release(col);
5667 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5669 IDispatchEx *dispex;
5670 IHTMLDOMNode *node;
5671 DISPPARAMS dp = {NULL, NULL, 0, 0};
5672 VARIANT var;
5673 EXCEPINFO ei;
5674 LONG type;
5675 DISPID id;
5676 BSTR bstr;
5677 HRESULT hres;
5679 static const WCHAR w0[] = {'0',0};
5680 static const WCHAR w100[] = {'1','0','0',0};
5682 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5683 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5685 bstr = SysAllocString(w0);
5686 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5687 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5688 SysFreeString(bstr);
5690 VariantInit(&var);
5691 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5692 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5693 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5694 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5695 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5696 type = get_node_type((IUnknown*)node);
5697 ok(type == 3, "type=%d\n", type);
5698 IHTMLDOMNode_Release(node);
5699 VariantClear(&var);
5701 bstr = SysAllocString(w100);
5702 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5703 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5704 SysFreeString(bstr);
5706 IDispatchEx_Release(dispex);
5711 static void test_elems(IHTMLDocument2 *doc)
5713 IHTMLElementCollection *col;
5714 IHTMLDOMChildrenCollection *child_col;
5715 IHTMLElement *elem, *elem2, *elem3;
5716 IHTMLDOMNode *node, *node2;
5717 IHTMLWindow2 *window;
5718 IDispatch *disp;
5719 LONG type;
5720 HRESULT hres;
5721 IHTMLElementCollection *collection;
5722 IHTMLDocument3 *doc3;
5723 BSTR str;
5725 static const elem_type_t all_types[] = {
5726 ET_HTML,
5727 ET_HEAD,
5728 ET_TITLE,
5729 ET_STYLE,
5730 ET_BODY,
5731 ET_COMMENT,
5732 ET_A,
5733 ET_INPUT,
5734 ET_SELECT,
5735 ET_OPTION,
5736 ET_OPTION,
5737 ET_TEXTAREA,
5738 ET_TABLE,
5739 ET_TBODY,
5740 ET_TR,
5741 ET_TR,
5742 ET_TD,
5743 ET_TD,
5744 ET_SCRIPT,
5745 ET_TEST,
5746 ET_IMG,
5747 ET_IFRAME,
5748 ET_FORM
5751 static const elem_type_t item_types[] = {
5752 ET_A,
5753 ET_OPTION,
5754 ET_TEXTAREA
5757 hres = IHTMLDocument2_get_all(doc, &col);
5758 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5759 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5760 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5761 IHTMLElementCollection_Release(col);
5763 hres = IHTMLDocument2_get_images(doc, &collection);
5764 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5765 if(hres == S_OK)
5767 static const elem_type_t images_types[] = {ET_IMG};
5768 test_elem_collection((IUnknown*)collection, images_types, 1);
5770 IHTMLElementCollection_Release(collection);
5773 hres = IHTMLDocument2_get_links(doc, &collection);
5774 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5775 if(hres == S_OK)
5777 static const elem_type_t images_types[] = {ET_A};
5778 test_elem_collection((IUnknown*)collection, images_types, 1);
5780 IHTMLElementCollection_Release(collection);
5783 hres = IHTMLDocument2_get_anchors(doc, &collection);
5784 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5785 if(hres == S_OK)
5787 static const elem_type_t anchor_types[] = {ET_A};
5788 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5790 IHTMLElementCollection_Release(collection);
5793 elem = get_doc_elem(doc);
5794 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5795 IHTMLElement_Release(elem);
5797 get_elem_by_id(doc, "xxx", FALSE);
5798 elem = get_doc_elem_by_id(doc, "xxx");
5799 ok(!elem, "elem != NULL\n");
5801 elem = get_doc_elem_by_id(doc, "s");
5802 ok(elem != NULL, "elem == NULL\n");
5803 if(elem) {
5804 test_elem_type((IUnknown*)elem, ET_SELECT);
5805 test_elem_attr(elem, "xxx", NULL);
5806 test_elem_attr(elem, "id", "s");
5807 test_elem_class((IUnknown*)elem, NULL);
5808 test_elem_set_class((IUnknown*)elem, "cl");
5809 test_elem_set_class((IUnknown*)elem, NULL);
5810 test_elem_tabindex((IUnknown*)elem, 0);
5811 test_elem_set_tabindex((IUnknown*)elem, 1);
5812 test_elem_filters((IUnknown*)elem);
5814 node = test_node_get_parent((IUnknown*)elem);
5815 ok(node != NULL, "node == NULL\n");
5816 test_node_name((IUnknown*)node, "BODY");
5817 node2 = test_node_get_parent((IUnknown*)node);
5818 IHTMLDOMNode_Release(node);
5819 ok(node2 != NULL, "node == NULL\n");
5820 test_node_name((IUnknown*)node2, "HTML");
5821 node = test_node_get_parent((IUnknown*)node2);
5822 IHTMLDOMNode_Release(node2);
5823 ok(node != NULL, "node == NULL\n");
5824 if (node)
5826 test_node_name((IUnknown*)node, "#document");
5827 type = get_node_type((IUnknown*)node);
5828 ok(type == 9, "type=%d, expected 9\n", type);
5829 node2 = test_node_get_parent((IUnknown*)node);
5830 IHTMLDOMNode_Release(node);
5831 ok(node2 == NULL, "node != NULL\n");
5834 elem2 = test_elem_get_parent((IUnknown*)elem);
5835 ok(elem2 != NULL, "elem2 == NULL\n");
5836 test_node_name((IUnknown*)elem2, "BODY");
5837 elem3 = test_elem_get_parent((IUnknown*)elem2);
5838 IHTMLElement_Release(elem2);
5839 ok(elem3 != NULL, "elem3 == NULL\n");
5840 test_node_name((IUnknown*)elem3, "HTML");
5841 elem2 = test_elem_get_parent((IUnknown*)elem3);
5842 IHTMLElement_Release(elem3);
5843 ok(elem2 == NULL, "elem2 != NULL\n");
5845 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5846 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5847 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5849 test_elem_innertext(elem, "opt1opt2");
5851 IHTMLElement_Release(elem);
5854 elem = get_elem_by_id(doc, "s", TRUE);
5855 if(elem) {
5856 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
5857 IHTMLDocument2 *doc_node, *elem_doc;
5859 test_select_elem(select);
5861 test_elem_title((IUnknown*)select, NULL);
5862 test_elem_set_title((IUnknown*)select, "Title");
5863 test_elem_title((IUnknown*)select, "Title");
5864 test_elem_offset((IUnknown*)select);
5866 node = get_first_child((IUnknown*)select);
5867 ok(node != NULL, "node == NULL\n");
5868 if(node) {
5869 test_elem_type((IUnknown*)node, ET_OPTION);
5870 IHTMLDOMNode_Release(node);
5873 type = get_node_type((IUnknown*)select);
5874 ok(type == 1, "type=%d\n", type);
5876 IHTMLSelectElement_Release(select);
5878 elem_doc = get_elem_doc((IUnknown*)elem);
5880 doc_node = get_doc_node(doc);
5881 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5882 IHTMLDocument2_Release(doc_node);
5883 IHTMLDocument2_Release(elem_doc);
5885 IHTMLElement_Release(elem);
5888 elem = get_elem_by_id(doc, "sc", TRUE);
5889 if(elem) {
5890 IHTMLScriptElement *script;
5891 BSTR type;
5893 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5894 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5896 if(hres == S_OK)
5898 VARIANT_BOOL vb;
5900 hres = IHTMLScriptElement_put_type (script, NULL);
5901 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5902 hres = IHTMLScriptElement_get_type(script, &type);
5903 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5904 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
5906 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
5907 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5908 hres = IHTMLScriptElement_get_type(script, &type);
5909 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5910 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5912 SysFreeString(type);
5914 /* test defer */
5915 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5916 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5918 hres = IHTMLScriptElement_get_defer(script, &vb);
5919 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5920 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5922 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5923 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5926 IHTMLScriptElement_Release(script);
5929 elem = get_elem_by_id(doc, "in", TRUE);
5930 if(elem) {
5931 IHTMLInputElement *input;
5933 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5934 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5936 test_elem_id((IUnknown*)elem, "in");
5937 test_elem_put_id((IUnknown*)elem, "newin");
5938 test_input_get_disabled(input, VARIANT_FALSE);
5939 test_input_set_disabled(input, VARIANT_TRUE);
5940 test_input_set_disabled(input, VARIANT_FALSE);
5941 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5942 test_input_get_disabled(input, VARIANT_TRUE);
5943 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5944 test_input_get_disabled(input, VARIANT_FALSE);
5945 test_elem_client_size((IUnknown*)elem);
5946 test_input_type(input, "text");
5948 test_node_get_value_str((IUnknown*)elem, NULL);
5949 test_node_put_value_str((IUnknown*)elem, "test");
5950 test_node_get_value_str((IUnknown*)elem, NULL);
5951 test_input_value((IUnknown*)elem, NULL);
5952 test_input_put_value((IUnknown*)elem, "test");
5953 test_input_value((IUnknown*)elem, NULL);
5954 test_elem_class((IUnknown*)elem, "testclass");
5955 test_elem_tabindex((IUnknown*)elem, 2);
5956 test_elem_set_tabindex((IUnknown*)elem, 3);
5957 test_elem_title((IUnknown*)elem, "test title");
5959 test_input_get_defaultchecked(input, VARIANT_FALSE);
5960 test_input_set_defaultchecked(input, VARIANT_TRUE);
5961 test_input_set_defaultchecked(input, VARIANT_FALSE);
5963 test_input_get_checked(input, VARIANT_FALSE);
5964 test_input_set_checked(input, VARIANT_TRUE);
5965 test_input_set_checked(input, VARIANT_FALSE);
5967 test_input_name(input, NULL);
5968 test_input_set_name(input, "test");
5970 test_input_src(input, NULL);
5971 test_input_set_src(input, "about:blank");
5973 IHTMLInputElement_Release(input);
5974 IHTMLElement_Release(elem);
5977 elem = get_elem_by_id(doc, "imgid", TRUE);
5978 if(elem) {
5979 test_img_src((IUnknown*)elem, "");
5980 test_img_set_src((IUnknown*)elem, "about:blank");
5981 test_img_alt((IUnknown*)elem, NULL);
5982 test_img_set_alt((IUnknown*)elem, "alt test");
5983 test_img_name((IUnknown*)elem, "WineImg");
5984 IHTMLElement_Release(elem);
5987 elem = get_doc_elem_by_id(doc, "tbl");
5988 ok(elem != NULL, "elem == NULL\n");
5989 if(elem) {
5990 test_table_elem(elem);
5991 IHTMLElement_Release(elem);
5994 elem = get_doc_elem_by_id(doc, "row2");
5995 ok(elem != NULL, "elem == NULL\n");
5996 if(elem) {
5997 test_tr_elem(elem);
5998 IHTMLElement_Release(elem);
6001 elem = get_doc_elem_by_id(doc, "ifr");
6002 ok(elem != NULL, "elem == NULL\n");
6003 if(elem) {
6004 test_iframe_elem(elem);
6005 IHTMLElement_Release(elem);
6008 elem = get_elem_by_id(doc, "a", TRUE);
6009 if(elem) {
6010 test_anchor_href((IUnknown*)elem, "http://test/");
6011 IHTMLElement_Release(elem);
6014 hres = IHTMLDocument2_get_body(doc, &elem);
6015 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6017 node = get_first_child((IUnknown*)elem);
6018 ok(node != NULL, "node == NULL\n");
6019 if(node) {
6020 test_ifaces((IUnknown*)node, text_iids);
6021 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6023 node2 = get_first_child((IUnknown*)node);
6024 ok(!node2, "node2 != NULL\n");
6026 type = get_node_type((IUnknown*)node);
6027 ok(type == 3, "type=%d\n", type);
6029 test_node_get_value_str((IUnknown*)node, "text test");
6030 test_node_put_value_str((IUnknown*)elem, "test text");
6031 test_node_get_value_str((IUnknown*)node, "text test");
6033 IHTMLDOMNode_Release(node);
6036 child_col = get_child_nodes((IUnknown*)elem);
6037 ok(child_col != NULL, "child_coll == NULL\n");
6038 if(child_col) {
6039 LONG length = 0;
6041 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6043 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6044 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6045 ok(length, "length=0\n");
6047 node2 = NULL;
6048 node = get_child_item(child_col, 0);
6049 ok(node != NULL, "node == NULL\n");
6050 if(node) {
6051 type = get_node_type((IUnknown*)node);
6052 ok(type == 3, "type=%d\n", type);
6053 node2 = node_get_next((IUnknown*)node);
6054 IHTMLDOMNode_Release(node);
6057 node = get_child_item(child_col, 1);
6058 ok(node != NULL, "node == NULL\n");
6059 if(node) {
6060 type = get_node_type((IUnknown*)node);
6061 ok(type == 8, "type=%d\n", type);
6063 test_elem_id((IUnknown*)node, NULL);
6064 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6065 IHTMLDOMNode_Release(node2);
6066 IHTMLDOMNode_Release(node);
6069 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6070 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6072 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6073 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6075 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6076 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6078 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6079 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6081 test_child_col_disp(child_col);
6083 IHTMLDOMChildrenCollection_Release(child_col);
6086 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6087 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6088 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6090 IHTMLElement_Release(elem);
6092 elem = get_doc_elem_by_id(doc, "frm");
6093 ok(elem != NULL, "elem == NULL\n");
6094 if(elem) {
6095 test_form_length((IUnknown*)elem, 0);
6096 IHTMLElement_Release(elem);
6099 test_stylesheets(doc);
6100 test_create_option_elem(doc);
6101 test_create_img_elem(doc);
6103 elem = get_doc_elem_by_id(doc, "tbl");
6104 ok(elem != NULL, "elem = NULL\n");
6105 test_elem_set_innertext(elem, "inner text");
6106 IHTMLElement_Release(elem);
6108 test_doc_title(doc, "test");
6109 test_doc_set_title(doc, "test title");
6110 test_doc_title(doc, "test title");
6112 disp = NULL;
6113 hres = IHTMLDocument2_get_Script(doc, &disp);
6114 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6115 if(hres == S_OK)
6117 IDispatchEx *dispex;
6118 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6119 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6120 if(hres == S_OK)
6122 DISPID pid = -1;
6123 BSTR str = a2bstr("Testing");
6124 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6125 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6126 ok(pid != -1, "pid == -1\n");
6127 SysFreeString(str);
6128 IDispatchEx_Release(dispex);
6131 IDispatch_Release(disp);
6133 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6134 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6136 str = a2bstr("img");
6137 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6138 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6139 SysFreeString(str);
6140 if(hres == S_OK)
6142 static const elem_type_t img_types[] = { ET_IMG };
6144 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6145 IHTMLElementCollection_Release(col);
6148 elem = get_doc_elem_by_id(doc, "y");
6149 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6150 test_elem_innerhtml((IUnknown*)elem, "inner html");
6151 test_elem_set_innerhtml((IUnknown*)elem, "");
6152 test_elem_innerhtml((IUnknown*)elem, NULL);
6153 node = node_get_next((IUnknown*)elem);
6154 ok(!node, "node = %p\n", node);
6156 elem2 = get_doc_elem_by_id(doc, "x");
6157 test_elem_tag((IUnknown*)elem2, "A");
6158 node = node_get_next((IUnknown*)elem2);
6159 IHTMLDOMNode_Release(node);
6160 IHTMLElement_Release(elem2);
6161 IHTMLElement_Release(elem);
6163 IHTMLDocument3_Release(doc3);
6165 elem = get_elem_by_id(doc, "s", TRUE);
6166 if(elem) {
6167 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6169 test_select_put_length((IUnknown*)elem, 3);
6170 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6171 test_select_put_length((IUnknown*)elem, 1);
6172 test_elem_all((IUnknown*)elem, select_types, 1);
6173 IHTMLElement_Release(elem);
6176 window = get_doc_window(doc);
6177 test_window_name(window, NULL);
6178 set_window_name(window, "test name");
6179 test_window_length(window, 1);
6180 IHTMLWindow2_Release(window);
6183 static void test_elems2(IHTMLDocument2 *doc)
6185 IHTMLElement *elem, *elem2, *div;
6187 static const elem_type_t outer_types[] = {
6188 ET_BR,
6189 ET_A
6192 div = get_doc_elem_by_id(doc, "divid");
6194 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6195 elem2 = get_doc_elem_by_id(doc, "innerid");
6196 ok(elem2 != NULL, "elem2 == NULL\n");
6197 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6198 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6199 IHTMLElement_Release(elem2);
6201 elem2 = get_doc_elem_by_id(doc, "aid");
6202 ok(elem2 != NULL, "elem2 == NULL\n");
6203 test_elem_set_outerhtml((IUnknown*)elem2, "");
6204 test_elem_all((IUnknown*)div, outer_types, 1);
6205 IHTMLElement_Release(elem2);
6207 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6208 elem = get_elem_by_id(doc, "ta", TRUE);
6209 if(elem) {
6210 test_textarea_value((IUnknown*)elem, NULL);
6211 test_textarea_put_value((IUnknown*)elem, "test");
6212 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6213 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6214 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6215 IHTMLElement_Release(elem);
6218 test_elem_set_innerhtml((IUnknown*)div,
6219 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6220 elem = get_elem_by_id(doc, "form", TRUE);
6221 if(elem) {
6222 test_form_length((IUnknown*)elem, 2);
6223 test_form_item(elem);
6224 test_form_action((IUnknown*)elem, NULL);
6225 test_form_put_action((IUnknown*)elem, "about:blank");
6226 IHTMLElement_Release(elem);
6229 IHTMLElement_Release(div);
6232 static void test_create_elems(IHTMLDocument2 *doc)
6234 IHTMLElement *elem, *body, *elem2;
6235 IHTMLDOMNode *node, *node2, *node3, *comment;
6236 IHTMLDocument5 *doc5;
6237 IDispatch *disp;
6238 VARIANT var;
6239 LONG type;
6240 HRESULT hres;
6241 BSTR str;
6243 static const elem_type_t types1[] = { ET_TESTG };
6245 elem = test_create_elem(doc, "TEST");
6246 test_elem_tag((IUnknown*)elem, "TEST");
6247 type = get_node_type((IUnknown*)elem);
6248 ok(type == 1, "type=%d\n", type);
6249 test_ifaces((IUnknown*)elem, elem_iids);
6250 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6252 hres = IHTMLDocument2_get_body(doc, &body);
6253 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6254 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6256 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6257 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6258 elem2 = get_elem_iface((IUnknown*)node);
6259 IHTMLElement_Release(elem2);
6261 hres = IHTMLElement_get_all(body, &disp);
6262 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6263 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6264 IDispatch_Release(disp);
6266 test_node_remove_child((IUnknown*)body, node);
6268 hres = IHTMLElement_get_all(body, &disp);
6269 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6270 test_elem_collection((IUnknown*)disp, NULL, 0);
6271 IDispatch_Release(disp);
6272 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6274 IHTMLElement_Release(elem);
6275 IHTMLDOMNode_Release(node);
6277 node = test_create_text(doc, "test");
6278 test_ifaces((IUnknown*)node, text_iids);
6279 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6280 test_text_length((IUnknown*)node, 4);
6282 V_VT(&var) = VT_NULL;
6283 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6284 IHTMLDOMNode_Release(node);
6286 node = test_create_text(doc, "insert ");
6288 V_VT(&var) = VT_DISPATCH;
6289 V_DISPATCH(&var) = (IDispatch*)node2;
6290 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6291 IHTMLDOMNode_Release(node);
6292 IHTMLDOMNode_Release(node2);
6293 IHTMLDOMNode_Release(node3);
6295 test_elem_innertext(body, "insert test");
6296 test_elem_innerhtml((IUnknown*)body, "insert test");
6298 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6299 if(hres == S_OK)
6301 str = a2bstr("testing");
6302 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6303 SysFreeString(str);
6304 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6305 if(hres == S_OK)
6307 type = get_node_type((IUnknown*)comment);
6308 ok(type == 8, "type=%d, expected 8\n", type);
6310 test_node_get_value_str((IUnknown*)comment, "testing");
6311 test_elem_title((IUnknown*)comment, NULL);
6312 test_elem_set_title((IUnknown*)comment, "comment title");
6313 test_elem_title((IUnknown*)comment, "comment title");
6314 test_comment_text((IUnknown*)comment, "<!--testing-->");
6315 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6317 IHTMLDOMNode_Release(comment);
6320 IHTMLDocument5_Release(doc5);
6323 IHTMLElement_Release(body);
6326 static void test_null_write(IHTMLDocument2 *doc)
6328 HRESULT hres;
6330 doc_write(doc, FALSE, NULL);
6331 doc_write(doc, TRUE, NULL);
6333 hres = IHTMLDocument2_write(doc, NULL);
6334 ok(hres == S_OK,
6335 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6337 hres = IHTMLDocument2_writeln(doc, NULL);
6338 ok(hres == S_OK,
6339 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6342 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6344 IOleCommandTarget *cmdtrg;
6345 HRESULT hres;
6347 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6348 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6350 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6351 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6353 IOleCommandTarget_Release(cmdtrg);
6356 static void test_indent(IHTMLDocument2 *doc)
6358 IHTMLElementCollection *col;
6359 IHTMLTxtRange *range;
6360 HRESULT hres;
6362 static const elem_type_t all_types[] = {
6363 ET_HTML,
6364 ET_HEAD,
6365 ET_TITLE,
6366 ET_BODY,
6367 ET_BR,
6368 ET_A,
6371 static const elem_type_t indent_types[] = {
6372 ET_HTML,
6373 ET_HEAD,
6374 ET_TITLE,
6375 ET_BODY,
6376 ET_BLOCKQUOTE,
6377 ET_P,
6378 ET_BR,
6379 ET_A,
6382 hres = IHTMLDocument2_get_all(doc, &col);
6383 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6384 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6385 IHTMLElementCollection_Release(col);
6387 range = test_create_body_range(doc);
6388 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6389 IHTMLTxtRange_Release(range);
6391 hres = IHTMLDocument2_get_all(doc, &col);
6392 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6393 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6394 IHTMLElementCollection_Release(col);
6397 static void test_cond_comment(IHTMLDocument2 *doc)
6399 IHTMLElementCollection *col;
6400 HRESULT hres;
6402 static const elem_type_t all_types[] = {
6403 ET_HTML,
6404 ET_HEAD,
6405 ET_TITLE,
6406 ET_BODY,
6407 ET_BR
6410 hres = IHTMLDocument2_get_all(doc, &col);
6411 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6412 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6413 IHTMLElementCollection_Release(col);
6416 static void test_frame(IDispatch *disp, const char *exp_id)
6418 IHTMLWindow2 *frame2, *parent, *top;
6419 IHTMLDocument2 *parent_doc, *top_doc;
6420 IHTMLWindow4 *frame;
6421 IHTMLFrameBase *frame_elem;
6422 HRESULT hres;
6424 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6425 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6426 if(FAILED(hres))
6427 return;
6429 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6430 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6431 IHTMLWindow4_Release(frame);
6432 if(FAILED(hres))
6433 return;
6435 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6436 test_frame_doc((IUnknown*)frame_elem, FALSE);
6437 test_elem_id((IUnknown*)frame_elem, exp_id);
6438 IHTMLElement_Release(frame_elem);
6440 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6441 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6442 if(FAILED(hres))
6443 return;
6445 hres = IHTMLWindow2_get_parent(frame2, &parent);
6446 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6447 if(FAILED(hres)){
6448 IHTMLWindow2_Release(frame2);
6449 return;
6452 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6453 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6454 IHTMLWindow2_Release(parent);
6455 if(FAILED(hres)){
6456 IHTMLWindow2_Release(frame2);
6457 return;
6460 test_doc_title(parent_doc, "frameset test");
6461 IHTMLDocument2_Release(parent_doc);
6463 /* test get_top */
6464 hres = IHTMLWindow2_get_top(frame2, &top);
6465 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6466 IHTMLWindow2_Release(frame2);
6467 if(FAILED(hres))
6468 return;
6470 hres = IHTMLWindow2_get_document(top, &top_doc);
6471 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6472 IHTMLWindow2_Release(top);
6473 if(FAILED(hres))
6474 return;
6476 test_doc_title(top_doc, "frameset test");
6477 IHTMLDocument2_Release(top_doc);
6480 static void test_frameset(IHTMLDocument2 *doc)
6482 IHTMLWindow2 *window;
6483 IHTMLFramesCollection2 *frames;
6484 IHTMLElement *elem;
6485 IHTMLFrameBase *fbase;
6486 LONG length;
6487 VARIANT index_var, result_var;
6488 BSTR str;
6489 HRESULT hres;
6491 window = get_doc_window(doc);
6493 /* test using IHTMLFramesCollection object */
6495 hres = IHTMLWindow2_get_frames(window, &frames);
6496 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6497 IHTMLWindow2_Release(window);
6498 if(FAILED(hres))
6499 return;
6501 /* test result length */
6502 hres = IHTMLFramesCollection2_get_length(frames, &length);
6503 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6504 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6506 /* test first frame */
6507 V_VT(&index_var) = VT_I4;
6508 V_I4(&index_var) = 0;
6509 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6510 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6511 if(SUCCEEDED(hres)) {
6512 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6513 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6515 VariantClear(&result_var);
6517 /* test second frame */
6518 V_I4(&index_var) = 1;
6519 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6520 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6521 if(SUCCEEDED(hres)) {
6522 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6523 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6525 VariantClear(&result_var);
6527 /* fail on next frame */
6528 V_I4(&index_var) = 3;
6529 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6530 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6531 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6532 VariantClear(&result_var);
6534 /* string argument (element id lookup) */
6535 V_VT(&index_var) = VT_BSTR;
6536 V_BSTR(&index_var) = a2bstr("fr1");
6537 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6538 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6539 if(SUCCEEDED(hres)) {
6540 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6541 test_frame(V_DISPATCH(&result_var), "fr1");
6543 VariantClear(&result_var);
6544 VariantClear(&index_var);
6546 /* invalid argument */
6547 V_VT(&index_var) = VT_BOOL;
6548 V_BOOL(&index_var) = VARIANT_TRUE;
6549 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6550 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6551 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6552 VariantClear(&result_var);
6554 IHTMLFramesCollection2_Release(frames);
6556 /* test using IHTMLWindow2 inheritance */
6558 /* test result length */
6559 hres = IHTMLWindow2_get_length(window, &length);
6560 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6561 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6563 /* test first frame */
6564 V_VT(&index_var) = VT_I4;
6565 V_I4(&index_var) = 0;
6566 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6567 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6568 if(SUCCEEDED(hres)) {
6569 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6570 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6572 VariantClear(&result_var);
6574 /* test second frame */
6575 V_I4(&index_var) = 1;
6576 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6577 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6578 if(SUCCEEDED(hres)) {
6579 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6580 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6582 VariantClear(&result_var);
6584 /* fail on next frame */
6585 V_I4(&index_var) = 3;
6586 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6587 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6588 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6589 VariantClear(&result_var);
6591 /* string argument (element id lookup) */
6592 V_VT(&index_var) = VT_BSTR;
6593 V_BSTR(&index_var) = a2bstr("fr2");
6594 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6595 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6596 if(SUCCEEDED(hres)) {
6597 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6598 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6600 VariantClear(&result_var);
6601 VariantClear(&index_var);
6603 /* invalid argument */
6604 V_VT(&index_var) = VT_BOOL;
6605 V_BOOL(&index_var) = VARIANT_TRUE;
6606 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6607 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6608 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6609 VariantClear(&result_var);
6611 /* getElementById with node name attributes */
6612 elem = get_doc_elem_by_id(doc, "nm1");
6613 test_elem_id((IUnknown*)elem, "fr1");
6615 /* get/put scrolling */
6616 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6617 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6619 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6620 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6621 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6622 SysFreeString(str);
6624 str = a2bstr("no");
6625 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6626 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6627 SysFreeString(str);
6629 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6630 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6631 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6632 SysFreeString(str);
6634 str = a2bstr("junk");
6635 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6636 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6637 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6638 SysFreeString(str);
6640 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6641 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6642 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6643 SysFreeString(str);
6645 /* get_name */
6646 hres = IHTMLFrameBase_get_name(fbase, &str);
6647 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6648 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6649 SysFreeString(str);
6651 IHTMLFrameBase_Release(fbase);
6652 IHTMLElement_Release(elem);
6654 /* get_name with no name attr */
6655 elem = get_doc_elem_by_id(doc, "fr3");
6656 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6657 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6659 hres = IHTMLFrameBase_get_name(fbase, &str);
6660 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6661 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6662 SysFreeString(str);
6664 IHTMLFrameBase_Release(fbase);
6665 IHTMLElement_Release(elem);
6668 static IHTMLDocument2 *notif_doc;
6669 static BOOL doc_complete;
6671 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6672 REFIID riid, void**ppv)
6674 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6675 *ppv = iface;
6676 return S_OK;
6679 ok(0, "unexpected call\n");
6680 return E_NOINTERFACE;
6683 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6685 return 2;
6688 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6690 return 1;
6693 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6695 if(dispID == DISPID_READYSTATE){
6696 BSTR state;
6697 HRESULT hres;
6699 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6700 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6702 if(!strcmp_wa(state, "complete"))
6703 doc_complete = TRUE;
6705 SysFreeString(state);
6708 return S_OK;
6711 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6713 ok(0, "unexpected call\n");
6714 return E_NOTIMPL;
6717 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6718 PropertyNotifySink_QueryInterface,
6719 PropertyNotifySink_AddRef,
6720 PropertyNotifySink_Release,
6721 PropertyNotifySink_OnChanged,
6722 PropertyNotifySink_OnRequestEdit
6725 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6727 static IHTMLDocument2 *create_doc_with_string(const char *str)
6729 IPersistStreamInit *init;
6730 IStream *stream;
6731 IHTMLDocument2 *doc;
6732 HGLOBAL mem;
6733 SIZE_T len;
6735 notif_doc = doc = create_document();
6736 if(!doc)
6737 return NULL;
6739 doc_complete = FALSE;
6740 len = strlen(str);
6741 mem = GlobalAlloc(0, len);
6742 memcpy(mem, str, len);
6743 CreateStreamOnHGlobal(mem, TRUE, &stream);
6745 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6747 IPersistStreamInit_Load(init, stream);
6748 IPersistStreamInit_Release(init);
6749 IStream_Release(stream);
6751 return doc;
6754 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6756 IConnectionPointContainer *container;
6757 IConnectionPoint *cp;
6758 DWORD cookie;
6759 HRESULT hres;
6761 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6762 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6764 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6765 IConnectionPointContainer_Release(container);
6766 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6768 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6769 IConnectionPoint_Release(cp);
6770 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6773 typedef void (*domtest_t)(IHTMLDocument2*);
6775 static void run_domtest(const char *str, domtest_t test)
6777 IHTMLDocument2 *doc;
6778 ULONG ref;
6779 MSG msg;
6781 doc = create_doc_with_string(str);
6782 if(!doc)
6783 return;
6785 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6787 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6788 TranslateMessage(&msg);
6789 DispatchMessage(&msg);
6792 test(doc);
6794 ref = IHTMLDocument2_Release(doc);
6795 ok(!ref ||
6796 ref == 1, /* Vista */
6797 "ref = %d\n", ref);
6800 START_TEST(dom)
6802 CoInitialize(NULL);
6804 run_domtest(doc_str1, test_doc_elem);
6805 run_domtest(doc_str1, test_get_set_attr);
6806 run_domtest(range_test_str, test_txtrange);
6807 run_domtest(range_test2_str, test_txtrange2);
6808 if (winetest_interactive || ! is_ie_hardened()) {
6809 run_domtest(elem_test_str, test_elems);
6810 }else {
6811 skip("IE running in Enhanced Security Configuration\n");
6813 run_domtest(elem_test2_str, test_elems2);
6814 run_domtest(doc_blank, test_create_elems);
6815 run_domtest(doc_blank, test_defaults);
6816 run_domtest(doc_blank, test_null_write);
6817 run_domtest(indent_test_str, test_indent);
6818 run_domtest(cond_comment_str, test_cond_comment);
6819 run_domtest(frameset_str, test_frameset);
6821 CoUninitialize();