mshtml: Don't access url in translate_url after freeing it.
[wine/hacks.git] / dlls / mshtml / tests / dom.c
blobc6f54793ce5c726a3cf6ea8fb5206c05b6fa3384
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_disp(__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_text_iface(u) _get_text_iface(__LINE__,u)
677 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
679 IHTMLDOMTextNode *text;
680 HRESULT hres;
682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
683 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
684 return text;
687 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
688 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
690 IHTMLCommentElement *comment;
691 HRESULT hres;
693 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
694 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
695 return comment;
698 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
699 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
701 IHTMLDOMNode *node = _get_node_iface(line, unk);
702 BSTR name;
703 HRESULT hres;
705 hres = IHTMLDOMNode_get_nodeName(node, &name);
706 IHTMLDOMNode_Release(node);
707 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
708 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
710 SysFreeString(name);
713 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
714 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
716 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
717 IDispatch *disp = (void*)0xdeadbeef;
718 IHTMLDocument2 *doc = NULL;
719 HRESULT hres;
721 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
722 IHTMLDOMNode2_Release(node);
723 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
725 if(disp) {
726 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
727 IDispatch_Release(disp);
728 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
731 return doc;
734 #define get_doc_window(d) _get_doc_window(__LINE__,d)
735 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
737 IHTMLWindow2 *window;
738 HRESULT hres;
740 window = NULL;
741 hres = IHTMLDocument2_get_parentWindow(doc, &window);
742 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
743 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
745 return window;
748 #define clone_node(n,d) _clone_node(__LINE__,n,d)
749 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
751 IHTMLDOMNode *node = _get_node_iface(line, unk);
752 IHTMLDOMNode *ret = NULL;
753 HRESULT hres;
755 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
756 IHTMLDOMNode_Release(node);
757 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
758 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
760 return ret;
764 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
765 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
767 IHTMLElement *elem = _get_elem_iface(line, unk);
768 BSTR tag;
769 HRESULT hres;
771 hres = IHTMLElement_get_tagName(elem, &tag);
772 IHTMLElement_Release(elem);
773 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
774 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
776 SysFreeString(tag);
779 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
780 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
782 _test_elem_tag(line, unk, elem_type_infos[type].tag);
783 _test_ifaces(line, unk, elem_type_infos[type].iids);
785 if(elem_type_infos[type].dispiid && type != ET_A)
786 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
789 #define get_node_type(n) _get_node_type(__LINE__,n)
790 static LONG _get_node_type(unsigned line, IUnknown *unk)
792 IHTMLDOMNode *node = _get_node_iface(line, unk);
793 LONG type = -1;
794 HRESULT hres;
796 hres = IHTMLDOMNode_get_nodeType(node, &type);
797 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
799 IHTMLDOMNode_Release(node);
801 return type;
804 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
805 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
807 IHTMLDOMNode *node = _get_node_iface(line, unk);
808 IHTMLDOMChildrenCollection *col = NULL;
809 IDispatch *disp;
810 HRESULT hres;
812 hres = IHTMLDOMNode_get_childNodes(node, &disp);
813 IHTMLDOMNode_Release(node);
814 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
815 if(FAILED(hres))
816 return NULL;
818 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
819 IDispatch_Release(disp);
820 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
822 return col;
825 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
826 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
828 IHTMLDOMNode *node = NULL;
829 IDispatch *disp;
830 HRESULT hres;
832 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
833 ok(hres == S_OK, "item failed: %08x\n", hres);
835 node = _get_node_iface(line, (IUnknown*)disp);
836 IDispatch_Release(disp);
838 return node;
841 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
842 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
844 VARIANT value;
845 BSTR tmp;
846 HRESULT hres;
848 VariantInit(&value);
850 tmp = a2bstr(name);
851 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
852 SysFreeString(tmp);
853 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
855 if(exval) {
856 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
857 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
858 }else {
859 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
862 VariantClear(&value);
865 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
866 static void _test_elem_offset(unsigned line, IUnknown *unk)
868 IHTMLElement *elem = _get_elem_iface(line, unk);
869 LONG l;
870 HRESULT hres;
872 hres = IHTMLElement_get_offsetTop(elem, &l);
873 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
875 hres = IHTMLElement_get_offsetHeight(elem, &l);
876 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
878 hres = IHTMLElement_get_offsetWidth(elem, &l);
879 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
881 IHTMLElement_Release(elem);
884 #define get_doc_node(d) _get_doc_node(__LINE__,d)
885 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
887 IHTMLWindow2 *window;
888 IHTMLDocument2 *ret;
889 HRESULT hres;
891 hres = IHTMLDocument2_get_parentWindow(doc, &window);
892 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
894 hres = IHTMLWindow2_get_document(window, &ret);
895 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
896 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
898 return ret;
901 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
902 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
904 BSTR name;
905 HRESULT hres;
907 hres = IHTMLWindow2_get_name(window, &name);
908 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
909 if(exname)
910 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
911 else
912 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
915 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
916 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
918 BSTR str;
919 HRESULT hres;
921 str = a2bstr(name);
922 hres = IHTMLWindow2_put_name(window, str);
923 SysFreeString(str);
924 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
926 _test_window_name(line, window, name);
929 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
930 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
932 LONG length = -1;
933 HRESULT hres;
935 hres = IHTMLWindow2_get_length(window, &length);
936 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
937 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
940 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
941 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
943 IHTMLFrameBase2 *base2;
944 IHTMLWindow2 *window;
945 HRESULT hres;
947 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
948 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
950 window = NULL;
951 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
952 IHTMLFrameBase2_Release(base2);
953 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
954 ok(window != NULL, "contentWindow = NULL\n");
956 return window;
959 static void test_get_set_attr(IHTMLDocument2 *doc)
961 IHTMLElement *elem;
962 IHTMLDocument3 *doc3;
963 HRESULT hres;
964 BSTR bstr;
965 VARIANT val;
967 /* grab an element to test with */
968 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
969 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
971 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
972 IHTMLDocument3_Release(doc3);
973 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
975 /* get a non-present attribute */
976 bstr = a2bstr("notAnAttribute");
977 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
978 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
979 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
980 VariantClear(&val);
981 SysFreeString(bstr);
983 /* get a present attribute */
984 bstr = a2bstr("scrollHeight");
985 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
986 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
987 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
988 VariantClear(&val);
989 SysFreeString(bstr);
991 /* create a new BSTR attribute */
992 bstr = a2bstr("newAttribute");
994 V_VT(&val) = VT_BSTR;
995 V_BSTR(&val) = a2bstr("the value");
996 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
997 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
998 VariantClear(&val);
1000 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1001 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1002 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1003 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)));
1004 VariantClear(&val);
1006 /* overwrite the attribute with a BOOL */
1007 V_VT(&val) = VT_BOOL;
1008 V_BOOL(&val) = VARIANT_TRUE;
1009 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1010 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1011 VariantClear(&val);
1013 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1014 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1015 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1016 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1017 VariantClear(&val);
1019 SysFreeString(bstr);
1021 /* case-insensitive */
1022 bstr = a2bstr("newattribute");
1023 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1024 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1025 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1026 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1027 VariantClear(&val);
1028 SysFreeString(bstr);
1030 IHTMLElement_Release(elem);
1033 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1034 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1036 IHTMLElement *elem;
1037 IHTMLDocument3 *doc3;
1038 HRESULT hres;
1040 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1041 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1042 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1043 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1044 IHTMLDocument3_Release(doc3);
1046 return elem;
1049 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1050 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1052 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1053 BSTR str;
1054 HRESULT hres;
1056 hres = IHTMLAnchorElement_get_href(anchor, &str);
1057 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1058 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1059 SysFreeString(str);
1061 _test_disp_value(line, unk, exhref);
1064 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1065 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1067 BSTR bstr;
1068 HRESULT hres;
1070 hres = IHTMLOptionElement_get_text(option, &bstr);
1071 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1072 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1073 SysFreeString(bstr);
1076 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1077 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1079 BSTR bstr;
1080 HRESULT hres;
1082 bstr = a2bstr(text);
1083 hres = IHTMLOptionElement_put_text(option, bstr);
1084 SysFreeString(bstr);
1085 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1087 _test_option_text(line, option, text);
1090 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1091 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1093 BSTR bstr;
1094 HRESULT hres;
1096 hres = IHTMLOptionElement_get_value(option, &bstr);
1097 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1098 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1099 SysFreeString(bstr);
1102 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1103 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1105 BSTR bstr;
1106 HRESULT hres;
1108 bstr = a2bstr(value);
1109 hres = IHTMLOptionElement_put_value(option, bstr);
1110 SysFreeString(bstr);
1111 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1113 _test_option_value(line, option, value);
1116 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1117 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1119 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1120 BSTR text;
1121 HRESULT hres;
1123 text = a2bstr(extext);
1124 hres = IHTMLCommentElement_get_text(comment, &text);
1125 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1126 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1128 IHTMLCommentElement_Release(comment);
1129 SysFreeString(text);
1132 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1133 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1134 const char *txt, const char *val)
1136 IHTMLOptionElementFactory *factory;
1137 IHTMLOptionElement *option;
1138 IHTMLWindow2 *window;
1139 VARIANT text, value, empty;
1140 HRESULT hres;
1142 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1143 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1145 hres = IHTMLWindow2_get_Option(window, &factory);
1146 IHTMLWindow2_Release(window);
1147 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1149 V_VT(&text) = VT_BSTR;
1150 V_BSTR(&text) = a2bstr(txt);
1151 V_VT(&value) = VT_BSTR;
1152 V_BSTR(&value) = a2bstr(val);
1153 V_VT(&empty) = VT_EMPTY;
1155 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1156 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1158 IHTMLOptionElementFactory_Release(factory);
1159 VariantClear(&text);
1160 VariantClear(&value);
1162 _test_option_text(line, option, txt);
1163 _test_option_value(line, option, val);
1165 return option;
1168 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1169 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1171 LONG found = -1;
1172 HRESULT hres;
1174 hres = IHTMLImgElement_get_width(img, &found);
1175 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1176 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1179 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1180 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1182 HRESULT hres;
1184 hres = IHTMLImgElement_put_width(img, width);
1185 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1187 _test_img_width(line, img, width);
1190 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1191 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1193 LONG found = -1;
1194 HRESULT hres;
1196 hres = IHTMLImgElement_get_height(img, &found);
1197 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1198 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1201 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1202 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1204 HRESULT hres;
1206 hres = IHTMLImgElement_put_height(img, height);
1207 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1209 _test_img_height(line, img, height);
1212 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1213 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1214 LONG wdth, LONG hght)
1216 IHTMLImageElementFactory *factory;
1217 IHTMLImgElement *img;
1218 IHTMLWindow2 *window;
1219 VARIANT width, height;
1220 char buf[16];
1221 HRESULT hres;
1223 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1224 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1226 hres = IHTMLWindow2_get_Image(window, &factory);
1227 IHTMLWindow2_Release(window);
1228 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1230 test_ifaces((IUnknown*)factory, img_factory_iids);
1231 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1233 if(wdth >= 0){
1234 snprintf(buf, 16, "%d", wdth);
1235 V_VT(&width) = VT_BSTR;
1236 V_BSTR(&width) = a2bstr(buf);
1237 }else{
1238 V_VT(&width) = VT_EMPTY;
1239 wdth = 0;
1242 if(hght >= 0){
1243 snprintf(buf, 16, "%d", hght);
1244 V_VT(&height) = VT_BSTR;
1245 V_BSTR(&height) = a2bstr(buf);
1246 }else{
1247 V_VT(&height) = VT_EMPTY;
1248 hght = 0;
1251 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1252 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1254 IHTMLImageElementFactory_Release(factory);
1255 VariantClear(&width);
1256 VariantClear(&height);
1258 if(SUCCEEDED(hres)) {
1259 _test_img_width(line, img, wdth);
1260 _test_img_height(line, img, hght);
1261 return img;
1264 return NULL;
1267 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1268 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1270 LONG len = 0xdeadbeef;
1271 HRESULT hres;
1273 hres = IHTMLSelectElement_get_length(select, &len);
1274 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1275 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1278 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1279 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1281 LONG idx = 0xdeadbeef;
1282 HRESULT hres;
1284 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1285 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1286 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1289 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1290 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1292 HRESULT hres;
1294 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1295 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1296 _test_select_selidx(line, select, index);
1299 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1300 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1302 BSTR val;
1303 HRESULT hres;
1305 hres = IHTMLSelectElement_get_value(select, &val);
1306 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1307 if(exval)
1308 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1309 else
1310 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1313 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1314 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1316 BSTR bstr;
1317 HRESULT hres;
1319 bstr = a2bstr(val);
1320 hres = IHTMLSelectElement_put_value(select, bstr);
1321 SysFreeString(bstr);
1322 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1325 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1326 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1328 BSTR type;
1329 HRESULT hres;
1331 hres = IHTMLSelectElement_get_type(select, &type);
1332 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1333 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1336 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1337 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1339 BSTR text;
1340 HRESULT hres;
1342 hres = IHTMLTxtRange_get_text(range, &text);
1343 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1345 if(extext) {
1346 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1347 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1348 }else {
1349 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1352 SysFreeString(text);
1356 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1357 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1359 HRESULT hres;
1361 hres = IHTMLTxtRange_collapse(range, b);
1362 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1363 _test_range_text(line, range, NULL);
1366 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1367 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1368 VARIANT_BOOL exb, const char *extext)
1370 VARIANT_BOOL b = 0xe0e0;
1371 HRESULT hres;
1373 hres = IHTMLTxtRange_expand(range, unit, &b);
1374 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1375 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1376 _test_range_text(line, range, extext);
1379 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1380 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1382 LONG c = 0xdeadbeef;
1383 HRESULT hres;
1385 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1386 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1387 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1388 _test_range_text(line, range, NULL);
1391 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1392 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1393 LPWSTR unit, LONG cnt, LONG excnt)
1395 LONG c = 0xdeadbeef;
1396 HRESULT hres;
1398 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1399 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1400 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1403 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1404 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1406 LONG c = 0xdeadbeef;
1407 HRESULT hres;
1409 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1410 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1411 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1414 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1415 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1417 HRESULT hres;
1418 BSTR bstr = a2bstr(text);
1420 hres = IHTMLTxtRange_put_text(range, bstr);
1421 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1422 SysFreeString(bstr);
1423 _test_range_text(line, range, NULL);
1426 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1427 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1429 VARIANT_BOOL b;
1430 HRESULT hres;
1432 b = 0xe0e0;
1433 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1434 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1435 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1438 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1439 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1441 VARIANT_BOOL b;
1442 HRESULT hres;
1444 b = 0xe0e0;
1445 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1446 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1447 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1449 b = 0xe0e0;
1450 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1451 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1452 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1454 if(exb) {
1455 test_range_inrange(range1, range2, VARIANT_TRUE);
1456 test_range_inrange(range2, range1, VARIANT_TRUE);
1460 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1461 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1463 IHTMLElement *elem;
1464 HRESULT hres;
1466 hres = IHTMLTxtRange_parentElement(range, &elem);
1467 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1469 _test_elem_type(line, (IUnknown*)elem, type);
1471 IHTMLElement_Release(elem);
1474 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1475 static void _test_elem_collection(unsigned line, IUnknown *unk,
1476 const elem_type_t *elem_types, LONG exlen)
1478 IHTMLElementCollection *col;
1479 LONG len;
1480 DWORD i;
1481 VARIANT name, index;
1482 IDispatch *disp, *disp2;
1483 HRESULT hres;
1485 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1486 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1488 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1490 hres = IHTMLElementCollection_get_length(col, &len);
1491 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1492 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1494 if(len > exlen)
1495 len = exlen;
1497 V_VT(&index) = VT_EMPTY;
1499 for(i=0; i<len; i++) {
1500 V_VT(&name) = VT_I4;
1501 V_I4(&name) = i;
1502 disp = (void*)0xdeadbeef;
1503 hres = IHTMLElementCollection_item(col, name, index, &disp);
1504 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1505 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1506 if(FAILED(hres) || !disp)
1507 continue;
1509 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1511 if(!i) {
1512 V_VT(&name) = VT_UINT;
1513 V_I4(&name) = 0;
1514 disp2 = (void*)0xdeadbeef;
1515 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1516 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1517 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1518 if(disp2)
1519 IDispatch_Release(disp2);
1522 IDispatch_Release(disp);
1525 V_VT(&name) = VT_I4;
1526 V_I4(&name) = len;
1527 disp = (void*)0xdeadbeef;
1528 hres = IHTMLElementCollection_item(col, name, index, &disp);
1529 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1530 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1532 V_VT(&name) = VT_I4;
1533 V_I4(&name) = -1;
1534 disp = (void*)0xdeadbeef;
1535 hres = IHTMLElementCollection_item(col, name, index, &disp);
1536 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1537 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1539 IHTMLElementCollection_Release(col);
1542 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1543 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1545 IHTMLElement *elem = _get_elem_iface(line, unk);
1546 IDispatch *disp;
1547 HRESULT hres;
1549 hres = IHTMLElement_get_all(elem, &disp);
1550 IHTMLElement_Release(elem);
1551 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1553 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1554 IDispatch_Release(disp);
1557 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1558 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1560 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1561 IHTMLElementCollection *col = NULL;
1562 elem_type_t *types = NULL;
1563 BSTR tmp;
1564 int i;
1565 HRESULT hres;
1567 tmp = a2bstr(elem_type_infos[type].tag);
1568 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1569 SysFreeString(tmp);
1570 IHTMLElement2_Release(elem);
1571 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1572 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1574 if(exlen) {
1575 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1576 for(i=0; i<exlen; i++)
1577 types[i] = type;
1580 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1582 HeapFree(GetProcessHeap(), 0, types);
1585 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1586 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1588 BSTR text = NULL;
1589 HRESULT hres;
1591 hres = IHTMLElement_get_innerText(elem, &text);
1592 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1593 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1594 wine_dbgstr_w(text), extext);
1595 SysFreeString(text);
1598 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1599 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1601 IHTMLDOMChildrenCollection *col;
1602 BSTR str;
1603 HRESULT hres;
1605 str = a2bstr(text);
1606 hres = IHTMLElement_put_innerText(elem, str);
1607 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1608 SysFreeString(str);
1610 _test_elem_innertext(line, elem, text);
1613 col = _get_child_nodes(line, (IUnknown*)elem);
1614 ok(col != NULL, "col == NULL\n");
1615 if(col) {
1616 LONG length = 0, type;
1617 IHTMLDOMNode *node;
1619 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1620 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1621 ok(length == 1, "length = %d\n", length);
1623 node = _get_child_item(line, col, 0);
1624 ok(node != NULL, "node == NULL\n");
1625 if(node) {
1626 type = _get_node_type(line, (IUnknown*)node);
1627 ok(type == 3, "type=%d\n", type);
1628 IHTMLDOMNode_Release(node);
1631 IHTMLDOMChildrenCollection_Release(col);
1636 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1637 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1639 IHTMLElement *elem = _get_elem_iface(line, unk);
1640 BSTR html;
1641 HRESULT hres;
1643 hres = IHTMLElement_get_innerHTML(elem, &html);
1644 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1645 if(inner_html)
1646 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1647 else
1648 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1650 IHTMLElement_Release(elem);
1651 SysFreeString(html);
1654 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1655 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1657 IHTMLElement *elem = _get_elem_iface(line, unk);
1658 BSTR html;
1659 HRESULT hres;
1661 html = a2bstr(inner_html);
1662 hres = IHTMLElement_put_innerHTML(elem, html);
1663 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1665 IHTMLElement_Release(elem);
1666 SysFreeString(html);
1669 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1670 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1672 IHTMLElement *elem = _get_elem_iface(line, unk);
1673 BSTR html;
1674 HRESULT hres;
1676 html = a2bstr(outer_html);
1677 hres = IHTMLElement_put_outerHTML(elem, html);
1678 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1680 IHTMLElement_Release(elem);
1681 SysFreeString(html);
1684 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1685 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1687 IHTMLElement *elem = _get_elem_iface(line, unk);
1688 BSTR html;
1689 HRESULT hres;
1691 hres = IHTMLElement_get_outerHTML(elem, &html);
1692 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1693 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1695 IHTMLElement_Release(elem);
1696 SysFreeString(html);
1699 #define get_first_child(n) _get_first_child(__LINE__,n)
1700 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1702 IHTMLDOMNode *node = _get_node_iface(line, unk);
1703 IHTMLDOMNode *child = NULL;
1704 HRESULT hres;
1706 hres = IHTMLDOMNode_get_firstChild(node, &child);
1707 IHTMLDOMNode_Release(node);
1708 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1710 return child;
1713 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1714 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1716 IHTMLDOMNode *node = _get_node_iface(line, unk);
1717 VARIANT_BOOL b = 0xdead;
1718 HRESULT hres;
1720 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1721 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1722 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1724 IHTMLDOMNode_Release(node);
1727 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1728 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1730 IHTMLDOMNode *node = _get_node_iface(line, unk);
1731 IHTMLDOMNode *parent;
1732 HRESULT hres;
1734 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1735 IHTMLDOMNode_Release(node);
1736 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1738 return parent;
1741 #define node_get_next(u) _node_get_next(__LINE__,u)
1742 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1744 IHTMLDOMNode *node = _get_node_iface(line, unk);
1745 IHTMLDOMNode *next;
1746 HRESULT hres;
1748 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1749 IHTMLDOMNode_Release(node);
1750 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1752 return next;
1755 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1756 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1758 IHTMLElement *elem = _get_elem_iface(line, unk);
1759 IHTMLElement *parent;
1760 HRESULT hres;
1762 hres = IHTMLElement_get_parentElement(elem, &parent);
1763 IHTMLElement_Release(elem);
1764 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1766 return parent;
1769 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1770 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1772 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1773 VARIANT_BOOL disabled = 100;
1774 HRESULT hres;
1776 if (!elem3) return;
1777 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1778 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1779 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1780 IHTMLElement3_Release(elem3);
1783 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1784 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1786 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1787 HRESULT hres;
1789 if (!elem3) return;
1790 hres = IHTMLElement3_put_disabled(elem3, b);
1791 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1793 IHTMLElement3_Release(elem3);
1794 _test_elem3_get_disabled(line, unk, b);
1797 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1798 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1800 VARIANT_BOOL disabled = 100;
1801 HRESULT hres;
1803 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1804 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1805 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1807 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1810 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1811 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1813 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
1814 LONG length;
1815 HRESULT hres;
1817 hres = IHTMLDOMTextNode_get_length(text, &length);
1818 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1819 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
1820 IHTMLDOMTextNode_Release(text);
1823 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1824 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1826 HRESULT hres;
1828 hres = IHTMLSelectElement_put_disabled(select, b);
1829 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1831 _test_select_get_disabled(line, select, b);
1834 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1835 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1837 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1838 IHTMLTextContainer *txtcont;
1839 LONG l = -1, l2 = -1;
1840 HRESULT hres;
1842 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1843 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1844 IHTMLElement2_Release(elem);
1846 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1847 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1849 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1850 IHTMLTextContainer_Release(txtcont);
1851 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1852 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1854 return l;
1857 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1858 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1860 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1861 IHTMLTextContainer *txtcont;
1862 LONG l = -1, l2 = -1;
1863 HRESULT hres;
1865 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1866 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1867 IHTMLElement2_Release(elem);
1869 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1870 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1872 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1873 IHTMLTextContainer_Release(txtcont);
1874 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1875 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1877 return l;
1880 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1881 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1883 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1884 IHTMLTextContainer *txtcont;
1885 LONG l = -1, l2 = -1;
1886 HRESULT hres;
1888 hres = IHTMLElement2_get_scrollTop(elem, &l);
1889 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1890 IHTMLElement2_Release(elem);
1892 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1893 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1895 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1896 IHTMLTextContainer_Release(txtcont);
1897 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1898 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1900 return l;
1903 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1904 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1906 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1907 IHTMLTextContainer *txtcont;
1908 LONG l = -1, l2 = -1;
1909 HRESULT hres;
1911 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1912 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1914 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1915 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1916 IHTMLElement2_Release(elem);
1918 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1919 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1921 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1922 IHTMLTextContainer_Release(txtcont);
1923 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1924 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1927 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1928 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1930 IHTMLImgElement *img = _get_img_iface(line, unk);
1931 BSTR src;
1932 HRESULT hres;
1934 hres = IHTMLImgElement_get_src(img, &src);
1935 IHTMLImgElement_Release(img);
1936 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1937 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1938 SysFreeString(src);
1941 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1942 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1944 IHTMLImgElement *img = _get_img_iface(line, unk);
1945 BSTR tmp;
1946 HRESULT hres;
1948 tmp = a2bstr(src);
1949 hres = IHTMLImgElement_put_src(img, tmp);
1950 IHTMLImgElement_Release(img);
1951 SysFreeString(tmp);
1952 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1954 _test_img_src(line, unk, src);
1957 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1958 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1960 IHTMLImgElement *img = _get_img_iface(line, unk);
1961 BSTR alt;
1962 HRESULT hres;
1964 hres = IHTMLImgElement_get_alt(img, &alt);
1965 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1966 if(exalt)
1967 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1968 else
1969 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1970 SysFreeString(alt);
1973 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1974 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1976 IHTMLImgElement *img = _get_img_iface(line, unk);
1977 BSTR tmp;
1978 HRESULT hres;
1980 tmp = a2bstr(alt);
1981 hres = IHTMLImgElement_put_alt(img, tmp);
1982 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1983 SysFreeString(tmp);
1985 _test_img_alt(line, unk, alt);
1988 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
1989 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
1991 IHTMLImgElement *img = _get_img_iface(line, unk);
1992 BSTR sName;
1993 HRESULT hres;
1995 hres = IHTMLImgElement_get_name(img, &sName);
1996 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
1997 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
1998 SysFreeString(sName);
2002 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2003 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2005 VARIANT_BOOL disabled = 100;
2006 HRESULT hres;
2008 hres = IHTMLInputElement_get_disabled(input, &disabled);
2009 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2010 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2012 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2015 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2016 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2018 HRESULT hres;
2020 hres = IHTMLInputElement_put_disabled(input, b);
2021 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2023 _test_input_get_disabled(line, input, b);
2026 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2027 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2029 VARIANT_BOOL checked = 100;
2030 HRESULT hres;
2032 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2033 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2034 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2037 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2038 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2040 HRESULT hres;
2042 hres = IHTMLInputElement_put_defaultChecked(input, b);
2043 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2045 _test_input_get_defaultchecked(line, input, b);
2048 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2049 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2051 VARIANT_BOOL checked = 100;
2052 HRESULT hres;
2054 hres = IHTMLInputElement_get_checked(input, &checked);
2055 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2056 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2059 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2060 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2062 HRESULT hres;
2064 hres = IHTMLInputElement_put_checked(input, b);
2065 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2067 _test_input_get_checked(line, input, b);
2070 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2071 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2073 IHTMLInputElement *input;
2074 BSTR bstr;
2075 HRESULT hres;
2077 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2078 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2079 if(FAILED(hres))
2080 return;
2082 hres = IHTMLInputElement_get_value(input, &bstr);
2083 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2084 if(exval)
2085 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2086 else
2087 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2088 SysFreeString(bstr);
2089 IHTMLInputElement_Release(input);
2092 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2093 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2095 IHTMLInputElement *input;
2096 BSTR bstr;
2097 HRESULT hres;
2099 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2100 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2101 if(FAILED(hres))
2102 return;
2104 bstr = a2bstr(val);
2105 hres = IHTMLInputElement_get_value(input, &bstr);
2106 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2107 SysFreeString(bstr);
2108 IHTMLInputElement_Release(input);
2111 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2112 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2114 BSTR src;
2115 HRESULT hres;
2117 hres = IHTMLInputElement_get_src(input, &src);
2118 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2119 if(exsrc)
2120 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2121 else
2122 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2123 SysFreeString(src);
2126 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2127 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2129 BSTR tmp;
2130 HRESULT hres;
2132 tmp = a2bstr(src);
2133 hres = IHTMLInputElement_put_src(input, tmp);
2134 SysFreeString(tmp);
2135 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2137 _test_input_src(line, input, src);
2140 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2141 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2143 IHTMLElement *elem = _get_elem_iface(line, unk);
2144 BSTR class = (void*)0xdeadbeef;
2145 HRESULT hres;
2147 hres = IHTMLElement_get_className(elem, &class);
2148 IHTMLElement_Release(elem);
2149 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2150 if(exclass)
2151 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2152 else
2153 ok_(__FILE__,line) (!class, "class != NULL\n");
2154 SysFreeString(class);
2157 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2158 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2160 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2161 short index = -3;
2162 HRESULT hres;
2164 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2165 IHTMLElement2_Release(elem2);
2166 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2167 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2170 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2171 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2173 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2174 HRESULT hres;
2176 hres = IHTMLElement2_put_tabIndex(elem2, index);
2177 IHTMLElement2_Release(elem2);
2178 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2180 _test_elem_tabindex(line, unk, index);
2183 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2184 static void _test_elem_filters(unsigned line, IUnknown *unk)
2186 IHTMLElement *elem = _get_elem_iface(line, unk);
2187 HRESULT hres;
2188 IHTMLFiltersCollection *filters;
2190 hres = IHTMLElement_get_filters(elem, &filters);
2191 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2192 "get_filters failed: %08x\n", hres);
2193 if(hres == S_OK)
2195 LONG len;
2196 IDispatchEx *dispex;
2198 hres = IHTMLFiltersCollection_get_length(filters, &len);
2199 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2200 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2202 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2203 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2204 "Could not get IDispatchEx interface: %08x\n", hres);
2205 if(SUCCEEDED(hres)) {
2206 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2207 IDispatchEx_Release(dispex);
2210 IHTMLFiltersCollection_Release(filters);
2213 IHTMLElement_Release(elem);
2216 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2217 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2219 IHTMLElement *elem = _get_elem_iface(line, unk);
2220 BSTR tmp;
2221 HRESULT hres;
2223 tmp = class ? a2bstr(class) : NULL;
2224 hres = IHTMLElement_put_className(elem, tmp);
2225 IHTMLElement_Release(elem);
2226 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2227 SysFreeString(tmp);
2229 _test_elem_class(line, unk, class);
2232 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2233 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2235 IHTMLElement *elem = _get_elem_iface(line, unk);
2236 BSTR id = (void*)0xdeadbeef;
2237 HRESULT hres;
2239 hres = IHTMLElement_get_id(elem, &id);
2240 IHTMLElement_Release(elem);
2241 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2243 if(exid)
2244 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2245 else
2246 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2248 SysFreeString(id);
2251 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2252 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2254 IHTMLElement *elem = _get_elem_iface(line, unk);
2255 BSTR tmp = a2bstr(new_id);
2256 HRESULT hres;
2258 hres = IHTMLElement_put_id(elem, tmp);
2259 IHTMLElement_Release(elem);
2260 SysFreeString(tmp);
2261 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2263 _test_elem_id(line, unk, new_id);
2266 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2267 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2269 IHTMLElement *elem = _get_elem_iface(line, unk);
2270 BSTR title;
2271 HRESULT hres;
2273 hres = IHTMLElement_get_title(elem, &title);
2274 IHTMLElement_Release(elem);
2275 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2276 if(extitle)
2277 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2278 else
2279 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2281 SysFreeString(title);
2284 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2285 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2287 IHTMLElement *elem = _get_elem_iface(line, unk);
2288 BSTR tmp;
2289 HRESULT hres;
2291 tmp = a2bstr(title);
2292 hres = IHTMLElement_put_title(elem, tmp);
2293 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2295 IHTMLElement_Release(elem);
2296 SysFreeString(tmp);
2299 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2300 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2302 IHTMLDOMNode *node = _get_node_iface(line, unk);
2303 VARIANT var;
2304 HRESULT hres;
2306 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2307 IHTMLDOMNode_Release(node);
2308 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2310 if(exval) {
2311 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2312 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2313 }else {
2314 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2317 VariantClear(&var);
2320 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2321 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2323 IHTMLDOMNode *node = _get_node_iface(line, unk);
2324 VARIANT var;
2325 HRESULT hres;
2327 V_VT(&var) = VT_BSTR;
2328 V_BSTR(&var) = a2bstr(val);
2330 hres = IHTMLDOMNode_put_nodeValue(node, var);
2331 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2332 IHTMLDOMNode_Release(node);
2333 VariantClear(&var);
2336 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2337 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2339 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2340 LONG l;
2341 HRESULT hres;
2343 hres = IHTMLElement2_get_clientWidth(elem, &l);
2344 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2345 hres = IHTMLElement2_get_clientHeight(elem, &l);
2346 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2348 IHTMLElement2_Release(elem);
2351 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2352 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2354 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2355 LONG l;
2356 HRESULT hres;
2358 hres = IHTMLElement2_get_clientLeft(elem, &l);
2359 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2360 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2362 hres = IHTMLElement2_get_clientTop(elem, &l);
2363 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2364 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2366 IHTMLElement2_Release(elem);
2369 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2370 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2372 IHTMLElement *elem = _get_elem_iface(line, unk);
2373 IHTMLDocument2 *doc;
2374 IDispatch *disp;
2375 HRESULT hres;
2377 disp = NULL;
2378 hres = IHTMLElement_get_document(elem, &disp);
2379 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2380 ok(disp != NULL, "disp == NULL\n");
2382 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2383 IDispatch_Release(disp);
2384 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2386 return doc;
2389 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2390 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2392 IHTMLDocument2 *doc;
2393 HRESULT hres;
2395 doc = NULL;
2396 hres = IHTMLWindow2_get_document(window, &doc);
2397 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2398 ok(doc != NULL, "disp == NULL\n");
2400 return doc;
2403 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2404 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2406 IHTMLElement *elem = NULL;
2407 BSTR tmp;
2408 HRESULT hres;
2410 tmp = a2bstr(tag);
2411 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2412 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2413 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2415 return elem;
2418 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2419 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2421 IHTMLDocument3 *doc3;
2422 IHTMLDOMNode *node = NULL;
2423 BSTR tmp;
2424 HRESULT hres;
2426 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2427 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2429 tmp = a2bstr(text);
2430 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2431 IHTMLDocument3_Release(doc3);
2432 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2433 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2435 return node;
2438 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2439 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2441 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2442 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2443 IHTMLDOMNode *new_child = NULL;
2444 HRESULT hres;
2446 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2447 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2448 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2449 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2451 IHTMLDOMNode_Release(node);
2452 IHTMLDOMNode_Release(child);
2454 return new_child;
2457 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2458 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2460 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2461 IHTMLDOMNode *new_child = NULL;
2462 HRESULT hres;
2464 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2465 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2466 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2467 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2469 IHTMLDOMNode_Release(node);
2471 return new_child;
2474 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2475 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2477 IHTMLDOMNode *node = _get_node_iface(line, unk);
2478 IHTMLDOMNode *new_node = NULL;
2479 HRESULT hres;
2481 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2482 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2483 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2484 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2486 IHTMLDOMNode_Release(node);
2487 IHTMLDOMNode_Release(new_node);
2490 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2491 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2493 BSTR title = NULL;
2494 HRESULT hres;
2496 hres = IHTMLDocument2_get_title(doc, &title);
2497 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2498 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2499 SysFreeString(title);
2502 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2503 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2505 BSTR tmp;
2506 HRESULT hres;
2508 tmp = a2bstr(title);
2509 hres = IHTMLDocument2_put_title(doc, tmp);
2510 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2511 SysFreeString(tmp);
2514 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2515 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2517 HRESULT hres;
2518 DISPID dispid;
2520 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2521 LOCALE_USER_DEFAULT, &dispid);
2522 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2523 if(hres == S_OK)
2525 DISPPARAMS params = {NULL,NULL,0,0};
2526 DISPID dispidNamed = DISPID_PROPERTYPUT;
2527 VARIANT ret;
2528 VARIANT vDefault;
2529 VARIANTARG arg;
2531 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2532 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2533 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2535 params.cArgs = 1;
2536 params.cNamedArgs = 1;
2537 params.rgdispidNamedArgs = &dispidNamed;
2538 V_VT(&arg) = VT_BSTR;
2539 V_BSTR(&arg) = a2bstr("none");
2540 params.rgvarg = &arg;
2541 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2542 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2543 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2544 VariantClear(&arg);
2546 V_VT(&arg) = VT_BSTR;
2547 V_BSTR(&arg) = a2bstr("dotted");
2548 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2549 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2550 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2551 VariantClear(&arg);
2553 V_VT(&arg) = VT_BSTR;
2554 V_BSTR(&arg) = a2bstr("dashed");
2555 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2556 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2557 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2558 VariantClear(&arg);
2560 V_VT(&arg) = VT_BSTR;
2561 V_BSTR(&arg) = a2bstr("solid");
2562 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2563 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2564 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2565 VariantClear(&arg);
2567 V_VT(&arg) = VT_BSTR;
2568 V_BSTR(&arg) = a2bstr("double");
2569 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2570 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2571 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2572 VariantClear(&arg);
2574 V_VT(&arg) = VT_BSTR;
2575 V_BSTR(&arg) = a2bstr("groove");
2576 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2577 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2578 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2579 VariantClear(&arg);
2581 V_VT(&arg) = VT_BSTR;
2582 V_BSTR(&arg) = a2bstr("ridge");
2583 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2584 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2585 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2586 VariantClear(&arg);
2588 V_VT(&arg) = VT_BSTR;
2589 V_BSTR(&arg) = a2bstr("inset");
2590 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2591 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2592 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2593 VariantClear(&arg);
2595 V_VT(&arg) = VT_BSTR;
2596 V_BSTR(&arg) = a2bstr("outset");
2597 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2598 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2599 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2600 VariantClear(&arg);
2602 V_VT(&arg) = VT_BSTR;
2603 V_BSTR(&arg) = a2bstr("invalid");
2604 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2605 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2606 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2607 VariantClear(&arg);
2609 params.rgvarg = &vDefault;
2610 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2611 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2612 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2616 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2617 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2619 BSTR text = (void*)0xdeadbeef;
2620 HRESULT hres;
2622 hres = IHTMLStyle_get_cssText(style, &text);
2623 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2624 if(extext)
2625 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2626 else
2627 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2629 SysFreeString(text);
2632 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2633 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2635 BSTR tmp;
2636 HRESULT hres;
2638 tmp = a2bstr(text);
2639 hres = IHTMLStyle_put_cssText(style, tmp);
2640 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2641 SysFreeString(tmp);
2644 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2645 const elem_type_t *elem_types, LONG len)
2647 IDispatch *disp;
2648 VARIANT name, index;
2649 DWORD i;
2650 HRESULT hres;
2652 V_VT(&index) = VT_EMPTY;
2653 V_VT(&name) = VT_BSTR;
2654 V_BSTR(&name) = a2bstr(n);
2656 hres = IHTMLElementCollection_item(col, name, index, &disp);
2657 ok(hres == S_OK, "item failed: %08x\n", hres);
2659 test_elem_collection((IUnknown*)disp, elem_types, len);
2660 IDispatch_Release(disp);
2661 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2662 if(hres != S_OK)
2663 goto cleanup;
2665 V_VT(&index) = VT_I4;
2667 for(i=0; i<len; i++) {
2668 V_I4(&index) = i;
2669 disp = (void*)0xdeadbeef;
2670 hres = IHTMLElementCollection_item(col, name, index, &disp);
2671 ok(hres == S_OK, "item failed: %08x\n", hres);
2672 ok(disp != NULL, "disp == NULL\n");
2673 if(FAILED(hres) || !disp)
2674 continue;
2676 test_elem_type((IUnknown*)disp, elem_types[i]);
2678 IDispatch_Release(disp);
2681 V_I4(&index) = len;
2682 disp = (void*)0xdeadbeef;
2683 hres = IHTMLElementCollection_item(col, name, index, &disp);
2684 ok(hres == S_OK, "item failed: %08x\n", hres);
2685 ok(disp == NULL, "disp != NULL\n");
2687 V_I4(&index) = -1;
2688 disp = (void*)0xdeadbeef;
2689 hres = IHTMLElementCollection_item(col, name, index, &disp);
2690 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2691 ok(disp == NULL, "disp != NULL\n");
2693 cleanup:
2694 SysFreeString(V_BSTR(&name));
2697 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2699 IHTMLElementCollection *col;
2700 IHTMLElement *elem;
2701 IDispatch *disp = (void*)0xdeadbeef;
2702 VARIANT name, index;
2703 HRESULT hres;
2705 hres = IHTMLDocument2_get_all(doc, &col);
2706 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2707 ok(col != NULL, "col == NULL\n");
2708 if(FAILED(hres) || !col)
2709 return NULL;
2711 V_VT(&index) = VT_EMPTY;
2712 V_VT(&name) = VT_BSTR;
2713 V_BSTR(&name) = a2bstr(id);
2715 hres = IHTMLElementCollection_item(col, name, index, &disp);
2716 IHTMLElementCollection_Release(col);
2717 SysFreeString(V_BSTR(&name));
2718 ok(hres == S_OK, "item failed: %08x\n", hres);
2719 if(!expect_success) {
2720 ok(disp == NULL, "disp != NULL\n");
2721 return NULL;
2724 ok(disp != NULL, "disp == NULL\n");
2725 if(!disp)
2726 return NULL;
2728 elem = get_elem_iface((IUnknown*)disp);
2729 IDispatch_Release(disp);
2731 return elem;
2734 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2736 IHTMLDocument3 *doc3;
2737 IHTMLElement *elem;
2738 BSTR tmp;
2739 HRESULT hres;
2741 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2742 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2744 tmp = a2bstr(id);
2745 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2746 SysFreeString(tmp);
2747 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2749 IHTMLDocument3_Release(doc3);
2751 return elem;
2754 static void test_select_elem(IHTMLSelectElement *select)
2756 test_select_type(select, "select-one");
2757 test_select_length(select, 2);
2758 test_select_selidx(select, 0);
2759 test_select_put_selidx(select, 1);
2761 test_select_set_value(select, "val1");
2762 test_select_value(select, "val1");
2764 test_select_get_disabled(select, VARIANT_FALSE);
2765 test_select_set_disabled(select, VARIANT_TRUE);
2766 test_select_set_disabled(select, VARIANT_FALSE);
2769 static void test_create_option_elem(IHTMLDocument2 *doc)
2771 IHTMLOptionElement *option;
2773 option = create_option_elem(doc, "test text", "test value");
2775 test_option_put_text(option, "new text");
2776 test_option_put_value(option, "new value");
2778 IHTMLOptionElement_Release(option);
2781 static void test_create_img_elem(IHTMLDocument2 *doc)
2783 IHTMLImgElement *img;
2785 img = create_img_elem(doc, 10, 15);
2787 if(img){
2788 test_img_put_width(img, 5);
2789 test_img_put_height(img, 20);
2791 IHTMLImgElement_Release(img);
2792 img = NULL;
2795 img = create_img_elem(doc, -1, -1);
2797 if(img){
2798 test_img_put_width(img, 5);
2799 test_img_put_height(img, 20);
2801 IHTMLImgElement_Release(img);
2805 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2807 IHTMLBodyElement *body;
2808 IHTMLTxtRange *range;
2809 IHTMLElement *elem;
2810 HRESULT hres;
2812 hres = IHTMLDocument2_get_body(doc, &elem);
2813 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2815 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2816 IHTMLElement_Release(elem);
2818 hres = IHTMLBodyElement_createTextRange(body, &range);
2819 IHTMLBodyElement_Release(body);
2820 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2822 return range;
2825 static void test_txtrange(IHTMLDocument2 *doc)
2827 IHTMLTxtRange *body_range, *range, *range2;
2828 IHTMLSelectionObject *selection;
2829 IDispatch *disp_range;
2830 HRESULT hres;
2832 body_range = test_create_body_range(doc);
2834 test_range_text(body_range, "test abc 123\r\nit's text");
2836 hres = IHTMLTxtRange_duplicate(body_range, &range);
2837 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2839 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2840 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2841 test_range_isequal(range, range2, VARIANT_TRUE);
2843 test_range_text(range, "test abc 123\r\nit's text");
2844 test_range_text(body_range, "test abc 123\r\nit's text");
2846 test_range_collapse(range, TRUE);
2847 test_range_isequal(range, range2, VARIANT_FALSE);
2848 test_range_inrange(range, range2, VARIANT_FALSE);
2849 test_range_inrange(range2, range, VARIANT_TRUE);
2850 IHTMLTxtRange_Release(range2);
2852 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2853 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2854 test_range_move(range, characterW, 2, 2);
2855 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2857 test_range_collapse(range, FALSE);
2858 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2860 test_range_collapse(range, FALSE);
2861 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2862 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2863 test_range_move(range, characterW, 2, 2);
2864 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2865 test_range_moveend(range, characterW, -5, -5);
2866 test_range_text(range, NULL);
2867 test_range_moveend(range, characterW, 3, 3);
2868 test_range_text(range, "c 1");
2869 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2870 test_range_collapse(range, TRUE);
2871 test_range_move(range, characterW, 4, 4);
2872 test_range_moveend(range, characterW, 1, 1);
2873 test_range_text(range, " ");
2874 test_range_move(range, wordW, 1, 1);
2875 test_range_moveend(range, characterW, 2, 2);
2876 test_range_text(range, "ab");
2878 IHTMLTxtRange_Release(range);
2880 hres = IHTMLTxtRange_duplicate(body_range, &range);
2881 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2883 test_range_text(range, "test abc 123\r\nit's text");
2884 test_range_move(range, characterW, 3, 3);
2885 test_range_moveend(range, characterW, 1, 1);
2886 test_range_text(range, "t");
2887 test_range_moveend(range, characterW, 3, 3);
2888 test_range_text(range, "t ab");
2889 test_range_moveend(range, characterW, -2, -2);
2890 test_range_text(range, "t ");
2891 test_range_move(range, characterW, 6, 6);
2892 test_range_moveend(range, characterW, 3, 3);
2893 test_range_text(range, "123");
2894 test_range_moveend(range, characterW, 2, 2);
2895 test_range_text(range, "123\r\ni");
2897 IHTMLTxtRange_Release(range);
2899 hres = IHTMLTxtRange_duplicate(body_range, &range);
2900 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2902 test_range_move(range, wordW, 1, 1);
2903 test_range_moveend(range, characterW, 2, 2);
2904 test_range_text(range, "ab");
2906 test_range_move(range, characterW, -2, -2);
2907 test_range_moveend(range, characterW, 2, 2);
2908 test_range_text(range, "t ");
2910 test_range_move(range, wordW, 3, 3);
2911 test_range_move(range, wordW, -2, -2);
2912 test_range_moveend(range, characterW, 2, 2);
2913 test_range_text(range, "ab");
2915 test_range_move(range, characterW, -6, -5);
2916 test_range_moveend(range, characterW, -1, 0);
2917 test_range_moveend(range, characterW, -6, 0);
2918 test_range_move(range, characterW, 2, 2);
2919 test_range_moveend(range, characterW, 2, 2);
2920 test_range_text(range, "st");
2921 test_range_moveend(range, characterW, -6, -4);
2922 test_range_moveend(range, characterW, 2, 2);
2924 IHTMLTxtRange_Release(range);
2926 hres = IHTMLTxtRange_duplicate(body_range, &range);
2927 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2929 test_range_move(range, wordW, 2, 2);
2930 test_range_moveend(range, characterW, 2, 2);
2931 test_range_text(range, "12");
2933 test_range_move(range, characterW, 15, 14);
2934 test_range_move(range, characterW, -2, -2);
2935 test_range_moveend(range, characterW, 3, 2);
2936 test_range_text(range, "t");
2937 test_range_moveend(range, characterW, -1, -1);
2938 test_range_text(range, "t");
2939 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2940 test_range_move(range, characterW, -2, -2);
2941 test_range_moveend(range, characterW, 2, 2);
2942 test_range_text(range, "s ");
2943 test_range_move(range, characterW, 100, 7);
2944 test_range_move(range, wordW, 1, 0);
2945 test_range_move(range, characterW, -2, -2);
2946 test_range_moveend(range, characterW, 3, 2);
2947 test_range_text(range, "t");
2949 IHTMLTxtRange_Release(range);
2951 hres = IHTMLTxtRange_duplicate(body_range, &range);
2952 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2954 test_range_collapse(range, TRUE);
2955 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2956 test_range_put_text(range, "word");
2957 test_range_text(body_range, "wordabc 123\r\nit's text");
2958 test_range_text(range, NULL);
2959 test_range_moveend(range, characterW, 3, 3);
2960 test_range_text(range, "abc");
2961 test_range_movestart(range, characterW, -2, -2);
2962 test_range_text(range, "rdabc");
2963 test_range_movestart(range, characterW, 3, 3);
2964 test_range_text(range, "bc");
2965 test_range_movestart(range, characterW, 4, 4);
2966 test_range_text(range, NULL);
2967 test_range_movestart(range, characterW, -3, -3);
2968 test_range_text(range, "c 1");
2969 test_range_movestart(range, characterW, -7, -6);
2970 test_range_text(range, "wordabc 1");
2971 test_range_movestart(range, characterW, 100, 22);
2972 test_range_text(range, NULL);
2974 IHTMLTxtRange_Release(range);
2975 IHTMLTxtRange_Release(body_range);
2977 hres = IHTMLDocument2_get_selection(doc, &selection);
2978 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2980 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2981 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2982 IHTMLSelectionObject_Release(selection);
2984 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2985 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2986 IDispatch_Release(disp_range);
2988 test_range_text(range, NULL);
2989 test_range_moveend(range, characterW, 3, 3);
2990 test_range_text(range, "wor");
2991 test_range_parent(range, ET_BODY);
2992 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2993 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2994 test_range_move(range, characterW, 3, 3);
2995 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2996 test_range_moveend(range, characterW, -4, -4);
2997 test_range_put_text(range, "abc def ");
2998 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2999 test_range_move(range, wordW, 1, 1);
3000 test_range_movestart(range, characterW, -1, -1);
3001 test_range_text(range, " ");
3002 test_range_move(range, wordW, 1, 1);
3003 test_range_moveend(range, characterW, 3, 3);
3004 test_range_text(range, "def");
3005 test_range_put_text(range, "xyz");
3006 test_range_moveend(range, characterW, 1, 1);
3007 test_range_move(range, wordW, 1, 1);
3008 test_range_moveend(range, characterW, 2, 2);
3009 test_range_text(range, "ab");
3011 IHTMLTxtRange_Release(range);
3014 static void test_txtrange2(IHTMLDocument2 *doc)
3016 IHTMLTxtRange *range;
3018 range = test_create_body_range(doc);
3020 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3021 test_range_move(range, characterW, 5, 5);
3022 test_range_moveend(range, characterW, 1, 1);
3023 test_range_text(range, "2");
3024 test_range_move(range, characterW, -3, -3);
3025 test_range_moveend(range, characterW, 3, 3);
3026 test_range_text(range, "c\r\n\r\n1");
3027 test_range_collapse(range, VARIANT_FALSE);
3028 test_range_moveend(range, characterW, 4, 4);
3029 test_range_text(range, "23");
3030 test_range_moveend(range, characterW, 1, 1);
3031 test_range_text(range, "23\r\n\r\n\r\nd");
3032 test_range_moveend(range, characterW, -1, -1);
3033 test_range_text(range, "23");
3034 test_range_moveend(range, characterW, -1, -1);
3035 test_range_text(range, "23");
3036 test_range_moveend(range, characterW, -2, -2);
3037 test_range_text(range, "2");
3039 IHTMLTxtRange_Release(range);
3042 static void test_compatmode(IHTMLDocument2 *doc)
3044 IHTMLDocument5 *doc5;
3045 BSTR mode;
3046 HRESULT hres;
3048 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3049 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3050 if(FAILED(hres))
3051 return;
3053 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3054 IHTMLDocument5_Release(doc5);
3055 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3056 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3057 SysFreeString(mode);
3060 static void test_location(IHTMLDocument2 *doc)
3062 IHTMLLocation *location, *location2;
3063 IHTMLWindow2 *window;
3064 BSTR str;
3065 ULONG ref;
3066 HRESULT hres;
3068 hres = IHTMLDocument2_get_location(doc, &location);
3069 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3071 hres = IHTMLDocument2_get_location(doc, &location2);
3072 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3074 ok(location == location2, "location != location2\n");
3075 IHTMLLocation_Release(location2);
3077 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3078 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3080 hres = IHTMLWindow2_get_location(window, &location2);
3081 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3082 ok(location == location2, "location != location2\n");
3083 IHTMLLocation_Release(location2);
3085 test_ifaces((IUnknown*)location, location_iids);
3086 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3088 hres = IHTMLLocation_get_pathname(location, &str);
3089 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3090 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3092 hres = IHTMLLocation_get_href(location, NULL);
3093 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3095 hres = IHTMLLocation_get_href(location, &str);
3096 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3097 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3099 ref = IHTMLLocation_Release(location);
3100 ok(!ref, "location chould be destroyed here\n");
3103 static void test_navigator(IHTMLDocument2 *doc)
3105 IHTMLWindow2 *window;
3106 IOmNavigator *navigator, *navigator2;
3107 char buf[512];
3108 DWORD size;
3109 ULONG ref;
3110 BSTR bstr;
3111 HRESULT hres;
3113 static const WCHAR v40[] = {'4','.','0'};
3115 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3116 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3118 hres = IHTMLWindow2_get_navigator(window, &navigator);
3119 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3120 ok(navigator != NULL, "navigator == NULL\n");
3121 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3123 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3124 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3125 ok(navigator != navigator2, "navigator2 != navihgator\n");
3127 IHTMLWindow2_Release(window);
3128 IOmNavigator_Release(navigator2);
3130 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3131 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3132 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3133 SysFreeString(bstr);
3135 bstr = NULL;
3136 hres = IOmNavigator_get_appName(navigator, &bstr);
3137 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3138 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3139 SysFreeString(bstr);
3141 bstr = NULL;
3142 hres = IOmNavigator_get_platform(navigator, &bstr);
3143 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3144 #ifdef _WIN64
3145 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3146 #else
3147 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3148 #endif
3149 SysFreeString(bstr);
3151 bstr = NULL;
3152 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3153 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3154 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3155 SysFreeString(bstr);
3157 hres = IOmNavigator_toString(navigator, NULL);
3158 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3160 bstr = NULL;
3161 hres = IOmNavigator_toString(navigator, &bstr);
3162 ok(hres == S_OK, "toString failed: %08x\n", hres);
3163 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3164 SysFreeString(bstr);
3166 size = sizeof(buf);
3167 hres = ObtainUserAgentString(0, buf, &size);
3168 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3170 bstr = NULL;
3171 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3172 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3173 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3174 SysFreeString(bstr);
3176 if(!strncmp(buf, "Mozilla/", 8)) {
3177 bstr = NULL;
3178 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3179 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3180 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3181 SysFreeString(bstr);
3182 }else {
3183 skip("nonstandard user agent\n");
3186 ref = IOmNavigator_Release(navigator);
3187 ok(!ref, "navigator should be destroyed here\n");
3190 static void test_screen(IHTMLWindow2 *window)
3192 IHTMLScreen *screen, *screen2;
3193 IDispatchEx *dispex;
3194 LONG l, exl;
3195 HDC hdc;
3196 HRESULT hres;
3198 screen = NULL;
3199 hres = IHTMLWindow2_get_screen(window, &screen);
3200 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3201 ok(screen != NULL, "screen == NULL\n");
3203 screen2 = NULL;
3204 hres = IHTMLWindow2_get_screen(window, &screen2);
3205 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3206 ok(screen2 != NULL, "screen == NULL\n");
3207 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3208 IHTMLScreen_Release(screen2);
3210 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3211 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3212 if(SUCCEEDED(hres)) {
3213 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3214 IDispatchEx_Release(dispex);
3217 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3219 exl = GetDeviceCaps(hdc, HORZRES);
3220 l = 0xdeadbeef;
3221 hres = IHTMLScreen_get_width(screen, &l);
3222 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3223 ok(l == exl, "width = %d, expected %d\n", l, exl);
3225 exl = GetDeviceCaps(hdc, VERTRES);
3226 l = 0xdeadbeef;
3227 hres = IHTMLScreen_get_height(screen, &l);
3228 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3229 ok(l == exl, "height = %d, expected %d\n", l, exl);
3231 exl = GetDeviceCaps(hdc, BITSPIXEL);
3232 l = 0xdeadbeef;
3233 hres = IHTMLScreen_get_colorDepth(screen, &l);
3234 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3235 ok(l == exl, "height = %d, expected %d\n", l, exl);
3237 DeleteObject(hdc);
3239 IHTMLScreen_Release(screen);
3242 static void test_current_style(IHTMLCurrentStyle *current_style)
3244 BSTR str;
3245 HRESULT hres;
3246 VARIANT v;
3248 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3249 test_ifaces((IUnknown*)current_style, cstyle_iids);
3251 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3252 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3253 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3254 SysFreeString(str);
3256 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3257 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3258 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3259 SysFreeString(str);
3261 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3262 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3263 SysFreeString(str);
3265 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3266 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3267 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3268 SysFreeString(str);
3270 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3271 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3272 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3273 SysFreeString(str);
3275 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3276 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3277 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3278 SysFreeString(str);
3280 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3281 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3282 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3283 SysFreeString(str);
3285 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3286 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3287 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3288 SysFreeString(str);
3290 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3291 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3292 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3293 SysFreeString(str);
3295 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3296 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3297 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3298 SysFreeString(str);
3300 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3301 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3302 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3303 SysFreeString(str);
3305 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3306 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3307 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3308 SysFreeString(str);
3310 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3311 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3312 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3313 SysFreeString(str);
3315 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3316 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3317 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3318 SysFreeString(str);
3320 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3321 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3322 SysFreeString(str);
3324 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3325 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3326 SysFreeString(str);
3328 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3329 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3330 SysFreeString(str);
3332 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3333 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3334 SysFreeString(str);
3336 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3337 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3338 SysFreeString(str);
3340 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3341 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3342 SysFreeString(str);
3344 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3345 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3346 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3347 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3348 VariantClear(&v);
3350 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3351 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3352 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3353 VariantClear(&v);
3355 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3356 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3357 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3358 VariantClear(&v);
3360 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3361 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3362 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3363 VariantClear(&v);
3365 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3366 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3367 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3368 VariantClear(&v);
3370 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3371 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3372 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3373 VariantClear(&v);
3375 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3376 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3377 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3378 VariantClear(&v);
3380 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3381 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3382 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3383 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3384 VariantClear(&v);
3386 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3387 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3388 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3389 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3390 VariantClear(&v);
3392 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3393 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3394 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3395 VariantClear(&v);
3397 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3398 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3399 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3400 VariantClear(&v);
3402 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3403 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3404 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3405 VariantClear(&v);
3407 V_BSTR(&v) = NULL;
3408 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3409 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3410 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3411 VariantClear(&v);
3413 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3414 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3415 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3416 VariantClear(&v);
3418 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3419 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3420 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3421 VariantClear(&v);
3423 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3424 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3425 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3426 VariantClear(&v);
3428 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3429 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3430 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3431 VariantClear(&v);
3433 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3434 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3435 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3436 VariantClear(&v);
3438 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3439 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3440 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3441 VariantClear(&v);
3443 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3444 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3445 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3446 VariantClear(&v);
3448 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3449 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3450 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3451 VariantClear(&v);
3453 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3454 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3455 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3456 VariantClear(&v);
3458 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3459 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3460 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3461 VariantClear(&v);
3463 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3464 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3465 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3466 VariantClear(&v);
3468 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3469 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3470 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3471 VariantClear(&v);
3473 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3474 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3475 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3476 VariantClear(&v);
3478 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3479 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3480 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3481 VariantClear(&v);
3483 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3484 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3485 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3486 VariantClear(&v);
3488 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3489 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3490 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3491 VariantClear(&v);
3493 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3494 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3495 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3496 VariantClear(&v);
3498 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3499 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3500 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3501 VariantClear(&v);
3504 static void test_style2(IHTMLStyle2 *style2)
3506 VARIANT v;
3507 BSTR str;
3508 HRESULT hres;
3510 str = (void*)0xdeadbeef;
3511 hres = IHTMLStyle2_get_position(style2, &str);
3512 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3513 ok(!str, "str != NULL\n");
3515 str = a2bstr("absolute");
3516 hres = IHTMLStyle2_put_position(style2, str);
3517 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3518 SysFreeString(str);
3520 str = NULL;
3521 hres = IHTMLStyle2_get_position(style2, &str);
3522 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3523 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3524 SysFreeString(str);
3526 /* Test right */
3527 V_VT(&v) = VT_EMPTY;
3528 hres = IHTMLStyle2_get_right(style2, &v);
3529 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3530 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
3531 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
3532 VariantClear(&v);
3534 V_VT(&v) = VT_BSTR;
3535 V_BSTR(&v) = a2bstr("3px");
3536 hres = IHTMLStyle2_put_right(style2, v);
3537 ok(hres == S_OK, "put_right failed: %08x\n", hres);
3538 VariantClear(&v);
3540 V_VT(&v) = VT_EMPTY;
3541 hres = IHTMLStyle2_get_right(style2, &v);
3542 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3543 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3544 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3545 VariantClear(&v);
3548 static void test_style3(IHTMLStyle3 *style3)
3550 BSTR str;
3551 HRESULT hres;
3553 str = (void*)0xdeadbeef;
3554 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3555 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3556 ok(!str, "str != NULL\n");
3558 str = a2bstr("break-word");
3559 hres = IHTMLStyle3_put_wordWrap(style3, str);
3560 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3561 SysFreeString(str);
3563 str = NULL;
3564 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3565 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3566 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3567 SysFreeString(str);
3570 static void test_style4(IHTMLStyle4 *style4)
3572 HRESULT hres;
3573 VARIANT v;
3574 VARIANT vdefault;
3576 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3577 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3579 V_VT(&v) = VT_BSTR;
3580 V_BSTR(&v) = a2bstr("10px");
3581 hres = IHTMLStyle4_put_minHeight(style4, v);
3582 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3583 VariantClear(&v);
3585 hres = IHTMLStyle4_get_minHeight(style4, &v);
3586 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3587 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3588 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3590 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3591 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3592 VariantClear(&vdefault);
3595 static void test_default_style(IHTMLStyle *style)
3597 IHTMLStyle2 *style2;
3598 IHTMLStyle3 *style3;
3599 IHTMLStyle4 *style4;
3600 VARIANT_BOOL b;
3601 VARIANT v;
3602 BSTR str;
3603 HRESULT hres;
3604 float f;
3605 BSTR sOverflowDefault;
3606 BSTR sDefault;
3607 VARIANT vDefault;
3609 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3610 test_ifaces((IUnknown*)style, style_iids);
3612 test_style_csstext(style, NULL);
3614 hres = IHTMLStyle_get_position(style, &str);
3615 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3616 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3618 V_VT(&v) = VT_NULL;
3619 hres = IHTMLStyle_get_marginRight(style, &v);
3620 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3621 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3622 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3624 V_VT(&v) = VT_NULL;
3625 hres = IHTMLStyle_get_marginLeft(style, &v);
3626 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3627 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3628 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3630 str = (void*)0xdeadbeef;
3631 hres = IHTMLStyle_get_fontFamily(style, &str);
3632 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3633 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3635 str = (void*)0xdeadbeef;
3636 hres = IHTMLStyle_get_fontWeight(style, &str);
3637 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3638 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3640 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3641 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3643 str = a2bstr("test");
3644 hres = IHTMLStyle_put_fontWeight(style, str);
3645 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3646 SysFreeString(str);
3648 str = a2bstr("bold");
3649 hres = IHTMLStyle_put_fontWeight(style, str);
3650 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3651 SysFreeString(str);
3653 str = a2bstr("bolder");
3654 hres = IHTMLStyle_put_fontWeight(style, str);
3655 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3656 SysFreeString(str);
3658 str = a2bstr("lighter");
3659 hres = IHTMLStyle_put_fontWeight(style, str);
3660 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3661 SysFreeString(str);
3663 str = a2bstr("100");
3664 hres = IHTMLStyle_put_fontWeight(style, str);
3665 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3666 SysFreeString(str);
3668 str = a2bstr("200");
3669 hres = IHTMLStyle_put_fontWeight(style, str);
3670 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3671 SysFreeString(str);
3673 str = a2bstr("300");
3674 hres = IHTMLStyle_put_fontWeight(style, str);
3675 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3676 SysFreeString(str);
3678 str = a2bstr("400");
3679 hres = IHTMLStyle_put_fontWeight(style, str);
3680 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3681 SysFreeString(str);
3683 str = a2bstr("500");
3684 hres = IHTMLStyle_put_fontWeight(style, str);
3685 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3686 SysFreeString(str);
3688 str = a2bstr("600");
3689 hres = IHTMLStyle_put_fontWeight(style, str);
3690 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3691 SysFreeString(str);
3693 str = a2bstr("700");
3694 hres = IHTMLStyle_put_fontWeight(style, str);
3695 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3696 SysFreeString(str);
3698 str = a2bstr("800");
3699 hres = IHTMLStyle_put_fontWeight(style, str);
3700 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3701 SysFreeString(str);
3703 str = a2bstr("900");
3704 hres = IHTMLStyle_put_fontWeight(style, str);
3705 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3706 SysFreeString(str);
3708 hres = IHTMLStyle_get_fontWeight(style, &str);
3709 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3710 ok(!strcmp_wa(str, "900"), "str != style900\n");
3711 SysFreeString(str);
3713 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3714 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3715 SysFreeString(sDefault);
3717 /* font Variant */
3718 hres = IHTMLStyle_get_fontVariant(style, NULL);
3719 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3721 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3722 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3724 str = a2bstr("test");
3725 hres = IHTMLStyle_put_fontVariant(style, str);
3726 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3727 SysFreeString(str);
3729 str = a2bstr("small-caps");
3730 hres = IHTMLStyle_put_fontVariant(style, str);
3731 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3732 SysFreeString(str);
3734 str = a2bstr("normal");
3735 hres = IHTMLStyle_put_fontVariant(style, str);
3736 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3737 SysFreeString(str);
3739 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3740 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3741 SysFreeString(sDefault);
3743 str = (void*)0xdeadbeef;
3744 hres = IHTMLStyle_get_display(style, &str);
3745 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3746 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3748 str = (void*)0xdeadbeef;
3749 hres = IHTMLStyle_get_visibility(style, &str);
3750 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3751 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3753 V_VT(&v) = VT_NULL;
3754 hres = IHTMLStyle_get_fontSize(style, &v);
3755 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3756 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3757 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3759 V_VT(&v) = VT_NULL;
3760 hres = IHTMLStyle_get_color(style, &v);
3761 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3762 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3763 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3765 b = 0xfefe;
3766 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3767 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3768 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3770 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3771 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3772 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3774 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3775 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3776 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3778 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3779 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3781 b = 0xfefe;
3782 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3783 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3784 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3786 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3787 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3788 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3790 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3791 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3792 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3794 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3795 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3797 b = 0xfefe;
3798 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3799 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3800 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3802 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3803 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3804 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3806 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3807 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3808 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3810 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3811 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3813 b = 0xfefe;
3814 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3815 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3816 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3818 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3819 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3820 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3822 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3823 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3824 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3826 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3827 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3829 b = 0xfefe;
3830 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3831 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3832 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3834 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3835 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3836 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3838 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3839 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3840 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3842 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3843 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3845 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3846 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3848 str = a2bstr("invalid");
3849 hres = IHTMLStyle_put_textDecoration(style, str);
3850 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3851 SysFreeString(str);
3853 str = a2bstr("none");
3854 hres = IHTMLStyle_put_textDecoration(style, str);
3855 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3856 SysFreeString(str);
3858 str = a2bstr("underline");
3859 hres = IHTMLStyle_put_textDecoration(style, str);
3860 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3861 SysFreeString(str);
3863 str = a2bstr("overline");
3864 hres = IHTMLStyle_put_textDecoration(style, str);
3865 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3866 SysFreeString(str);
3868 str = a2bstr("line-through");
3869 hres = IHTMLStyle_put_textDecoration(style, str);
3870 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3871 SysFreeString(str);
3873 str = a2bstr("blink");
3874 hres = IHTMLStyle_put_textDecoration(style, str);
3875 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3876 SysFreeString(str);
3878 hres = IHTMLStyle_get_textDecoration(style, &str);
3879 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3880 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3881 SysFreeString(str);
3883 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3884 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3885 SysFreeString(sDefault);
3887 hres = IHTMLStyle_get_posWidth(style, NULL);
3888 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3890 hres = IHTMLStyle_get_posWidth(style, &f);
3891 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3892 ok(f == 0.0f, "f = %f\n", f);
3894 V_VT(&v) = VT_EMPTY;
3895 hres = IHTMLStyle_get_width(style, &v);
3896 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3897 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3898 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3900 hres = IHTMLStyle_put_posWidth(style, 2.2);
3901 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3903 hres = IHTMLStyle_get_posWidth(style, &f);
3904 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3905 ok(f == 2.0f ||
3906 f == 2.2f, /* IE8 */
3907 "f = %f\n", f);
3909 V_VT(&v) = VT_BSTR;
3910 V_BSTR(&v) = a2bstr("auto");
3911 hres = IHTMLStyle_put_width(style, v);
3912 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3913 VariantClear(&v);
3915 V_VT(&v) = VT_EMPTY;
3916 hres = IHTMLStyle_get_width(style, &v);
3917 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3918 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3919 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3920 VariantClear(&v);
3922 V_VT(&v) = VT_I4;
3923 V_I4(&v) = 100;
3924 hres = IHTMLStyle_put_width(style, v);
3925 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3927 V_VT(&v) = VT_EMPTY;
3928 hres = IHTMLStyle_get_width(style, &v);
3929 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3930 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3931 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3932 VariantClear(&v);
3934 /* margin tests */
3935 str = (void*)0xdeadbeef;
3936 hres = IHTMLStyle_get_margin(style, &str);
3937 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3938 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3940 str = a2bstr("1");
3941 hres = IHTMLStyle_put_margin(style, str);
3942 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3943 SysFreeString(str);
3945 hres = IHTMLStyle_get_margin(style, &str);
3946 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3947 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3949 hres = IHTMLStyle_put_margin(style, NULL);
3950 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3952 str = (void*)0xdeadbeef;
3953 hres = IHTMLStyle_get_marginTop(style, &v);
3954 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3955 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
3956 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3958 V_VT(&v) = VT_BSTR;
3959 V_BSTR(&v) = a2bstr("6px");
3960 hres = IHTMLStyle_put_marginTop(style, v);
3961 SysFreeString(V_BSTR(&v));
3962 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
3964 str = (void*)0xdeadbeef;
3965 hres = IHTMLStyle_get_marginTop(style, &v);
3966 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3967 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
3968 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3970 str = NULL;
3971 hres = IHTMLStyle_get_border(style, &str);
3972 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3973 ok(!str || !*str, "str is not empty\n");
3974 SysFreeString(str);
3976 str = a2bstr("1px");
3977 hres = IHTMLStyle_put_border(style, str);
3978 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3979 SysFreeString(str);
3981 V_VT(&v) = VT_EMPTY;
3982 hres = IHTMLStyle_get_left(style, &v);
3983 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3984 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3985 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3986 VariantClear(&v);
3988 /* Test posLeft */
3989 hres = IHTMLStyle_get_posLeft(style, NULL);
3990 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3992 f = 1.0f;
3993 hres = IHTMLStyle_get_posLeft(style, &f);
3994 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3995 ok(f == 0.0, "expected 0.0 got %f\n", f);
3997 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3998 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4000 hres = IHTMLStyle_get_posLeft(style, &f);
4001 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4002 ok(f == 4.0 ||
4003 f == 4.9f, /* IE8 */
4004 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4006 /* Ensure left is updated correctly. */
4007 V_VT(&v) = VT_EMPTY;
4008 hres = IHTMLStyle_get_left(style, &v);
4009 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4010 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4011 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4012 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4013 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4014 VariantClear(&v);
4016 /* Test left */
4017 V_VT(&v) = VT_BSTR;
4018 V_BSTR(&v) = a2bstr("3px");
4019 hres = IHTMLStyle_put_left(style, v);
4020 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4021 VariantClear(&v);
4023 hres = IHTMLStyle_get_posLeft(style, &f);
4024 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4025 ok(f == 3.0, "expected 3.0 got %f\n", f);
4027 V_VT(&v) = VT_EMPTY;
4028 hres = IHTMLStyle_get_left(style, &v);
4029 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4030 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4031 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4032 VariantClear(&v);
4034 V_VT(&v) = VT_NULL;
4035 hres = IHTMLStyle_put_left(style, v);
4036 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4038 V_VT(&v) = VT_EMPTY;
4039 hres = IHTMLStyle_get_left(style, &v);
4040 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4041 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4042 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4043 VariantClear(&v);
4045 V_VT(&v) = VT_EMPTY;
4046 hres = IHTMLStyle_get_top(style, &v);
4047 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4048 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4049 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4050 VariantClear(&v);
4052 /* Test posTop */
4053 hres = IHTMLStyle_get_posTop(style, NULL);
4054 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4056 f = 1.0f;
4057 hres = IHTMLStyle_get_posTop(style, &f);
4058 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4059 ok(f == 0.0, "expected 0.0 got %f\n", f);
4061 hres = IHTMLStyle_put_posTop(style, 4.9f);
4062 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4064 hres = IHTMLStyle_get_posTop(style, &f);
4065 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4066 ok(f == 4.0 ||
4067 f == 4.9f, /* IE8 */
4068 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4070 V_VT(&v) = VT_BSTR;
4071 V_BSTR(&v) = a2bstr("3px");
4072 hres = IHTMLStyle_put_top(style, v);
4073 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4074 VariantClear(&v);
4076 V_VT(&v) = VT_EMPTY;
4077 hres = IHTMLStyle_get_top(style, &v);
4078 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4079 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4080 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4081 VariantClear(&v);
4083 hres = IHTMLStyle_get_posTop(style, &f);
4084 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4085 ok(f == 3.0, "expected 3.0 got %f\n", f);
4087 V_VT(&v) = VT_NULL;
4088 hres = IHTMLStyle_put_top(style, v);
4089 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4091 V_VT(&v) = VT_EMPTY;
4092 hres = IHTMLStyle_get_top(style, &v);
4093 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4094 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4095 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4096 VariantClear(&v);
4098 /* Test posHeight */
4099 hres = IHTMLStyle_get_posHeight(style, NULL);
4100 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4102 V_VT(&v) = VT_EMPTY;
4103 hres = IHTMLStyle_get_height(style, &v);
4104 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4105 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4106 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4107 VariantClear(&v);
4109 f = 1.0f;
4110 hres = IHTMLStyle_get_posHeight(style, &f);
4111 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4112 ok(f == 0.0, "expected 0.0 got %f\n", f);
4114 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4115 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4117 hres = IHTMLStyle_get_posHeight(style, &f);
4118 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4119 ok(f == 4.0 ||
4120 f == 4.9f, /* IE8 */
4121 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4123 V_VT(&v) = VT_BSTR;
4124 V_BSTR(&v) = a2bstr("64px");
4125 hres = IHTMLStyle_put_height(style, v);
4126 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4127 VariantClear(&v);
4129 V_VT(&v) = VT_EMPTY;
4130 hres = IHTMLStyle_get_height(style, &v);
4131 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4132 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4133 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4134 VariantClear(&v);
4136 hres = IHTMLStyle_get_posHeight(style, &f);
4137 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4138 ok(f == 64.0, "expected 64.0 got %f\n", f);
4140 str = (void*)0xdeadbeef;
4141 hres = IHTMLStyle_get_cursor(style, &str);
4142 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4143 ok(!str, "get_cursor != NULL\n");
4144 SysFreeString(str);
4146 str = a2bstr("default");
4147 hres = IHTMLStyle_put_cursor(style, str);
4148 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4149 SysFreeString(str);
4151 str = NULL;
4152 hres = IHTMLStyle_get_cursor(style, &str);
4153 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4154 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4155 SysFreeString(str);
4157 V_VT(&v) = VT_EMPTY;
4158 hres = IHTMLStyle_get_verticalAlign(style, &v);
4159 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4160 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4161 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4162 VariantClear(&v);
4164 V_VT(&v) = VT_BSTR;
4165 V_BSTR(&v) = a2bstr("middle");
4166 hres = IHTMLStyle_put_verticalAlign(style, v);
4167 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4168 VariantClear(&v);
4170 V_VT(&v) = VT_EMPTY;
4171 hres = IHTMLStyle_get_verticalAlign(style, &v);
4172 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4173 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4174 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4175 VariantClear(&v);
4177 str = (void*)0xdeadbeef;
4178 hres = IHTMLStyle_get_textAlign(style, &str);
4179 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4180 ok(!str, "textAlign != NULL\n");
4182 str = a2bstr("center");
4183 hres = IHTMLStyle_put_textAlign(style, str);
4184 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4185 SysFreeString(str);
4187 str = NULL;
4188 hres = IHTMLStyle_get_textAlign(style, &str);
4189 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4190 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4191 SysFreeString(str);
4193 str = (void*)0xdeadbeef;
4194 hres = IHTMLStyle_get_filter(style, &str);
4195 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4196 ok(!str, "filter != NULL\n");
4198 str = a2bstr("alpha(opacity=100)");
4199 hres = IHTMLStyle_put_filter(style, str);
4200 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4201 SysFreeString(str);
4203 V_VT(&v) = VT_EMPTY;
4204 hres = IHTMLStyle_get_zIndex(style, &v);
4205 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4206 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4207 ok(!V_I4(&v), "V_I4(v) != 0\n");
4208 VariantClear(&v);
4210 V_VT(&v) = VT_BSTR;
4211 V_BSTR(&v) = a2bstr("1");
4212 hres = IHTMLStyle_put_zIndex(style, v);
4213 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4214 VariantClear(&v);
4216 V_VT(&v) = VT_EMPTY;
4217 hres = IHTMLStyle_get_zIndex(style, &v);
4218 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4219 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4220 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4221 VariantClear(&v);
4223 /* fontStyle */
4224 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4225 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4227 str = a2bstr("test");
4228 hres = IHTMLStyle_put_fontStyle(style, str);
4229 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4230 SysFreeString(str);
4232 str = a2bstr("italic");
4233 hres = IHTMLStyle_put_fontStyle(style, str);
4234 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4235 SysFreeString(str);
4237 str = a2bstr("oblique");
4238 hres = IHTMLStyle_put_fontStyle(style, str);
4239 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4240 SysFreeString(str);
4242 str = a2bstr("normal");
4243 hres = IHTMLStyle_put_fontStyle(style, str);
4244 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4245 SysFreeString(str);
4247 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4248 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4249 SysFreeString(sDefault);
4251 /* overflow */
4252 hres = IHTMLStyle_get_overflow(style, NULL);
4253 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4255 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4256 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4258 str = a2bstr("test");
4259 hres = IHTMLStyle_put_overflow(style, str);
4260 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4261 SysFreeString(str);
4263 str = a2bstr("visible");
4264 hres = IHTMLStyle_put_overflow(style, str);
4265 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4266 SysFreeString(str);
4268 str = a2bstr("scroll");
4269 hres = IHTMLStyle_put_overflow(style, str);
4270 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4271 SysFreeString(str);
4273 str = a2bstr("hidden");
4274 hres = IHTMLStyle_put_overflow(style, str);
4275 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4276 SysFreeString(str);
4278 str = a2bstr("auto");
4279 hres = IHTMLStyle_put_overflow(style, str);
4280 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4281 SysFreeString(str);
4283 hres = IHTMLStyle_get_overflow(style, &str);
4284 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4285 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4286 SysFreeString(str);
4288 str = a2bstr("");
4289 hres = IHTMLStyle_put_overflow(style, str);
4290 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4291 SysFreeString(str);
4293 hres = IHTMLStyle_get_overflow(style, &str);
4294 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4295 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4296 SysFreeString(str);
4298 /* restore overflow default */
4299 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4300 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4301 SysFreeString(sOverflowDefault);
4303 /* Attribute Tests*/
4304 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4305 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4307 str = a2bstr("position");
4308 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4309 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4311 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4312 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4313 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4314 VariantClear(&v);
4316 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4317 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4319 V_VT(&v) = VT_BSTR;
4320 V_BSTR(&v) = a2bstr("absolute");
4321 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4322 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4323 VariantClear(&v);
4325 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4326 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4327 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4328 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4329 VariantClear(&v);
4331 V_VT(&v) = VT_BSTR;
4332 V_BSTR(&v) = NULL;
4333 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4334 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4335 VariantClear(&v);
4337 SysFreeString(str);
4339 str = a2bstr("borderLeftStyle");
4340 test_border_styles(style, str);
4341 SysFreeString(str);
4343 str = a2bstr("borderbottomstyle");
4344 test_border_styles(style, str);
4345 SysFreeString(str);
4347 str = a2bstr("borderrightstyle");
4348 test_border_styles(style, str);
4349 SysFreeString(str);
4351 str = a2bstr("bordertopstyle");
4352 test_border_styles(style, str);
4353 SysFreeString(str);
4355 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4356 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4358 str = a2bstr("none dotted dashed solid");
4359 hres = IHTMLStyle_put_borderStyle(style, str);
4360 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4361 SysFreeString(str);
4363 str = a2bstr("none dotted dashed solid");
4364 hres = IHTMLStyle_get_borderStyle(style, &str);
4365 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4366 ok(!strcmp_wa(str, "none dotted dashed solid"),
4367 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4368 SysFreeString(str);
4370 str = a2bstr("double groove ridge inset");
4371 hres = IHTMLStyle_put_borderStyle(style, str);
4372 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4373 SysFreeString(str);
4375 str = a2bstr("window-inset outset ridge inset");
4376 hres = IHTMLStyle_put_borderStyle(style, str);
4377 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4378 SysFreeString(str);
4380 str = a2bstr("window-inset");
4381 hres = IHTMLStyle_put_borderStyle(style, str);
4382 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4383 SysFreeString(str);
4385 str = a2bstr("none none none none none");
4386 hres = IHTMLStyle_put_borderStyle(style, str);
4387 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4388 SysFreeString(str);
4390 str = a2bstr("invalid none none none");
4391 hres = IHTMLStyle_put_borderStyle(style, str);
4392 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4393 SysFreeString(str);
4395 str = a2bstr("none invalid none none");
4396 hres = IHTMLStyle_put_borderStyle(style, str);
4397 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4398 SysFreeString(str);
4400 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4401 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4402 SysFreeString(sDefault);
4404 /* backgoundColor */
4405 hres = IHTMLStyle_get_backgroundColor(style, &v);
4406 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4407 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4408 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4409 VariantClear(&v);
4411 /* PaddingLeft */
4412 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4413 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4415 V_VT(&v) = VT_BSTR;
4416 V_BSTR(&v) = a2bstr("10");
4417 hres = IHTMLStyle_put_paddingLeft(style, v);
4418 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4419 VariantClear(&v);
4421 hres = IHTMLStyle_get_paddingLeft(style, &v);
4422 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4423 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4425 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4426 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4428 /* BackgroundRepeat */
4429 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4430 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4432 str = a2bstr("invalid");
4433 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4434 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4435 SysFreeString(str);
4437 str = a2bstr("repeat");
4438 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4439 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4440 SysFreeString(str);
4442 str = a2bstr("no-repeat");
4443 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4444 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4445 SysFreeString(str);
4447 str = a2bstr("repeat-x");
4448 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4449 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4450 SysFreeString(str);
4452 str = a2bstr("repeat-y");
4453 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4454 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4455 SysFreeString(str);
4457 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4458 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4459 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4460 SysFreeString(str);
4462 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4463 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4464 SysFreeString(sDefault);
4466 /* BorderColor */
4467 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4468 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4470 str = a2bstr("red green red blue");
4471 hres = IHTMLStyle_put_borderColor(style, str);
4472 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4473 SysFreeString(str);
4475 hres = IHTMLStyle_get_borderColor(style, &str);
4476 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4477 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4478 SysFreeString(str);
4480 hres = IHTMLStyle_put_borderColor(style, sDefault);
4481 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4482 SysFreeString(sDefault);
4484 /* BorderRight */
4485 hres = IHTMLStyle_get_borderRight(style, &sDefault);
4486 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
4488 str = a2bstr("thick dotted red");
4489 hres = IHTMLStyle_put_borderRight(style, str);
4490 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4491 SysFreeString(str);
4493 /* IHTMLStyle_get_borderRight appears to have a bug where
4494 it returns the first letter of the color. So we check
4495 each style individually.
4497 V_BSTR(&v) = NULL;
4498 hres = IHTMLStyle_get_borderRightColor(style, &v);
4499 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4500 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4501 VariantClear(&v);
4503 V_BSTR(&v) = NULL;
4504 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4505 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4506 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4507 VariantClear(&v);
4509 hres = IHTMLStyle_get_borderRightStyle(style, &str);
4510 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
4511 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4512 SysFreeString(str);
4514 hres = IHTMLStyle_put_borderRight(style, sDefault);
4515 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4516 SysFreeString(sDefault);
4518 /* BorderTop */
4519 hres = IHTMLStyle_get_borderTop(style, &sDefault);
4520 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
4522 str = a2bstr("thick dotted red");
4523 hres = IHTMLStyle_put_borderTop(style, str);
4524 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4525 SysFreeString(str);
4527 /* IHTMLStyle_get_borderTop appears to have a bug where
4528 it returns the first letter of the color. So we check
4529 each style individually.
4531 V_BSTR(&v) = NULL;
4532 hres = IHTMLStyle_get_borderTopColor(style, &v);
4533 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4534 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4535 VariantClear(&v);
4537 V_BSTR(&v) = NULL;
4538 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4539 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4540 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4541 VariantClear(&v);
4543 hres = IHTMLStyle_get_borderTopStyle(style, &str);
4544 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
4545 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4546 SysFreeString(str);
4548 hres = IHTMLStyle_put_borderTop(style, sDefault);
4549 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
4550 SysFreeString(sDefault);
4552 /* BorderBottom */
4553 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
4554 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
4556 str = a2bstr("thick dotted red");
4557 hres = IHTMLStyle_put_borderBottom(style, str);
4558 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4559 SysFreeString(str);
4561 /* IHTMLStyle_get_borderBottom appears to have a bug where
4562 it returns the first letter of the color. So we check
4563 each style individually.
4565 V_BSTR(&v) = NULL;
4566 hres = IHTMLStyle_get_borderBottomColor(style, &v);
4567 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4568 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4569 VariantClear(&v);
4571 V_BSTR(&v) = NULL;
4572 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4573 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4574 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4575 VariantClear(&v);
4577 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
4578 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
4579 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4580 SysFreeString(str);
4582 hres = IHTMLStyle_put_borderBottom(style, sDefault);
4583 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
4584 SysFreeString(sDefault);
4586 /* BorderLeft */
4587 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4588 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4590 str = a2bstr("thick dotted red");
4591 hres = IHTMLStyle_put_borderLeft(style, str);
4592 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4593 SysFreeString(str);
4595 /* IHTMLStyle_get_borderLeft appears to have a bug where
4596 it returns the first letter of the color. So we check
4597 each style individually.
4599 V_BSTR(&v) = NULL;
4600 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4601 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4602 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4603 VariantClear(&v);
4605 V_BSTR(&v) = NULL;
4606 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4607 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4608 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4609 VariantClear(&v);
4611 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4612 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4613 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4614 SysFreeString(str);
4616 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4617 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4618 SysFreeString(sDefault);
4620 /* backgroundPositionX */
4621 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4622 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4624 V_VT(&v) = VT_BSTR;
4625 V_BSTR(&v) = a2bstr("10px");
4626 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4627 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4628 VariantClear(&v);
4630 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4631 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4632 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4633 VariantClear(&v);
4635 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4636 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4637 VariantClear(&vDefault);
4639 /* backgroundPositionY */
4640 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4641 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4643 V_VT(&v) = VT_BSTR;
4644 V_BSTR(&v) = a2bstr("10px");
4645 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4646 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4647 VariantClear(&v);
4649 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4650 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4651 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4652 VariantClear(&v);
4654 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4655 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4656 VariantClear(&vDefault);
4658 /* borderTopWidth */
4659 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4660 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4662 V_VT(&v) = VT_BSTR;
4663 V_BSTR(&v) = a2bstr("10px");
4664 hres = IHTMLStyle_put_borderTopWidth(style, v);
4665 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4666 VariantClear(&v);
4668 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4669 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4670 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4671 VariantClear(&v);
4673 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4674 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4675 VariantClear(&vDefault);
4677 /* borderRightWidth */
4678 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4679 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4681 V_VT(&v) = VT_BSTR;
4682 V_BSTR(&v) = a2bstr("10");
4683 hres = IHTMLStyle_put_borderRightWidth(style, v);
4684 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4685 VariantClear(&v);
4687 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4688 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4689 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4690 VariantClear(&v);
4692 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4693 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4694 VariantClear(&vDefault);
4696 /* borderBottomWidth */
4697 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4698 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4700 V_VT(&v) = VT_BSTR;
4701 V_BSTR(&v) = a2bstr("10");
4702 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4703 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4704 VariantClear(&v);
4706 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4707 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4708 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4709 VariantClear(&v);
4711 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4712 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4713 VariantClear(&vDefault);
4715 /* borderLeftWidth */
4716 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4717 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4719 V_VT(&v) = VT_BSTR;
4720 V_BSTR(&v) = a2bstr("10");
4721 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4722 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4723 VariantClear(&v);
4725 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4726 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4727 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4728 VariantClear(&v);
4730 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4731 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4732 VariantClear(&vDefault);
4734 /* wordSpacing */
4735 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4736 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4738 V_VT(&v) = VT_BSTR;
4739 V_BSTR(&v) = a2bstr("10");
4740 hres = IHTMLStyle_put_wordSpacing(style, v);
4741 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4742 VariantClear(&v);
4744 hres = IHTMLStyle_get_wordSpacing(style, &v);
4745 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4746 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4747 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4748 VariantClear(&v);
4750 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4751 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4752 VariantClear(&vDefault);
4754 /* letterSpacing */
4755 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4756 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4758 V_VT(&v) = VT_BSTR;
4759 V_BSTR(&v) = a2bstr("11");
4760 hres = IHTMLStyle_put_letterSpacing(style, v);
4761 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4762 VariantClear(&v);
4764 hres = IHTMLStyle_get_letterSpacing(style, &v);
4765 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4766 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4767 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4768 VariantClear(&v);
4770 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4771 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4772 VariantClear(&vDefault);
4774 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4775 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4776 if(SUCCEEDED(hres)) {
4777 test_style2(style2);
4778 IHTMLStyle2_Release(style2);
4781 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4782 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4783 if(SUCCEEDED(hres)) {
4784 test_style3(style3);
4785 IHTMLStyle3_Release(style3);
4788 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4789 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4790 if(SUCCEEDED(hres)) {
4791 test_style4(style4);
4792 IHTMLStyle4_Release(style4);
4796 static void test_set_csstext(IHTMLStyle *style)
4798 VARIANT v;
4799 HRESULT hres;
4801 test_style_set_csstext(style, "background-color: black;");
4803 hres = IHTMLStyle_get_backgroundColor(style, &v);
4804 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4805 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4806 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4807 VariantClear(&v);
4810 static void test_default_selection(IHTMLDocument2 *doc)
4812 IHTMLSelectionObject *selection;
4813 IHTMLTxtRange *range;
4814 IDispatch *disp;
4815 BSTR str;
4816 HRESULT hres;
4818 hres = IHTMLDocument2_get_selection(doc, &selection);
4819 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4821 hres = IHTMLSelectionObject_get_type(selection, &str);
4822 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4823 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4824 SysFreeString(str);
4826 hres = IHTMLSelectionObject_createRange(selection, &disp);
4827 IHTMLSelectionObject_Release(selection);
4828 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4830 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4831 IDispatch_Release(disp);
4832 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4834 test_range_text(range, NULL);
4835 IHTMLTxtRange_Release(range);
4838 static void test_doc_elem(IHTMLDocument2 *doc)
4840 IHTMLDocument2 *doc_node, *owner_doc;
4841 IHTMLElement *elem;
4842 IHTMLDocument3 *doc3;
4843 HRESULT hres;
4845 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4846 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4848 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4849 IHTMLDocument3_Release(doc3);
4850 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4852 test_node_name((IUnknown*)elem, "HTML");
4853 test_elem_tag((IUnknown*)elem, "HTML");
4855 doc_node = get_doc_node(doc);
4856 owner_doc = get_owner_doc((IUnknown*)elem);
4857 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4858 IHTMLDocument2_Release(owner_doc);
4860 owner_doc = get_owner_doc((IUnknown*)doc_node);
4861 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4862 IHTMLDocument2_Release(doc_node);
4864 test_elem_client_rect((IUnknown*)elem);
4866 IHTMLElement_Release(elem);
4869 static void test_default_body(IHTMLBodyElement *body)
4871 LONG l;
4872 BSTR bstr;
4873 HRESULT hres;
4874 VARIANT v;
4876 bstr = (void*)0xdeadbeef;
4877 hres = IHTMLBodyElement_get_background(body, &bstr);
4878 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4879 ok(bstr == NULL, "bstr != NULL\n");
4881 l = elem_get_scroll_height((IUnknown*)body);
4882 ok(l != -1, "scrollHeight == -1\n");
4883 l = elem_get_scroll_width((IUnknown*)body);
4884 ok(l != -1, "scrollWidth == -1\n");
4885 l = elem_get_scroll_top((IUnknown*)body);
4886 ok(!l, "scrollTop = %d\n", l);
4887 elem_get_scroll_left((IUnknown*)body);
4889 /* get_text tests */
4890 hres = IHTMLBodyElement_get_text(body, &v);
4891 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4892 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4893 ok(bstr == NULL, "bstr != NULL\n");
4895 /* get_text - Invalid Text */
4896 V_VT(&v) = VT_BSTR;
4897 V_BSTR(&v) = a2bstr("Invalid");
4898 hres = IHTMLBodyElement_put_text(body, v);
4899 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4900 VariantClear(&v);
4902 V_VT(&v) = VT_NULL;
4903 hres = IHTMLBodyElement_get_text(body, &v);
4904 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4905 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4906 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
4907 VariantClear(&v);
4909 /* get_text - Valid Text */
4910 V_VT(&v) = VT_BSTR;
4911 V_BSTR(&v) = a2bstr("#FF0000");
4912 hres = IHTMLBodyElement_put_text(body, v);
4913 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4914 VariantClear(&v);
4916 V_VT(&v) = VT_NULL;
4917 hres = IHTMLBodyElement_get_text(body, &v);
4918 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4919 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4920 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
4921 VariantClear(&v);
4924 static void test_body_funs(IHTMLBodyElement *body)
4926 VARIANT vbg, vDefaultbg;
4927 HRESULT hres;
4929 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4930 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4931 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4932 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
4934 V_VT(&vbg) = VT_BSTR;
4935 V_BSTR(&vbg) = a2bstr("red");
4936 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4937 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4938 VariantClear(&vbg);
4940 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4941 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4942 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4943 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4944 VariantClear(&vbg);
4946 /* Restore Originial */
4947 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4948 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4949 VariantClear(&vDefaultbg);
4952 static void test_window(IHTMLDocument2 *doc)
4954 IHTMLWindow2 *window, *window2, *self;
4955 IHTMLDocument2 *doc2 = NULL;
4956 IDispatch *disp;
4957 IUnknown *unk;
4958 BSTR str;
4959 HRESULT hres;
4961 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4962 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4963 test_ifaces((IUnknown*)window, window_iids);
4964 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4966 hres = IHTMLWindow2_get_document(window, &doc2);
4967 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4968 ok(doc2 != NULL, "doc2 == NULL\n");
4970 test_ifaces((IUnknown*)doc2, doc_node_iids);
4971 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4973 test_ifaces((IUnknown*)doc, doc_obj_iids);
4974 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4976 unk = (void*)0xdeadbeef;
4977 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4978 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4979 ok(!unk, "unk = %p\n", unk);
4981 IHTMLDocument_Release(doc2);
4983 hres = IHTMLWindow2_get_window(window, &window2);
4984 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4985 ok(window2 != NULL, "window2 == NULL\n");
4987 hres = IHTMLWindow2_get_self(window, &self);
4988 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4989 ok(window2 != NULL, "self == NULL\n");
4991 ok(self == window2, "self != window2\n");
4993 IHTMLWindow2_Release(window2);
4994 IHTMLWindow2_Release(self);
4996 disp = NULL;
4997 hres = IHTMLDocument2_get_Script(doc, &disp);
4998 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4999 ok(disp == (void*)window, "disp != window\n");
5000 IDispatch_Release(disp);
5002 hres = IHTMLWindow2_toString(window, NULL);
5003 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5005 str = NULL;
5006 hres = IHTMLWindow2_toString(window, &str);
5007 ok(hres == S_OK, "toString failed: %08x\n", hres);
5008 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5009 SysFreeString(str);
5011 test_window_name(window, NULL);
5012 set_window_name(window, "test");
5013 test_window_length(window, 0);
5014 test_screen(window);
5016 IHTMLWindow2_Release(window);
5019 static void test_defaults(IHTMLDocument2 *doc)
5021 IHTMLStyleSheetsCollection *stylesheetcol;
5022 IHTMLCurrentStyle *cstyle;
5023 IHTMLBodyElement *body;
5024 IHTMLElement2 *elem2;
5025 IHTMLElement *elem;
5026 IHTMLStyle *style;
5027 LONG l;
5028 HRESULT hres;
5029 IHTMLElementCollection *collection;
5031 hres = IHTMLDocument2_get_body(doc, &elem);
5032 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5034 hres = IHTMLDocument2_get_images(doc, NULL);
5035 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5037 hres = IHTMLDocument2_get_images(doc, &collection);
5038 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5039 if(hres == S_OK)
5041 test_elem_collection((IUnknown*)collection, NULL, 0);
5042 IHTMLElementCollection_Release(collection);
5045 hres = IHTMLDocument2_get_applets(doc, NULL);
5046 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5048 hres = IHTMLDocument2_get_applets(doc, &collection);
5049 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5050 if(hres == S_OK)
5052 test_elem_collection((IUnknown*)collection, NULL, 0);
5053 IHTMLElementCollection_Release(collection);
5056 hres = IHTMLDocument2_get_links(doc, NULL);
5057 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5059 hres = IHTMLDocument2_get_links(doc, &collection);
5060 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5061 if(hres == S_OK)
5063 test_elem_collection((IUnknown*)collection, NULL, 0);
5064 IHTMLElementCollection_Release(collection);
5067 hres = IHTMLDocument2_get_forms(doc, NULL);
5068 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5070 hres = IHTMLDocument2_get_forms(doc, &collection);
5071 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5072 if(hres == S_OK)
5074 test_elem_collection((IUnknown*)collection, NULL, 0);
5075 IHTMLElementCollection_Release(collection);
5078 hres = IHTMLDocument2_get_anchors(doc, NULL);
5079 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5081 hres = IHTMLDocument2_get_anchors(doc, &collection);
5082 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5083 if(hres == S_OK)
5085 test_elem_collection((IUnknown*)collection, NULL, 0);
5086 IHTMLElementCollection_Release(collection);
5089 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5090 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5091 test_default_body(body);
5092 test_body_funs(body);
5093 IHTMLBodyElement_Release(body);
5095 hres = IHTMLElement_get_style(elem, &style);
5096 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5098 test_default_style(style);
5099 test_window(doc);
5100 test_compatmode(doc);
5101 test_location(doc);
5102 test_navigator(doc);
5104 elem2 = get_elem2_iface((IUnknown*)elem);
5105 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5106 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5107 if(SUCCEEDED(hres)) {
5108 test_current_style(cstyle);
5109 IHTMLCurrentStyle_Release(cstyle);
5111 IHTMLElement2_Release(elem2);
5113 IHTMLElement_Release(elem);
5115 test_set_csstext(style);
5116 IHTMLStyle_Release(style);
5118 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5119 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5121 l = 0xdeadbeef;
5122 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5123 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5124 ok(l == 0, "length = %d\n", l);
5126 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5128 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5129 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5131 test_default_selection(doc);
5132 test_doc_title(doc, "");
5135 static void test_tr_elem(IHTMLElement *elem)
5137 IHTMLElementCollection *col;
5138 IHTMLTableRow *row;
5139 HRESULT hres;
5141 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5143 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5144 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5145 if(FAILED(hres))
5146 return;
5148 col = NULL;
5149 hres = IHTMLTableRow_get_cells(row, &col);
5150 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5151 ok(col != NULL, "get_cells returned NULL\n");
5153 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5154 IHTMLElementCollection_Release(col);
5156 IHTMLTable_Release(row);
5159 static void test_table_elem(IHTMLElement *elem)
5161 IHTMLElementCollection *col;
5162 IHTMLTable *table;
5163 IHTMLDOMNode *node;
5164 HRESULT hres;
5166 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5167 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5169 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5170 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5171 if(FAILED(hres))
5172 return;
5174 col = NULL;
5175 hres = IHTMLTable_get_rows(table, &col);
5176 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5177 ok(col != NULL, "get_ros returned NULL\n");
5179 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5180 IHTMLElementCollection_Release(col);
5182 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5184 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5185 test_elem_tag((IUnknown*)node, "TABLE");
5186 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5187 IHTMLDOMNode_Release(node);
5189 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5190 test_elem_tag((IUnknown*)node, "TABLE");
5191 test_elem_all((IUnknown*)node, NULL, 0);
5192 IHTMLDOMNode_Release(node);
5194 IHTMLTable_Release(table);
5197 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5199 SAFEARRAYBOUND dim;
5200 SAFEARRAY *sa;
5201 VARIANT *var;
5202 BSTR str;
5203 HRESULT hres;
5205 dim.lLbound = 0;
5206 dim.cElements = 1;
5207 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5208 SafeArrayAccessData(sa, (void**)&var);
5209 V_VT(var) = VT_BSTR;
5210 V_BSTR(var) = str = a2bstr(text);
5211 SafeArrayUnaccessData(sa);
5213 if(ln)
5214 hres = IHTMLDocument2_writeln(doc, sa);
5215 else
5216 hres = IHTMLDocument2_write(doc, sa);
5217 ok(hres == S_OK, "write failed: %08x\n", hres);
5219 SysFreeString(str);
5220 SafeArrayDestroy(sa);
5223 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5225 IHTMLDocument2 *window_doc, *elem_doc;
5226 IHTMLFrameElement3 *frame_elem3;
5227 IHTMLWindow2 *content_window;
5228 HRESULT hres;
5230 content_window = get_frame_content_window(frame_elem);
5231 window_doc = get_window_doc(content_window);
5232 IHTMLWindow2_Release(content_window);
5234 elem_doc = get_elem_doc(frame_elem);
5235 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5237 if(!iframe) {
5238 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5239 if(SUCCEEDED(hres)) {
5240 IDispatch *disp = NULL;
5242 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5243 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5244 ok(disp != NULL, "contentDocument == NULL\n");
5245 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5247 IDispatch_Release(disp);
5248 IHTMLFrameElement3_Release(frame_elem3);
5249 }else {
5250 win_skip("IHTMLFrameElement3 not supported\n");
5254 IHTMLDocument2_Release(elem_doc);
5255 IHTMLDocument2_Release(window_doc);
5258 static void test_iframe_elem(IHTMLElement *elem)
5260 IHTMLDocument2 *content_doc, *owner_doc;
5261 IHTMLElementCollection *col;
5262 IHTMLWindow2 *content_window;
5263 IDispatch *disp;
5264 VARIANT errv;
5265 BSTR str;
5266 HRESULT hres;
5268 static const elem_type_t all_types[] = {
5269 ET_HTML,
5270 ET_HEAD,
5271 ET_TITLE,
5272 ET_BODY,
5273 ET_BR
5276 test_frame_doc((IUnknown*)elem, TRUE);
5278 content_window = get_frame_content_window((IUnknown*)elem);
5279 test_window_length(content_window, 0);
5281 content_doc = get_window_doc(content_window);
5282 IHTMLWindow2_Release(content_window);
5284 str = a2bstr("text/html");
5285 V_VT(&errv) = VT_ERROR;
5286 disp = NULL;
5287 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5288 SysFreeString(str);
5289 ok(hres == S_OK, "open failed: %08x\n", hres);
5290 ok(disp != NULL, "disp == NULL\n");
5291 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5292 IDispatch_Release(disp);
5294 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5295 doc_write(content_doc, TRUE, "</html>");
5297 hres = IHTMLDocument2_get_all(content_doc, &col);
5298 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5299 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5300 IHTMLElementCollection_Release(col);
5302 hres = IHTMLDocument2_close(content_doc);
5303 ok(hres == S_OK, "close failed: %08x\n", hres);
5305 owner_doc = get_owner_doc((IUnknown*)content_doc);
5306 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5308 IHTMLDocument2_Release(content_doc);
5311 static void test_stylesheet(IDispatch *disp)
5313 IHTMLStyleSheetRulesCollection *col = NULL;
5314 IHTMLStyleSheet *stylesheet;
5315 HRESULT hres;
5317 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5318 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5320 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5321 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5322 ok(col != NULL, "col == NULL\n");
5324 IHTMLStyleSheetRulesCollection_Release(col);
5325 IHTMLStyleSheet_Release(stylesheet);
5328 static void test_stylesheets(IHTMLDocument2 *doc)
5330 IHTMLStyleSheetsCollection *col = NULL;
5331 VARIANT idx, res;
5332 LONG len = 0;
5333 HRESULT hres;
5335 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5336 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5337 ok(col != NULL, "col == NULL\n");
5339 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5340 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5341 ok(len == 1, "len=%d\n", len);
5343 VariantInit(&res);
5344 V_VT(&idx) = VT_I4;
5345 V_I4(&idx) = 0;
5347 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5348 ok(hres == S_OK, "item failed: %08x\n", hres);
5349 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5350 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5351 test_stylesheet(V_DISPATCH(&res));
5352 VariantClear(&res);
5354 V_VT(&res) = VT_I4;
5355 V_VT(&idx) = VT_I4;
5356 V_I4(&idx) = 1;
5358 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5359 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5360 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5361 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5362 VariantClear(&res);
5364 IHTMLStyleSheetsCollection_Release(col);
5367 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5369 IDispatchEx *dispex;
5370 IHTMLDOMNode *node;
5371 DISPPARAMS dp = {NULL, NULL, 0, 0};
5372 VARIANT var;
5373 EXCEPINFO ei;
5374 LONG type;
5375 DISPID id;
5376 BSTR bstr;
5377 HRESULT hres;
5379 static const WCHAR w0[] = {'0',0};
5380 static const WCHAR w100[] = {'1','0','0',0};
5382 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5383 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5385 bstr = SysAllocString(w0);
5386 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5387 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5388 SysFreeString(bstr);
5390 VariantInit(&var);
5391 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5392 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5393 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5394 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5395 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5396 type = get_node_type((IUnknown*)node);
5397 ok(type == 3, "type=%d\n", type);
5398 IHTMLDOMNode_Release(node);
5399 VariantClear(&var);
5401 bstr = SysAllocString(w100);
5402 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5403 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5404 SysFreeString(bstr);
5406 IDispatchEx_Release(dispex);
5411 static void test_elems(IHTMLDocument2 *doc)
5413 IHTMLElementCollection *col;
5414 IHTMLDOMChildrenCollection *child_col;
5415 IHTMLElement *elem, *elem2, *elem3;
5416 IHTMLDOMNode *node, *node2;
5417 IHTMLWindow2 *window;
5418 IDispatch *disp;
5419 LONG type;
5420 HRESULT hres;
5421 IHTMLElementCollection *collection;
5422 IHTMLDocument3 *doc3;
5423 BSTR str;
5425 static const elem_type_t all_types[] = {
5426 ET_HTML,
5427 ET_HEAD,
5428 ET_TITLE,
5429 ET_STYLE,
5430 ET_BODY,
5431 ET_COMMENT,
5432 ET_A,
5433 ET_INPUT,
5434 ET_SELECT,
5435 ET_OPTION,
5436 ET_OPTION,
5437 ET_TEXTAREA,
5438 ET_TABLE,
5439 ET_TBODY,
5440 ET_TR,
5441 ET_TR,
5442 ET_TD,
5443 ET_TD,
5444 ET_SCRIPT,
5445 ET_TEST,
5446 ET_IMG,
5447 ET_IFRAME,
5448 ET_FORM
5451 static const elem_type_t item_types[] = {
5452 ET_A,
5453 ET_OPTION,
5454 ET_TEXTAREA
5457 hres = IHTMLDocument2_get_all(doc, &col);
5458 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5459 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5460 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5461 IHTMLElementCollection_Release(col);
5463 hres = IHTMLDocument2_get_images(doc, &collection);
5464 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5465 if(hres == S_OK)
5467 static const elem_type_t images_types[] = {ET_IMG};
5468 test_elem_collection((IUnknown*)collection, images_types, 1);
5470 IHTMLElementCollection_Release(collection);
5473 hres = IHTMLDocument2_get_links(doc, &collection);
5474 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5475 if(hres == S_OK)
5477 static const elem_type_t images_types[] = {ET_A};
5478 test_elem_collection((IUnknown*)collection, images_types, 1);
5480 IHTMLElementCollection_Release(collection);
5483 hres = IHTMLDocument2_get_anchors(doc, &collection);
5484 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5485 if(hres == S_OK)
5487 static const elem_type_t anchor_types[] = {ET_A};
5488 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5490 IHTMLElementCollection_Release(collection);
5493 elem = get_doc_elem(doc);
5494 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5495 IHTMLElement_Release(elem);
5497 get_elem_by_id(doc, "xxx", FALSE);
5498 elem = get_doc_elem_by_id(doc, "xxx");
5499 ok(!elem, "elem != NULL\n");
5501 elem = get_doc_elem_by_id(doc, "s");
5502 ok(elem != NULL, "elem == NULL\n");
5503 if(elem) {
5504 test_elem_type((IUnknown*)elem, ET_SELECT);
5505 test_elem_attr(elem, "xxx", NULL);
5506 test_elem_attr(elem, "id", "s");
5507 test_elem_class((IUnknown*)elem, NULL);
5508 test_elem_set_class((IUnknown*)elem, "cl");
5509 test_elem_set_class((IUnknown*)elem, NULL);
5510 test_elem_tabindex((IUnknown*)elem, 0);
5511 test_elem_set_tabindex((IUnknown*)elem, 1);
5512 test_elem_filters((IUnknown*)elem);
5514 node = test_node_get_parent((IUnknown*)elem);
5515 ok(node != NULL, "node == NULL\n");
5516 test_node_name((IUnknown*)node, "BODY");
5517 node2 = test_node_get_parent((IUnknown*)node);
5518 IHTMLDOMNode_Release(node);
5519 ok(node2 != NULL, "node == NULL\n");
5520 test_node_name((IUnknown*)node2, "HTML");
5521 node = test_node_get_parent((IUnknown*)node2);
5522 IHTMLDOMNode_Release(node2);
5523 ok(node != NULL, "node == NULL\n");
5524 if (node)
5526 test_node_name((IUnknown*)node, "#document");
5527 type = get_node_type((IUnknown*)node);
5528 ok(type == 9, "type=%d, expected 9\n", type);
5529 node2 = test_node_get_parent((IUnknown*)node);
5530 IHTMLDOMNode_Release(node);
5531 ok(node2 == NULL, "node != NULL\n");
5534 elem2 = test_elem_get_parent((IUnknown*)elem);
5535 ok(elem2 != NULL, "elem2 == NULL\n");
5536 test_node_name((IUnknown*)elem2, "BODY");
5537 elem3 = test_elem_get_parent((IUnknown*)elem2);
5538 IHTMLElement_Release(elem2);
5539 ok(elem3 != NULL, "elem3 == NULL\n");
5540 test_node_name((IUnknown*)elem3, "HTML");
5541 elem2 = test_elem_get_parent((IUnknown*)elem3);
5542 IHTMLElement_Release(elem3);
5543 ok(elem2 == NULL, "elem2 != NULL\n");
5545 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5546 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5547 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5549 test_elem_innertext(elem, "opt1opt2");
5551 IHTMLElement_Release(elem);
5554 elem = get_elem_by_id(doc, "s", TRUE);
5555 if(elem) {
5556 IHTMLSelectElement *select;
5557 IHTMLDocument2 *doc_node, *elem_doc;
5559 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5560 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5562 test_select_elem(select);
5564 test_elem_title((IUnknown*)select, NULL);
5565 test_elem_set_title((IUnknown*)select, "Title");
5566 test_elem_title((IUnknown*)select, "Title");
5567 test_elem_offset((IUnknown*)select);
5569 node = get_first_child((IUnknown*)select);
5570 ok(node != NULL, "node == NULL\n");
5571 if(node) {
5572 test_elem_type((IUnknown*)node, ET_OPTION);
5573 IHTMLDOMNode_Release(node);
5576 type = get_node_type((IUnknown*)select);
5577 ok(type == 1, "type=%d\n", type);
5579 IHTMLSelectElement_Release(select);
5581 elem_doc = get_elem_doc((IUnknown*)elem);
5583 doc_node = get_doc_node(doc);
5584 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5585 IHTMLDocument2_Release(doc_node);
5586 IHTMLDocument2_Release(elem_doc);
5588 IHTMLElement_Release(elem);
5591 elem = get_elem_by_id(doc, "sc", TRUE);
5592 if(elem) {
5593 IHTMLScriptElement *script;
5594 BSTR type;
5596 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5597 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5599 if(hres == S_OK)
5601 VARIANT_BOOL vb;
5603 hres = IHTMLScriptElement_put_type (script, NULL);
5604 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5605 hres = IHTMLScriptElement_get_type(script, &type);
5606 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5607 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
5609 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
5610 ok(hres == S_OK, "put_type failed: %08x\n", hres);
5611 hres = IHTMLScriptElement_get_type(script, &type);
5612 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5613 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5615 SysFreeString(type);
5617 /* test defer */
5618 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5619 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5621 hres = IHTMLScriptElement_get_defer(script, &vb);
5622 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5623 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5625 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5626 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5629 IHTMLScriptElement_Release(script);
5632 elem = get_elem_by_id(doc, "in", TRUE);
5633 if(elem) {
5634 IHTMLInputElement *input;
5636 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5637 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5639 test_elem_id((IUnknown*)elem, "in");
5640 test_elem_put_id((IUnknown*)elem, "newin");
5641 test_input_get_disabled(input, VARIANT_FALSE);
5642 test_input_set_disabled(input, VARIANT_TRUE);
5643 test_input_set_disabled(input, VARIANT_FALSE);
5644 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5645 test_input_get_disabled(input, VARIANT_TRUE);
5646 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5647 test_input_get_disabled(input, VARIANT_FALSE);
5648 test_elem_client_size((IUnknown*)elem);
5650 test_node_get_value_str((IUnknown*)elem, NULL);
5651 test_node_put_value_str((IUnknown*)elem, "test");
5652 test_node_get_value_str((IUnknown*)elem, NULL);
5653 test_input_value((IUnknown*)elem, NULL);
5654 test_input_put_value((IUnknown*)elem, "test");
5655 test_input_value((IUnknown*)elem, NULL);
5656 test_elem_class((IUnknown*)elem, "testclass");
5657 test_elem_tabindex((IUnknown*)elem, 2);
5658 test_elem_set_tabindex((IUnknown*)elem, 3);
5659 test_elem_title((IUnknown*)elem, "test title");
5661 test_input_get_defaultchecked(input, VARIANT_FALSE);
5662 test_input_set_defaultchecked(input, VARIANT_TRUE);
5663 test_input_set_defaultchecked(input, VARIANT_FALSE);
5665 test_input_get_checked(input, VARIANT_FALSE);
5666 test_input_set_checked(input, VARIANT_TRUE);
5667 test_input_set_checked(input, VARIANT_FALSE);
5669 test_input_src(input, NULL);
5670 test_input_set_src(input, "about:blank");
5672 IHTMLInputElement_Release(input);
5673 IHTMLElement_Release(elem);
5676 elem = get_elem_by_id(doc, "imgid", TRUE);
5677 if(elem) {
5678 test_img_src((IUnknown*)elem, "");
5679 test_img_set_src((IUnknown*)elem, "about:blank");
5680 test_img_alt((IUnknown*)elem, NULL);
5681 test_img_set_alt((IUnknown*)elem, "alt test");
5682 test_img_name((IUnknown*)elem, "WineImg");
5683 IHTMLElement_Release(elem);
5686 elem = get_doc_elem_by_id(doc, "tbl");
5687 ok(elem != NULL, "elem == NULL\n");
5688 if(elem) {
5689 test_table_elem(elem);
5690 IHTMLElement_Release(elem);
5693 elem = get_doc_elem_by_id(doc, "row2");
5694 ok(elem != NULL, "elem == NULL\n");
5695 if(elem) {
5696 test_tr_elem(elem);
5697 IHTMLElement_Release(elem);
5700 elem = get_doc_elem_by_id(doc, "ifr");
5701 ok(elem != NULL, "elem == NULL\n");
5702 if(elem) {
5703 test_iframe_elem(elem);
5704 IHTMLElement_Release(elem);
5707 elem = get_elem_by_id(doc, "a", TRUE);
5708 if(elem) {
5709 test_anchor_href((IUnknown*)elem, "http://test/");
5710 IHTMLElement_Release(elem);
5713 hres = IHTMLDocument2_get_body(doc, &elem);
5714 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5716 node = get_first_child((IUnknown*)elem);
5717 ok(node != NULL, "node == NULL\n");
5718 if(node) {
5719 test_ifaces((IUnknown*)node, text_iids);
5720 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5722 node2 = get_first_child((IUnknown*)node);
5723 ok(!node2, "node2 != NULL\n");
5725 type = get_node_type((IUnknown*)node);
5726 ok(type == 3, "type=%d\n", type);
5728 test_node_get_value_str((IUnknown*)node, "text test");
5729 test_node_put_value_str((IUnknown*)elem, "test text");
5730 test_node_get_value_str((IUnknown*)node, "text test");
5732 IHTMLDOMNode_Release(node);
5735 child_col = get_child_nodes((IUnknown*)elem);
5736 ok(child_col != NULL, "child_coll == NULL\n");
5737 if(child_col) {
5738 LONG length = 0;
5740 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5742 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5743 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5744 ok(length, "length=0\n");
5746 node2 = NULL;
5747 node = get_child_item(child_col, 0);
5748 ok(node != NULL, "node == NULL\n");
5749 if(node) {
5750 type = get_node_type((IUnknown*)node);
5751 ok(type == 3, "type=%d\n", type);
5752 node2 = node_get_next((IUnknown*)node);
5753 IHTMLDOMNode_Release(node);
5756 node = get_child_item(child_col, 1);
5757 ok(node != NULL, "node == NULL\n");
5758 if(node) {
5759 type = get_node_type((IUnknown*)node);
5760 ok(type == 8, "type=%d\n", type);
5762 test_elem_id((IUnknown*)node, NULL);
5763 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5764 IHTMLDOMNode_Release(node2);
5765 IHTMLDOMNode_Release(node);
5768 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5769 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5771 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5772 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5774 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5775 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5777 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5778 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5780 test_child_col_disp(child_col);
5782 IHTMLDOMChildrenCollection_Release(child_col);
5785 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5786 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5787 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5789 IHTMLElement_Release(elem);
5791 test_stylesheets(doc);
5792 test_create_option_elem(doc);
5793 test_create_img_elem(doc);
5795 elem = get_doc_elem_by_id(doc, "tbl");
5796 ok(elem != NULL, "elem = NULL\n");
5797 test_elem_set_innertext(elem, "inner text");
5798 IHTMLElement_Release(elem);
5800 test_doc_title(doc, "test");
5801 test_doc_set_title(doc, "test title");
5802 test_doc_title(doc, "test title");
5804 disp = NULL;
5805 hres = IHTMLDocument2_get_Script(doc, &disp);
5806 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5807 if(hres == S_OK)
5809 IDispatchEx *dispex;
5810 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5811 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5812 if(hres == S_OK)
5814 DISPID pid = -1;
5815 BSTR str = a2bstr("Testing");
5816 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5817 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5818 ok(pid != -1, "pid == -1\n");
5819 SysFreeString(str);
5820 IDispatchEx_Release(dispex);
5823 IDispatch_Release(disp);
5825 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5826 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5828 str = a2bstr("img");
5829 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5830 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5831 SysFreeString(str);
5832 if(hres == S_OK)
5834 static const elem_type_t img_types[] = { ET_IMG };
5836 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5837 IHTMLElementCollection_Release(col);
5840 elem = get_doc_elem_by_id(doc, "y");
5841 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5842 test_elem_innerhtml((IUnknown*)elem, "inner html");
5843 test_elem_set_innerhtml((IUnknown*)elem, "");
5844 test_elem_innerhtml((IUnknown*)elem, NULL);
5845 node = node_get_next((IUnknown*)elem);
5846 ok(!node, "node = %p\n", node);
5848 elem2 = get_doc_elem_by_id(doc, "x");
5849 test_elem_tag((IUnknown*)elem2, "A");
5850 node = node_get_next((IUnknown*)elem2);
5851 IHTMLDOMNode_Release(node);
5852 IHTMLElement_Release(elem2);
5853 IHTMLElement_Release(elem);
5855 IHTMLDocument3_Release(doc3);
5857 window = get_doc_window(doc);
5858 test_window_name(window, NULL);
5859 set_window_name(window, "test name");
5860 test_window_length(window, 1);
5861 IHTMLWindow2_Release(window);
5864 static void test_elems2(IHTMLDocument2 *doc)
5866 IHTMLElement *elem, *elem2;
5868 static const elem_type_t outer_types[] = {
5869 ET_BR,
5870 ET_A
5873 elem = get_doc_elem_by_id(doc, "divid");
5875 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5876 elem2 = get_doc_elem_by_id(doc, "innerid");
5877 ok(elem2 != NULL, "elem2 == NULL\n");
5878 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5879 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5880 IHTMLElement_Release(elem2);
5882 elem2 = get_doc_elem_by_id(doc, "aid");
5883 ok(elem2 != NULL, "elem2 == NULL\n");
5884 test_elem_set_outerhtml((IUnknown*)elem2, "");
5885 test_elem_all((IUnknown*)elem, outer_types, 1);
5886 IHTMLElement_Release(elem2);
5888 IHTMLElement_Release(elem);
5891 static void test_create_elems(IHTMLDocument2 *doc)
5893 IHTMLElement *elem, *body, *elem2;
5894 IHTMLDOMNode *node, *node2, *node3, *comment;
5895 IHTMLDocument5 *doc5;
5896 IDispatch *disp;
5897 VARIANT var;
5898 LONG type;
5899 HRESULT hres;
5900 BSTR str;
5902 static const elem_type_t types1[] = { ET_TESTG };
5904 elem = test_create_elem(doc, "TEST");
5905 test_elem_tag((IUnknown*)elem, "TEST");
5906 type = get_node_type((IUnknown*)elem);
5907 ok(type == 1, "type=%d\n", type);
5908 test_ifaces((IUnknown*)elem, elem_iids);
5909 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5911 hres = IHTMLDocument2_get_body(doc, &body);
5912 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5913 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5915 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5916 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5917 elem2 = get_elem_iface((IUnknown*)node);
5918 IHTMLElement_Release(elem2);
5920 hres = IHTMLElement_get_all(body, &disp);
5921 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5922 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5923 IDispatch_Release(disp);
5925 test_node_remove_child((IUnknown*)body, node);
5927 hres = IHTMLElement_get_all(body, &disp);
5928 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5929 test_elem_collection((IUnknown*)disp, NULL, 0);
5930 IDispatch_Release(disp);
5931 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5933 IHTMLElement_Release(elem);
5934 IHTMLDOMNode_Release(node);
5936 node = test_create_text(doc, "test");
5937 test_ifaces((IUnknown*)node, text_iids);
5938 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5939 test_text_length((IUnknown*)node, 4);
5941 V_VT(&var) = VT_NULL;
5942 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5943 IHTMLDOMNode_Release(node);
5945 node = test_create_text(doc, "insert ");
5947 V_VT(&var) = VT_DISPATCH;
5948 V_DISPATCH(&var) = (IDispatch*)node2;
5949 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5950 IHTMLDOMNode_Release(node);
5951 IHTMLDOMNode_Release(node2);
5952 IHTMLDOMNode_Release(node3);
5954 test_elem_innertext(body, "insert test");
5955 test_elem_innerhtml((IUnknown*)body, "insert test");
5957 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5958 if(hres == S_OK)
5960 str = a2bstr("testing");
5961 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5962 SysFreeString(str);
5963 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5964 if(hres == S_OK)
5966 type = get_node_type((IUnknown*)comment);
5967 ok(type == 8, "type=%d, expected 8\n", type);
5969 test_node_get_value_str((IUnknown*)comment, "testing");
5970 test_elem_title((IUnknown*)comment, NULL);
5971 test_elem_set_title((IUnknown*)comment, "comment title");
5972 test_elem_title((IUnknown*)comment, "comment title");
5973 test_comment_text((IUnknown*)comment, "<!--testing-->");
5974 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
5976 IHTMLDOMNode_Release(comment);
5979 IHTMLDocument5_Release(doc5);
5982 IHTMLElement_Release(body);
5985 static void test_null_write(IHTMLDocument2 *doc)
5987 HRESULT hres;
5989 doc_write(doc, FALSE, NULL);
5990 doc_write(doc, TRUE, NULL);
5992 hres = IHTMLDocument2_write(doc, NULL);
5993 ok(hres == S_OK,
5994 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
5996 hres = IHTMLDocument2_writeln(doc, NULL);
5997 ok(hres == S_OK,
5998 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6001 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6003 IOleCommandTarget *cmdtrg;
6004 HRESULT hres;
6006 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6007 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6009 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6010 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6012 IOleCommandTarget_Release(cmdtrg);
6015 static void test_indent(IHTMLDocument2 *doc)
6017 IHTMLElementCollection *col;
6018 IHTMLTxtRange *range;
6019 HRESULT hres;
6021 static const elem_type_t all_types[] = {
6022 ET_HTML,
6023 ET_HEAD,
6024 ET_TITLE,
6025 ET_BODY,
6026 ET_BR,
6027 ET_A,
6030 static const elem_type_t indent_types[] = {
6031 ET_HTML,
6032 ET_HEAD,
6033 ET_TITLE,
6034 ET_BODY,
6035 ET_BLOCKQUOTE,
6036 ET_P,
6037 ET_BR,
6038 ET_A,
6041 hres = IHTMLDocument2_get_all(doc, &col);
6042 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6043 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6044 IHTMLElementCollection_Release(col);
6046 range = test_create_body_range(doc);
6047 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6048 IHTMLTxtRange_Release(range);
6050 hres = IHTMLDocument2_get_all(doc, &col);
6051 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6052 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6053 IHTMLElementCollection_Release(col);
6056 static void test_cond_comment(IHTMLDocument2 *doc)
6058 IHTMLElementCollection *col;
6059 HRESULT hres;
6061 static const elem_type_t all_types[] = {
6062 ET_HTML,
6063 ET_HEAD,
6064 ET_TITLE,
6065 ET_BODY,
6066 ET_BR
6069 hres = IHTMLDocument2_get_all(doc, &col);
6070 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6071 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6072 IHTMLElementCollection_Release(col);
6075 static void test_frame(IDispatch *disp, const char *exp_id)
6077 IHTMLWindow2 *frame2, *parent, *top;
6078 IHTMLDocument2 *parent_doc, *top_doc;
6079 IHTMLWindow4 *frame;
6080 IHTMLFrameBase *frame_elem;
6081 HRESULT hres;
6083 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6084 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6085 if(FAILED(hres))
6086 return;
6088 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6089 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6090 IHTMLWindow4_Release(frame);
6091 if(FAILED(hres))
6092 return;
6094 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6095 test_frame_doc((IUnknown*)frame_elem, FALSE);
6096 test_elem_id((IUnknown*)frame_elem, exp_id);
6097 IHTMLElement_Release(frame_elem);
6099 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6100 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6101 if(FAILED(hres))
6102 return;
6104 hres = IHTMLWindow2_get_parent(frame2, &parent);
6105 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6106 if(FAILED(hres)){
6107 IHTMLWindow2_Release(frame2);
6108 return;
6111 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6112 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6113 IHTMLWindow2_Release(parent);
6114 if(FAILED(hres)){
6115 IHTMLWindow2_Release(frame2);
6116 return;
6119 test_doc_title(parent_doc, "frameset test");
6120 IHTMLDocument2_Release(parent_doc);
6122 /* test get_top */
6123 hres = IHTMLWindow2_get_top(frame2, &top);
6124 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6125 IHTMLWindow2_Release(frame2);
6126 if(FAILED(hres))
6127 return;
6129 hres = IHTMLWindow2_get_document(top, &top_doc);
6130 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6131 IHTMLWindow2_Release(top);
6132 if(FAILED(hres))
6133 return;
6135 test_doc_title(top_doc, "frameset test");
6136 IHTMLDocument2_Release(top_doc);
6139 static void test_frameset(IHTMLDocument2 *doc)
6141 IHTMLWindow2 *window;
6142 IHTMLFramesCollection2 *frames;
6143 IHTMLElement *elem;
6144 IHTMLFrameBase *fbase;
6145 LONG length;
6146 VARIANT index_var, result_var;
6147 BSTR str;
6148 HRESULT hres;
6150 window = get_doc_window(doc);
6152 /* test using IHTMLFramesCollection object */
6154 hres = IHTMLWindow2_get_frames(window, &frames);
6155 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6156 IHTMLWindow2_Release(window);
6157 if(FAILED(hres))
6158 return;
6160 /* test result length */
6161 hres = IHTMLFramesCollection2_get_length(frames, &length);
6162 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6163 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6165 /* test first frame */
6166 V_VT(&index_var) = VT_I4;
6167 V_I4(&index_var) = 0;
6168 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6169 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6170 if(SUCCEEDED(hres)) {
6171 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6172 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6174 VariantClear(&result_var);
6176 /* test second frame */
6177 V_I4(&index_var) = 1;
6178 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6179 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6180 if(SUCCEEDED(hres)) {
6181 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6182 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6184 VariantClear(&result_var);
6186 /* fail on next frame */
6187 V_I4(&index_var) = 3;
6188 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6189 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6190 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6191 VariantClear(&result_var);
6193 /* string argument (element id lookup) */
6194 V_VT(&index_var) = VT_BSTR;
6195 V_BSTR(&index_var) = a2bstr("fr1");
6196 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6197 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6198 if(SUCCEEDED(hres)) {
6199 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6200 test_frame(V_DISPATCH(&result_var), "fr1");
6202 VariantClear(&result_var);
6203 VariantClear(&index_var);
6205 /* invalid argument */
6206 V_VT(&index_var) = VT_BOOL;
6207 V_BOOL(&index_var) = VARIANT_TRUE;
6208 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6209 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6210 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6211 VariantClear(&result_var);
6213 IHTMLFramesCollection2_Release(frames);
6215 /* test using IHTMLWindow2 inheritance */
6217 /* test result length */
6218 hres = IHTMLWindow2_get_length(window, &length);
6219 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6220 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6222 /* test first frame */
6223 V_VT(&index_var) = VT_I4;
6224 V_I4(&index_var) = 0;
6225 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6226 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6227 if(SUCCEEDED(hres)) {
6228 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6229 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6231 VariantClear(&result_var);
6233 /* test second frame */
6234 V_I4(&index_var) = 1;
6235 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6236 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6237 if(SUCCEEDED(hres)) {
6238 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6239 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6241 VariantClear(&result_var);
6243 /* fail on next frame */
6244 V_I4(&index_var) = 3;
6245 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6246 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6247 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6248 VariantClear(&result_var);
6250 /* string argument (element id lookup) */
6251 V_VT(&index_var) = VT_BSTR;
6252 V_BSTR(&index_var) = a2bstr("fr2");
6253 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6254 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6255 if(SUCCEEDED(hres)) {
6256 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6257 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6259 VariantClear(&result_var);
6260 VariantClear(&index_var);
6262 /* invalid argument */
6263 V_VT(&index_var) = VT_BOOL;
6264 V_BOOL(&index_var) = VARIANT_TRUE;
6265 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6266 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6267 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6268 VariantClear(&result_var);
6270 /* getElementById with node name attributes */
6271 elem = get_doc_elem_by_id(doc, "nm1");
6272 test_elem_id((IUnknown*)elem, "fr1");
6274 /* get/put scrolling */
6275 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6276 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6278 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6279 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6280 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6281 SysFreeString(str);
6283 str = a2bstr("no");
6284 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6285 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6286 SysFreeString(str);
6288 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6289 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6290 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6291 SysFreeString(str);
6293 str = a2bstr("junk");
6294 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6295 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6296 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6297 SysFreeString(str);
6299 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6300 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6301 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6302 SysFreeString(str);
6304 /* get_name */
6305 hres = IHTMLFrameBase_get_name(fbase, &str);
6306 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6307 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6308 SysFreeString(str);
6310 IHTMLFrameBase_Release(fbase);
6311 IHTMLElement_Release(elem);
6313 /* get_name with no name attr */
6314 elem = get_doc_elem_by_id(doc, "fr3");
6315 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6316 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6318 hres = IHTMLFrameBase_get_name(fbase, &str);
6319 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6320 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6321 SysFreeString(str);
6323 IHTMLFrameBase_Release(fbase);
6324 IHTMLElement_Release(elem);
6327 static IHTMLDocument2 *notif_doc;
6328 static BOOL doc_complete;
6330 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6331 REFIID riid, void**ppv)
6333 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6334 *ppv = iface;
6335 return S_OK;
6338 ok(0, "unexpected call\n");
6339 return E_NOINTERFACE;
6342 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6344 return 2;
6347 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6349 return 1;
6352 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6354 if(dispID == DISPID_READYSTATE){
6355 BSTR state;
6356 HRESULT hres;
6358 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6359 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6361 if(!strcmp_wa(state, "complete"))
6362 doc_complete = TRUE;
6364 SysFreeString(state);
6367 return S_OK;
6370 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6372 ok(0, "unexpected call\n");
6373 return E_NOTIMPL;
6376 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6377 PropertyNotifySink_QueryInterface,
6378 PropertyNotifySink_AddRef,
6379 PropertyNotifySink_Release,
6380 PropertyNotifySink_OnChanged,
6381 PropertyNotifySink_OnRequestEdit
6384 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6386 static IHTMLDocument2 *create_doc_with_string(const char *str)
6388 IPersistStreamInit *init;
6389 IStream *stream;
6390 IHTMLDocument2 *doc;
6391 HGLOBAL mem;
6392 SIZE_T len;
6394 notif_doc = doc = create_document();
6395 if(!doc)
6396 return NULL;
6398 doc_complete = FALSE;
6399 len = strlen(str);
6400 mem = GlobalAlloc(0, len);
6401 memcpy(mem, str, len);
6402 CreateStreamOnHGlobal(mem, TRUE, &stream);
6404 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6406 IPersistStreamInit_Load(init, stream);
6407 IPersistStreamInit_Release(init);
6408 IStream_Release(stream);
6410 return doc;
6413 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6415 IConnectionPointContainer *container;
6416 IConnectionPoint *cp;
6417 DWORD cookie;
6418 HRESULT hres;
6420 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6421 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6423 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6424 IConnectionPointContainer_Release(container);
6425 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6427 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6428 IConnectionPoint_Release(cp);
6429 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6432 typedef void (*domtest_t)(IHTMLDocument2*);
6434 static void run_domtest(const char *str, domtest_t test)
6436 IHTMLDocument2 *doc;
6437 ULONG ref;
6438 MSG msg;
6440 doc = create_doc_with_string(str);
6441 if(!doc)
6442 return;
6444 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6446 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6447 TranslateMessage(&msg);
6448 DispatchMessage(&msg);
6451 test(doc);
6453 ref = IHTMLDocument2_Release(doc);
6454 ok(!ref ||
6455 ref == 1, /* Vista */
6456 "ref = %d\n", ref);
6459 START_TEST(dom)
6461 CoInitialize(NULL);
6463 run_domtest(doc_str1, test_doc_elem);
6464 run_domtest(doc_str1, test_get_set_attr);
6465 run_domtest(range_test_str, test_txtrange);
6466 run_domtest(range_test2_str, test_txtrange2);
6467 if (winetest_interactive || ! is_ie_hardened()) {
6468 run_domtest(elem_test_str, test_elems);
6469 }else {
6470 skip("IE running in Enhanced Security Configuration\n");
6472 run_domtest(elem_test2_str, test_elems2);
6473 run_domtest(doc_blank, test_create_elems);
6474 run_domtest(doc_blank, test_defaults);
6475 run_domtest(doc_blank, test_null_write);
6476 run_domtest(indent_test_str, test_indent);
6477 run_domtest(cond_comment_str, test_cond_comment);
6478 run_domtest(frameset_str, test_frameset);
6480 CoUninitialize();