c13c0a8c6067b3a2eb7e14d8d288a9da74771a39
[reactos.git] / rostests / winetests / mshtml / dom.c
1 /*
2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #define COBJMACROS
20 #define CONST_VTABLE
21
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "mshtml.h"
30 #include "mshtmcid.h"
31 #include "mshtmhst.h"
32 #include "docobj.h"
33 #include "dispex.h"
34 #include "mshtml_test.h"
35
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test />"
52 "<img id=\"imgid\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "</body></html>";
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
60 "</body></html>";
61
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
65
66 typedef enum {
67 ET_NONE,
68 ET_HTML,
69 ET_HEAD,
70 ET_TITLE,
71 ET_BODY,
72 ET_A,
73 ET_INPUT,
74 ET_SELECT,
75 ET_TEXTAREA,
76 ET_OPTION,
77 ET_STYLE,
78 ET_BLOCKQUOTE,
79 ET_P,
80 ET_BR,
81 ET_TABLE,
82 ET_TBODY,
83 ET_SCRIPT,
84 ET_TEST,
85 ET_TESTG,
86 ET_COMMENT,
87 ET_IMG,
88 ET_TR,
89 ET_TD,
90 ET_IFRAME
91 } elem_type_t;
92
93 static const IID * const none_iids[] = {
94 &IID_IUnknown,
95 NULL
96 };
97
98 static const IID * const doc_node_iids[] = {
99 &IID_IHTMLDOMNode,
100 &IID_IHTMLDOMNode2,
101 &IID_IHTMLDocument,
102 &IID_IHTMLDocument2,
103 &IID_IHTMLDocument3,
104 &IID_IHTMLDocument4,
105 &IID_IHTMLDocument5,
106 &IID_IDispatchEx,
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
109 NULL
110 };
111
112 static const IID * const doc_obj_iids[] = {
113 &IID_IHTMLDocument,
114 &IID_IHTMLDocument2,
115 &IID_IHTMLDocument3,
116 &IID_IHTMLDocument4,
117 &IID_IHTMLDocument5,
118 &IID_IDispatchEx,
119 &IID_IConnectionPointContainer,
120 &IID_ICustomDoc,
121 NULL
122 };
123
124 static const IID * const elem_iids[] = {
125 &IID_IHTMLDOMNode,
126 &IID_IHTMLDOMNode2,
127 &IID_IHTMLElement,
128 &IID_IHTMLElement2,
129 &IID_IHTMLElement3,
130 &IID_IDispatchEx,
131 &IID_IConnectionPointContainer,
132 NULL
133 };
134
135 static const IID * const body_iids[] = {
136 &IID_IHTMLDOMNode,
137 &IID_IHTMLDOMNode2,
138 &IID_IHTMLElement,
139 &IID_IHTMLElement2,
140 &IID_IHTMLElement3,
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
143 &IID_IDispatchEx,
144 &IID_IConnectionPointContainer,
145 NULL
146 };
147
148 static const IID * const anchor_iids[] = {
149 &IID_IHTMLDOMNode,
150 &IID_IHTMLDOMNode2,
151 &IID_IHTMLElement,
152 &IID_IHTMLElement2,
153 &IID_IHTMLElement3,
154 &IID_IHTMLAnchorElement,
155 &IID_IDispatchEx,
156 &IID_IConnectionPointContainer,
157 NULL
158 };
159
160 static const IID * const input_iids[] = {
161 &IID_IHTMLDOMNode,
162 &IID_IHTMLDOMNode2,
163 &IID_IHTMLElement,
164 &IID_IHTMLElement2,
165 &IID_IHTMLElement3,
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
168 &IID_IDispatchEx,
169 &IID_IConnectionPointContainer,
170 NULL
171 };
172
173 static const IID * const select_iids[] = {
174 &IID_IHTMLDOMNode,
175 &IID_IHTMLDOMNode2,
176 &IID_IHTMLElement,
177 &IID_IHTMLElement2,
178 &IID_IHTMLElement3,
179 &IID_IHTMLSelectElement,
180 &IID_IDispatchEx,
181 &IID_IConnectionPointContainer,
182 NULL
183 };
184
185 static const IID * const textarea_iids[] = {
186 &IID_IHTMLDOMNode,
187 &IID_IHTMLDOMNode2,
188 &IID_IHTMLElement,
189 &IID_IHTMLElement2,
190 &IID_IHTMLElement3,
191 &IID_IHTMLTextAreaElement,
192 &IID_IDispatchEx,
193 &IID_IConnectionPointContainer,
194 NULL
195 };
196
197 static const IID * const option_iids[] = {
198 &IID_IHTMLDOMNode,
199 &IID_IHTMLDOMNode2,
200 &IID_IHTMLElement,
201 &IID_IHTMLElement2,
202 &IID_IHTMLElement3,
203 &IID_IHTMLOptionElement,
204 &IID_IDispatchEx,
205 &IID_IConnectionPointContainer,
206 NULL
207 };
208
209 static const IID * const table_iids[] = {
210 &IID_IHTMLDOMNode,
211 &IID_IHTMLDOMNode2,
212 &IID_IHTMLElement,
213 &IID_IHTMLElement2,
214 &IID_IHTMLElement3,
215 &IID_IHTMLTable,
216 &IID_IDispatchEx,
217 &IID_IConnectionPointContainer,
218 NULL
219 };
220
221 static const IID * const script_iids[] = {
222 &IID_IHTMLDOMNode,
223 &IID_IHTMLDOMNode2,
224 &IID_IHTMLElement,
225 &IID_IHTMLElement2,
226 &IID_IHTMLElement3,
227 &IID_IHTMLScriptElement,
228 &IID_IDispatchEx,
229 &IID_IConnectionPointContainer,
230 NULL
231 };
232
233 static const IID * const text_iids[] = {
234 &IID_IHTMLDOMNode,
235 &IID_IHTMLDOMNode2,
236 &IID_IHTMLDOMTextNode,
237 NULL
238 };
239
240 static const IID * const location_iids[] = {
241 &IID_IDispatch,
242 &IID_IHTMLLocation,
243 NULL
244 };
245
246 static const IID * const window_iids[] = {
247 &IID_IDispatch,
248 &IID_IHTMLWindow2,
249 &IID_IHTMLWindow3,
250 &IID_IDispatchEx,
251 NULL
252 };
253
254 static const IID * const comment_iids[] = {
255 &IID_IHTMLDOMNode,
256 &IID_IHTMLDOMNode2,
257 &IID_IHTMLElement,
258 &IID_IHTMLElement2,
259 &IID_IHTMLElement3,
260 &IID_IHTMLCommentElement,
261 &IID_IDispatchEx,
262 &IID_IConnectionPointContainer,
263 NULL
264 };
265
266 static const IID * const img_iids[] = {
267 &IID_IHTMLDOMNode,
268 &IID_IHTMLDOMNode2,
269 &IID_IHTMLElement,
270 &IID_IHTMLElement2,
271 &IID_IHTMLElement3,
272 &IID_IDispatchEx,
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
275 NULL
276 };
277
278 static const IID * const tr_iids[] = {
279 &IID_IHTMLDOMNode,
280 &IID_IHTMLDOMNode2,
281 &IID_IHTMLElement,
282 &IID_IHTMLElement2,
283 &IID_IHTMLElement3,
284 &IID_IDispatchEx,
285 &IID_IHTMLTableRow,
286 &IID_IConnectionPointContainer,
287 NULL
288 };
289
290 static const IID * const td_iids[] = {
291 &IID_IHTMLDOMNode,
292 &IID_IHTMLDOMNode2,
293 &IID_IHTMLElement,
294 &IID_IHTMLElement2,
295 &IID_IHTMLElement3,
296 &IID_IDispatchEx,
297 &IID_IConnectionPointContainer,
298 NULL
299 };
300
301 static const IID * const iframe_iids[] = {
302 &IID_IHTMLDOMNode,
303 &IID_IHTMLDOMNode2,
304 &IID_IHTMLElement,
305 &IID_IHTMLElement2,
306 &IID_IHTMLElement3,
307 &IID_IHTMLFrameBase2,
308 &IID_IDispatchEx,
309 &IID_IConnectionPointContainer,
310 NULL
311 };
312
313 static const IID * const generic_iids[] = {
314 &IID_IHTMLDOMNode,
315 &IID_IHTMLDOMNode2,
316 &IID_IHTMLElement,
317 &IID_IHTMLElement2,
318 &IID_IHTMLElement3,
319 &IID_IHTMLGenericElement,
320 &IID_IDispatchEx,
321 &IID_IConnectionPointContainer,
322 NULL
323 };
324
325 static const IID * const style_iids[] = {
326 &IID_IUnknown,
327 &IID_IDispatch,
328 &IID_IDispatchEx,
329 &IID_IHTMLStyle,
330 &IID_IHTMLStyle2,
331 &IID_IHTMLStyle3,
332 &IID_IHTMLStyle4,
333 NULL
334 };
335
336 static const IID * const cstyle_iids[] = {
337 &IID_IUnknown,
338 &IID_IDispatch,
339 &IID_IDispatchEx,
340 &IID_IHTMLCurrentStyle,
341 NULL
342 };
343
344 typedef struct {
345 const char *tag;
346 REFIID *iids;
347 const IID *dispiid;
348 } elem_type_info_t;
349
350 static const elem_type_info_t elem_type_infos[] = {
351 {"", none_iids, NULL},
352 {"HTML", elem_iids, NULL},
353 {"HEAD", elem_iids, NULL},
354 {"TITLE", elem_iids, NULL},
355 {"BODY", body_iids, &DIID_DispHTMLBody},
356 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
357 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
358 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
359 {"TEXTAREA", textarea_iids, NULL},
360 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
361 {"STYLE", elem_iids, NULL},
362 {"BLOCKQUOTE",elem_iids, NULL},
363 {"P", elem_iids, NULL},
364 {"BR", elem_iids, NULL},
365 {"TABLE", table_iids, &DIID_DispHTMLTable},
366 {"TBODY", elem_iids, NULL},
367 {"SCRIPT", script_iids, NULL},
368 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
369 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
370 {"!", comment_iids, &DIID_DispHTMLCommentElement},
371 {"IMG", img_iids, &DIID_DispHTMLImg},
372 {"TR", tr_iids, &DIID_DispHTMLTableRow},
373 {"TD", td_iids, NULL},
374 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
375 };
376
377 static const char *dbgstr_guid(REFIID riid)
378 {
379 static char buf[50];
380
381 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
382 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
383 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
384 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
385
386 return buf;
387 }
388
389 static int strcmp_wa(LPCWSTR strw, const char *stra)
390 {
391 CHAR buf[512];
392 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
393 return lstrcmpA(stra, buf);
394 }
395
396 static BSTR a2bstr(const char *str)
397 {
398 BSTR ret;
399 int len;
400
401 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
402 ret = SysAllocStringLen(NULL, len);
403 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
404
405 return ret;
406 }
407
408 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
409 {
410 IUnknown *unk1, *unk2;
411
412 if(iface1 == iface2)
413 return TRUE;
414
415 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
416 IUnknown_Release(unk1);
417 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
418 IUnknown_Release(unk2);
419
420 return unk1 == unk2;
421 }
422
423 static IHTMLDocument2 *create_document(void)
424 {
425 IHTMLDocument2 *doc;
426 IHTMLDocument5 *doc5;
427 HRESULT hres;
428
429 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
430 &IID_IHTMLDocument2, (void**)&doc);
431 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
432
433 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
434 if(FAILED(hres)) {
435 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
436 IHTMLDocument2_Release(doc);
437 return NULL;
438 }
439
440 IHTMLDocument5_Release(doc5);
441 return doc;
442 }
443
444 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
445 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
446 {
447 const IID * const *piid;
448 IUnknown *unk;
449 HRESULT hres;
450
451 for(piid = iids; *piid; piid++) {
452 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
453 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
454 if(SUCCEEDED(hres))
455 IUnknown_Release(unk);
456 }
457 }
458
459 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
460 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
461 {
462 IDispatchEx *dispex;
463 ITypeInfo *typeinfo;
464 BOOL ret = FALSE;
465 UINT ticnt;
466 HRESULT hres;
467
468 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
469 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
470 if(FAILED(hres))
471 return FALSE;
472
473 ticnt = 0xdeadbeef;
474 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
475 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
476 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
477
478 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
479 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
480
481 if(SUCCEEDED(hres)) {
482 TYPEATTR *type_attr;
483
484 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
485 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
486 if(hres == S_OK) {
487 *iid = type_attr->guid;
488 ret = TRUE;
489 }
490
491 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
492 ITypeInfo_Release(typeinfo);
493 }
494
495 IDispatchEx_Release(dispex);
496 return ret;
497 }
498
499 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
500 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
501 {
502 DISPPARAMS dp = {NULL,NULL,0,0};
503 IDispatchEx *dispex;
504 EXCEPINFO ei;
505 VARIANT var;
506 HRESULT hres;
507
508 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
509 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
510 if(FAILED(hres))
511 return;
512
513 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
514 IDispatchEx_Release(dispex);
515 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
516
517 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
518 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
519 VariantClear(&var);
520 }
521
522 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
523 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
524 {
525 IID iid;
526
527 if(_test_get_dispid(line, unk, &iid))
528 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
529
530 if(val)
531 _test_disp_value(line, unk, val);
532 }
533
534 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
535 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
536 {
537 IID iid;
538
539 if(_test_get_dispid(line, unk, &iid))
540 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
541 "unexpected guid %s\n", dbgstr_guid(&iid));
542
543 if(val)
544 _test_disp_value(line, unk, val);
545 }
546
547 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
548 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
549 {
550 IHTMLElement *elem;
551 HRESULT hres;
552
553 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
554 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
555 return elem;
556 }
557
558 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
559 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
560 {
561 IHTMLElement2 *elem;
562 HRESULT hres;
563
564 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
565 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
566 return elem;
567 }
568
569 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
570 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
571 {
572 IHTMLElement3 *elem;
573 HRESULT hres;
574
575 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
576 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
577 return elem;
578 }
579
580 #define get_node_iface(u) _get_node_iface(__LINE__,u)
581 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
582 {
583 IHTMLDOMNode *node;
584 HRESULT hres;
585
586 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
587 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
588 return node;
589 }
590
591 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
592 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
593 {
594 IHTMLDOMNode2 *node;
595 HRESULT hres;
596
597 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
598 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
599 return node;
600 }
601
602 #define get_img_iface(u) _get_img_iface(__LINE__,u)
603 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
604 {
605 IHTMLImgElement *img;
606 HRESULT hres;
607
608 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
609 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
610 return img;
611 }
612
613 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
614 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
615 {
616 IHTMLAnchorElement *anchor;
617 HRESULT hres;
618
619 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
620 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
621 return anchor;
622 }
623
624 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
625 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
626 {
627 IHTMLDOMNode *node = _get_node_iface(line, unk);
628 BSTR name;
629 HRESULT hres;
630
631 hres = IHTMLDOMNode_get_nodeName(node, &name);
632 IHTMLDOMNode_Release(node);
633 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
634 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
635
636 SysFreeString(name);
637 }
638
639 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
640 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
641 {
642 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
643 IDispatch *disp = (void*)0xdeadbeef;
644 IHTMLDocument2 *doc;
645 HRESULT hres;
646
647 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
648 IHTMLDOMNode2_Release(node);
649 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
650 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
651
652 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
653 IDispatch_Release(disp);
654 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
655
656 return doc;
657 }
658
659 #define clone_node(n,d) _clone_node(__LINE__,n,d)
660 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
661 {
662 IHTMLDOMNode *node = _get_node_iface(line, unk);
663 IHTMLDOMNode *ret = NULL;
664 HRESULT hres;
665
666 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
667 IHTMLDOMNode_Release(node);
668 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
669 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
670
671 return ret;
672
673 }
674
675 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
676 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
677 {
678 IHTMLElement *elem = _get_elem_iface(line, unk);
679 BSTR tag;
680 HRESULT hres;
681
682 hres = IHTMLElement_get_tagName(elem, &tag);
683 IHTMLElement_Release(elem);
684 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
685 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
686
687 SysFreeString(tag);
688 }
689
690 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
691 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
692 {
693 _test_elem_tag(line, unk, elem_type_infos[type].tag);
694 _test_ifaces(line, unk, elem_type_infos[type].iids);
695
696 if(elem_type_infos[type].dispiid && type != ET_A)
697 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
698 }
699
700 #define get_node_type(n) _get_node_type(__LINE__,n)
701 static LONG _get_node_type(unsigned line, IUnknown *unk)
702 {
703 IHTMLDOMNode *node = _get_node_iface(line, unk);
704 LONG type = -1;
705 HRESULT hres;
706
707 hres = IHTMLDOMNode_get_nodeType(node, &type);
708 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
709
710 IHTMLDOMNode_Release(node);
711
712 return type;
713 }
714
715 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
716 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
717 {
718 IHTMLDOMNode *node = _get_node_iface(line, unk);
719 IHTMLDOMChildrenCollection *col = NULL;
720 IDispatch *disp;
721 HRESULT hres;
722
723 hres = IHTMLDOMNode_get_childNodes(node, &disp);
724 IHTMLDOMNode_Release(node);
725 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
726 if(FAILED(hres))
727 return NULL;
728
729 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
730 IDispatch_Release(disp);
731 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
732
733 return col;
734 }
735
736 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
737 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
738 {
739 IHTMLDOMNode *node = NULL;
740 IDispatch *disp;
741 HRESULT hres;
742
743 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
744 ok(hres == S_OK, "item failed: %08x\n", hres);
745
746 node = _get_node_iface(line, (IUnknown*)disp);
747 IDispatch_Release(disp);
748
749 return node;
750 }
751
752 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
753 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
754 {
755 VARIANT value;
756 BSTR tmp;
757 HRESULT hres;
758
759 VariantInit(&value);
760
761 tmp = a2bstr(name);
762 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
763 SysFreeString(tmp);
764 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
765
766 if(exval) {
767 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
768 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
769 }else {
770 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
771 }
772
773 VariantClear(&value);
774 }
775
776 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
777 static void _test_elem_offset(unsigned line, IUnknown *unk)
778 {
779 IHTMLElement *elem = _get_elem_iface(line, unk);
780 LONG l;
781 HRESULT hres;
782
783 hres = IHTMLElement_get_offsetTop(elem, &l);
784 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
785
786 hres = IHTMLElement_get_offsetHeight(elem, &l);
787 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
788
789 hres = IHTMLElement_get_offsetWidth(elem, &l);
790 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
791
792 IHTMLElement_Release(elem);
793 }
794
795 #define get_doc_node(d) _get_doc_node(__LINE__,d)
796 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
797 {
798 IHTMLWindow2 *window;
799 IHTMLDocument2 *ret;
800 HRESULT hres;
801
802 hres = IHTMLDocument2_get_parentWindow(doc, &window);
803 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
804
805 hres = IHTMLWindow2_get_document(window, &ret);
806 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
807 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
808
809 return ret;
810 }
811
812 static void test_get_set_attr(IHTMLDocument2 *doc)
813 {
814 IHTMLElement *elem;
815 IHTMLDocument3 *doc3;
816 HRESULT hres;
817 BSTR bstr;
818 VARIANT val;
819
820 /* grab an element to test with */
821 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
822 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
823
824 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
825 IHTMLDocument3_Release(doc3);
826 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
827
828 /* get a non-present attribute */
829 bstr = a2bstr("notAnAttribute");
830 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
831 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
832 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
833 VariantClear(&val);
834 SysFreeString(bstr);
835
836 /* get a present attribute */
837 bstr = a2bstr("scrollHeight");
838 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
839 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
840 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
841 VariantClear(&val);
842 SysFreeString(bstr);
843
844 /* create a new BSTR attribute */
845 bstr = a2bstr("newAttribute");
846
847 V_VT(&val) = VT_BSTR;
848 V_BSTR(&val) = a2bstr("the value");
849 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
850 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
851 VariantClear(&val);
852
853 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
854 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
855 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
856 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)));
857 VariantClear(&val);
858
859 /* overwrite the attribute with a BOOL */
860 V_VT(&val) = VT_BOOL;
861 V_BOOL(&val) = VARIANT_TRUE;
862 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
863 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
864 VariantClear(&val);
865
866 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
867 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
868 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
869 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
870 VariantClear(&val);
871
872 SysFreeString(bstr);
873
874 /* case-insensitive */
875 bstr = a2bstr("newattribute");
876 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
877 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
878 todo_wine ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
879 todo_wine ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
880 VariantClear(&val);
881 SysFreeString(bstr);
882
883 IHTMLElement_Release(elem);
884 }
885
886 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
887 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
888 {
889 IHTMLElement *elem;
890 IHTMLDocument3 *doc3;
891 HRESULT hres;
892
893 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
894 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
895 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
896 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
897 IHTMLDocument3_Release(doc3);
898
899 return elem;
900 }
901
902 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
903 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
904 {
905 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
906 BSTR str;
907 HRESULT hres;
908
909 hres = IHTMLAnchorElement_get_href(anchor, &str);
910 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
911 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
912 SysFreeString(str);
913
914 _test_disp_value(line, unk, exhref);
915 }
916
917 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
918 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
919 {
920 BSTR bstr;
921 HRESULT hres;
922
923 hres = IHTMLOptionElement_get_text(option, &bstr);
924 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
925 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
926 SysFreeString(bstr);
927 }
928
929 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
930 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
931 {
932 BSTR bstr;
933 HRESULT hres;
934
935 bstr = a2bstr(text);
936 hres = IHTMLOptionElement_put_text(option, bstr);
937 SysFreeString(bstr);
938 ok(hres == S_OK, "put_text failed: %08x\n", hres);
939
940 _test_option_text(line, option, text);
941 }
942
943 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
944 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
945 {
946 BSTR bstr;
947 HRESULT hres;
948
949 hres = IHTMLOptionElement_get_value(option, &bstr);
950 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
951 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
952 SysFreeString(bstr);
953 }
954
955 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
956 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
957 {
958 BSTR bstr;
959 HRESULT hres;
960
961 bstr = a2bstr(value);
962 hres = IHTMLOptionElement_put_value(option, bstr);
963 SysFreeString(bstr);
964 ok(hres == S_OK, "put_value failed: %08x\n", hres);
965
966 _test_option_value(line, option, value);
967 }
968
969 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
970 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
971 const char *txt, const char *val)
972 {
973 IHTMLOptionElementFactory *factory;
974 IHTMLOptionElement *option;
975 IHTMLWindow2 *window;
976 VARIANT text, value, empty;
977 HRESULT hres;
978
979 hres = IHTMLDocument2_get_parentWindow(doc, &window);
980 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
981
982 hres = IHTMLWindow2_get_Option(window, &factory);
983 IHTMLWindow2_Release(window);
984 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
985
986 V_VT(&text) = VT_BSTR;
987 V_BSTR(&text) = a2bstr(txt);
988 V_VT(&value) = VT_BSTR;
989 V_BSTR(&value) = a2bstr(val);
990 V_VT(&empty) = VT_EMPTY;
991
992 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
993 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
994
995 IHTMLOptionElementFactory_Release(factory);
996 VariantClear(&text);
997 VariantClear(&value);
998
999 _test_option_text(line, option, txt);
1000 _test_option_value(line, option, val);
1001
1002 return option;
1003 }
1004
1005 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1006 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1007 {
1008 LONG len = 0xdeadbeef;
1009 HRESULT hres;
1010
1011 hres = IHTMLSelectElement_get_length(select, &len);
1012 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1013 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1014 }
1015
1016 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1017 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1018 {
1019 LONG idx = 0xdeadbeef;
1020 HRESULT hres;
1021
1022 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1023 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1024 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1025 }
1026
1027 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1028 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1029 {
1030 HRESULT hres;
1031
1032 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1033 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1034 _test_select_selidx(line, select, index);
1035 }
1036
1037 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1038 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1039 {
1040 BSTR val;
1041 HRESULT hres;
1042
1043 hres = IHTMLSelectElement_get_value(select, &val);
1044 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1045 if(exval)
1046 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1047 else
1048 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1049 }
1050
1051 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1052 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1053 {
1054 BSTR bstr;
1055 HRESULT hres;
1056
1057 bstr = a2bstr(val);
1058 hres = IHTMLSelectElement_put_value(select, bstr);
1059 SysFreeString(bstr);
1060 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1061 }
1062
1063 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1064 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1065 {
1066 BSTR type;
1067 HRESULT hres;
1068
1069 hres = IHTMLSelectElement_get_type(select, &type);
1070 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1071 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1072 }
1073
1074 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1075 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1076 {
1077 BSTR text;
1078 HRESULT hres;
1079
1080 hres = IHTMLTxtRange_get_text(range, &text);
1081 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1082
1083 if(extext) {
1084 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1085 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1086 }else {
1087 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1088 }
1089
1090 SysFreeString(text);
1091
1092 }
1093
1094 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1095 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1096 {
1097 HRESULT hres;
1098
1099 hres = IHTMLTxtRange_collapse(range, b);
1100 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1101 _test_range_text(line, range, NULL);
1102 }
1103
1104 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1105 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1106 VARIANT_BOOL exb, const char *extext)
1107 {
1108 VARIANT_BOOL b = 0xe0e0;
1109 HRESULT hres;
1110
1111 hres = IHTMLTxtRange_expand(range, unit, &b);
1112 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1113 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1114 _test_range_text(line, range, extext);
1115 }
1116
1117 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1118 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1119 {
1120 LONG c = 0xdeadbeef;
1121 HRESULT hres;
1122
1123 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1124 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1125 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1126 _test_range_text(line, range, NULL);
1127 }
1128
1129 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1130 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1131 LPWSTR unit, LONG cnt, LONG excnt)
1132 {
1133 LONG c = 0xdeadbeef;
1134 HRESULT hres;
1135
1136 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1137 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1138 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1139 }
1140
1141 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1142 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1143 {
1144 LONG c = 0xdeadbeef;
1145 HRESULT hres;
1146
1147 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1148 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1149 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1150 }
1151
1152 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1153 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1154 {
1155 HRESULT hres;
1156 BSTR bstr = a2bstr(text);
1157
1158 hres = IHTMLTxtRange_put_text(range, bstr);
1159 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1160 SysFreeString(bstr);
1161 _test_range_text(line, range, NULL);
1162 }
1163
1164 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1165 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1166 {
1167 VARIANT_BOOL b;
1168 HRESULT hres;
1169
1170 b = 0xe0e0;
1171 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1172 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1173 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1174 }
1175
1176 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1177 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1178 {
1179 VARIANT_BOOL b;
1180 HRESULT hres;
1181
1182 b = 0xe0e0;
1183 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1184 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1185 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1186
1187 b = 0xe0e0;
1188 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1189 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1190 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1191
1192 if(exb) {
1193 test_range_inrange(range1, range2, VARIANT_TRUE);
1194 test_range_inrange(range2, range1, VARIANT_TRUE);
1195 }
1196 }
1197
1198 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1199 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1200 {
1201 IHTMLElement *elem;
1202 HRESULT hres;
1203
1204 hres = IHTMLTxtRange_parentElement(range, &elem);
1205 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1206
1207 _test_elem_type(line, (IUnknown*)elem, type);
1208
1209 IHTMLElement_Release(elem);
1210 }
1211
1212 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1213 static void _test_elem_collection(unsigned line, IUnknown *unk,
1214 const elem_type_t *elem_types, LONG exlen)
1215 {
1216 IHTMLElementCollection *col;
1217 LONG len;
1218 DWORD i;
1219 VARIANT name, index;
1220 IDispatch *disp, *disp2;
1221 HRESULT hres;
1222
1223 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1224 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1225
1226 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1227
1228 hres = IHTMLElementCollection_get_length(col, &len);
1229 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1230 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1231
1232 if(len > exlen)
1233 len = exlen;
1234
1235 V_VT(&index) = VT_EMPTY;
1236
1237 for(i=0; i<len; i++) {
1238 V_VT(&name) = VT_I4;
1239 V_I4(&name) = i;
1240 disp = (void*)0xdeadbeef;
1241 hres = IHTMLElementCollection_item(col, name, index, &disp);
1242 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1243 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1244 if(FAILED(hres) || !disp)
1245 continue;
1246
1247 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1248
1249 if(!i) {
1250 V_VT(&name) = VT_UINT;
1251 V_I4(&name) = 0;
1252 disp2 = (void*)0xdeadbeef;
1253 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1254 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1255 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1256 if(disp2)
1257 IDispatch_Release(disp2);
1258 }
1259
1260 IDispatch_Release(disp);
1261 }
1262
1263 V_VT(&name) = VT_I4;
1264 V_I4(&name) = len;
1265 disp = (void*)0xdeadbeef;
1266 hres = IHTMLElementCollection_item(col, name, index, &disp);
1267 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1268 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1269
1270 V_VT(&name) = VT_I4;
1271 V_I4(&name) = -1;
1272 disp = (void*)0xdeadbeef;
1273 hres = IHTMLElementCollection_item(col, name, index, &disp);
1274 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1275 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1276
1277 IHTMLElementCollection_Release(col);
1278 }
1279
1280 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1281 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1282 {
1283 IHTMLElement *elem = _get_elem_iface(line, unk);
1284 IDispatch *disp;
1285 HRESULT hres;
1286
1287 hres = IHTMLElement_get_all(elem, &disp);
1288 IHTMLElement_Release(elem);
1289 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1290
1291 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1292 IDispatch_Release(disp);
1293 }
1294
1295 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1296 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1297 {
1298 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1299 IHTMLElementCollection *col = NULL;
1300 elem_type_t *types = NULL;
1301 BSTR tmp;
1302 int i;
1303 HRESULT hres;
1304
1305 tmp = a2bstr(elem_type_infos[type].tag);
1306 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1307 SysFreeString(tmp);
1308 IHTMLElement2_Release(elem);
1309 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1310 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1311
1312 if(exlen) {
1313 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1314 for(i=0; i<exlen; i++)
1315 types[i] = type;
1316 }
1317
1318 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1319
1320 HeapFree(GetProcessHeap(), 0, types);
1321 }
1322
1323 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1324 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1325 {
1326 BSTR text = NULL;
1327 HRESULT hres;
1328
1329 hres = IHTMLElement_get_innerText(elem, &text);
1330 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1331 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1332 wine_dbgstr_w(text), extext);
1333 SysFreeString(text);
1334 }
1335
1336 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1337 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1338 {
1339 IHTMLDOMChildrenCollection *col;
1340 BSTR str;
1341 HRESULT hres;
1342
1343 str = a2bstr(text);
1344 hres = IHTMLElement_put_innerText(elem, str);
1345 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1346 SysFreeString(str);
1347
1348 _test_elem_innertext(line, elem, text);
1349
1350
1351 col = _get_child_nodes(line, (IUnknown*)elem);
1352 ok(col != NULL, "col == NULL\n");
1353 if(col) {
1354 LONG length = 0, type;
1355 IHTMLDOMNode *node;
1356
1357 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1358 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1359 ok(length == 1, "length = %d\n", length);
1360
1361 node = _get_child_item(line, col, 0);
1362 ok(node != NULL, "node == NULL\n");
1363 if(node) {
1364 type = _get_node_type(line, (IUnknown*)node);
1365 ok(type == 3, "type=%d\n", type);
1366 IHTMLDOMNode_Release(node);
1367 }
1368
1369 IHTMLDOMChildrenCollection_Release(col);
1370 }
1371
1372 }
1373
1374 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1375 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1376 {
1377 IHTMLElement *elem = _get_elem_iface(line, unk);
1378 BSTR html;
1379 HRESULT hres;
1380
1381 hres = IHTMLElement_get_innerHTML(elem, &html);
1382 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1383 if(inner_html)
1384 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1385 else
1386 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1387
1388 IHTMLElement_Release(elem);
1389 SysFreeString(html);
1390 }
1391
1392 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1393 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1394 {
1395 IHTMLElement *elem = _get_elem_iface(line, unk);
1396 BSTR html;
1397 HRESULT hres;
1398
1399 html = a2bstr(inner_html);
1400 hres = IHTMLElement_put_innerHTML(elem, html);
1401 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1402
1403 IHTMLElement_Release(elem);
1404 SysFreeString(html);
1405 }
1406
1407 #define get_first_child(n) _get_first_child(__LINE__,n)
1408 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1409 {
1410 IHTMLDOMNode *node = _get_node_iface(line, unk);
1411 IHTMLDOMNode *child = NULL;
1412 HRESULT hres;
1413
1414 hres = IHTMLDOMNode_get_firstChild(node, &child);
1415 IHTMLDOMNode_Release(node);
1416 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1417
1418 return child;
1419 }
1420
1421 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1422 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1423 {
1424 IHTMLDOMNode *node = _get_node_iface(line, unk);
1425 VARIANT_BOOL b = 0xdead;
1426 HRESULT hres;
1427
1428 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1429 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1430 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1431
1432 IHTMLDOMNode_Release(node);
1433 }
1434
1435 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1436 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1437 {
1438 IHTMLDOMNode *node = _get_node_iface(line, unk);
1439 IHTMLDOMNode *parent;
1440 HRESULT hres;
1441
1442 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1443 IHTMLDOMNode_Release(node);
1444 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1445
1446 return parent;
1447 }
1448
1449 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1450 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1451 {
1452 IHTMLElement *elem = _get_elem_iface(line, unk);
1453 IHTMLElement *parent;
1454 HRESULT hres;
1455
1456 hres = IHTMLElement_get_parentElement(elem, &parent);
1457 IHTMLElement_Release(elem);
1458 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1459
1460 return parent;
1461 }
1462
1463 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1464 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1465 {
1466 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1467 VARIANT_BOOL disabled = 100;
1468 HRESULT hres;
1469
1470 if (!elem3) return;
1471 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1472 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1473 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1474 IHTMLElement3_Release(elem3);
1475 }
1476
1477 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1478 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1479 {
1480 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1481 HRESULT hres;
1482
1483 if (!elem3) return;
1484 hres = IHTMLElement3_put_disabled(elem3, b);
1485 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1486
1487 IHTMLElement3_Release(elem3);
1488 _test_elem3_get_disabled(line, unk, b);
1489 }
1490
1491 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1492 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1493 {
1494 VARIANT_BOOL disabled = 100;
1495 HRESULT hres;
1496
1497 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1498 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1499 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1500
1501 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1502 }
1503
1504 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1505 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1506 {
1507 HRESULT hres;
1508
1509 hres = IHTMLSelectElement_put_disabled(select, b);
1510 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1511
1512 _test_select_get_disabled(line, select, b);
1513 }
1514
1515 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1516 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1517 {
1518 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1519 IHTMLTextContainer *txtcont;
1520 LONG l = -1, l2 = -1;
1521 HRESULT hres;
1522
1523 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1524 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1525 IHTMLElement2_Release(elem);
1526
1527 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1528 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1529
1530 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1531 IHTMLTextContainer_Release(txtcont);
1532 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1533 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1534
1535 return l;
1536 }
1537
1538 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1539 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1540 {
1541 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1542 IHTMLTextContainer *txtcont;
1543 LONG l = -1, l2 = -1;
1544 HRESULT hres;
1545
1546 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1547 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1548 IHTMLElement2_Release(elem);
1549
1550 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1551 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1552
1553 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1554 IHTMLTextContainer_Release(txtcont);
1555 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1556 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1557
1558 return l;
1559 }
1560
1561 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1562 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1563 {
1564 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1565 IHTMLTextContainer *txtcont;
1566 LONG l = -1, l2 = -1;
1567 HRESULT hres;
1568
1569 hres = IHTMLElement2_get_scrollTop(elem, &l);
1570 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1571 IHTMLElement2_Release(elem);
1572
1573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1575
1576 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1577 IHTMLTextContainer_Release(txtcont);
1578 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1579 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1580
1581 return l;
1582 }
1583
1584 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1585 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1586 {
1587 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1588 IHTMLTextContainer *txtcont;
1589 LONG l = -1, l2 = -1;
1590 HRESULT hres;
1591
1592 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1593 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1594
1595 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1596 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1597 IHTMLElement2_Release(elem);
1598
1599 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1600 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1601
1602 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1603 IHTMLTextContainer_Release(txtcont);
1604 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1605 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1606 }
1607
1608 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1609 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1610 {
1611 IHTMLImgElement *img = _get_img_iface(line, unk);
1612 BSTR src;
1613 HRESULT hres;
1614
1615 hres = IHTMLImgElement_get_src(img, &src);
1616 IHTMLImgElement_Release(img);
1617 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1618 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1619 SysFreeString(src);
1620 }
1621
1622 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1623 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1624 {
1625 IHTMLImgElement *img = _get_img_iface(line, unk);
1626 BSTR tmp;
1627 HRESULT hres;
1628
1629 tmp = a2bstr(src);
1630 hres = IHTMLImgElement_put_src(img, tmp);
1631 IHTMLImgElement_Release(img);
1632 SysFreeString(tmp);
1633 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1634
1635 _test_img_src(line, unk, src);
1636 }
1637
1638 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1639 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1640 {
1641 IHTMLImgElement *img = _get_img_iface(line, unk);
1642 BSTR alt;
1643 HRESULT hres;
1644
1645 hres = IHTMLImgElement_get_alt(img, &alt);
1646 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1647 if(exalt)
1648 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1649 else
1650 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1651 SysFreeString(alt);
1652 }
1653
1654 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1655 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1656 {
1657 IHTMLImgElement *img = _get_img_iface(line, unk);
1658 BSTR tmp;
1659 HRESULT hres;
1660
1661 tmp = a2bstr(alt);
1662 hres = IHTMLImgElement_put_alt(img, tmp);
1663 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1664 SysFreeString(tmp);
1665
1666 _test_img_alt(line, unk, alt);
1667 }
1668
1669 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1670 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1671 {
1672 VARIANT_BOOL disabled = 100;
1673 HRESULT hres;
1674
1675 hres = IHTMLInputElement_get_disabled(input, &disabled);
1676 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1677 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1678
1679 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1680 }
1681
1682 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1683 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1684 {
1685 HRESULT hres;
1686
1687 hres = IHTMLInputElement_put_disabled(input, b);
1688 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1689
1690 _test_input_get_disabled(line, input, b);
1691 }
1692
1693 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1694 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1695 {
1696 VARIANT_BOOL checked = 100;
1697 HRESULT hres;
1698
1699 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1700 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1701 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1702 }
1703
1704 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1705 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1706 {
1707 HRESULT hres;
1708
1709 hres = IHTMLInputElement_put_defaultChecked(input, b);
1710 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1711
1712 _test_input_get_defaultchecked(line, input, b);
1713 }
1714
1715 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1716 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1717 {
1718 VARIANT_BOOL checked = 100;
1719 HRESULT hres;
1720
1721 hres = IHTMLInputElement_get_checked(input, &checked);
1722 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1723 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1724 }
1725
1726 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1727 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1728 {
1729 HRESULT hres;
1730
1731 hres = IHTMLInputElement_put_checked(input, b);
1732 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1733
1734 _test_input_get_checked(line, input, b);
1735 }
1736
1737 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1738 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1739 {
1740 IHTMLInputElement *input;
1741 BSTR bstr;
1742 HRESULT hres;
1743
1744 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1745 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1746 if(FAILED(hres))
1747 return;
1748
1749 hres = IHTMLInputElement_get_value(input, &bstr);
1750 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1751 if(exval)
1752 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1753 else
1754 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1755 SysFreeString(bstr);
1756 IHTMLInputElement_Release(input);
1757 }
1758
1759 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1760 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1761 {
1762 IHTMLInputElement *input;
1763 BSTR bstr;
1764 HRESULT hres;
1765
1766 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1767 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1768 if(FAILED(hres))
1769 return;
1770
1771 bstr = a2bstr(val);
1772 hres = IHTMLInputElement_get_value(input, &bstr);
1773 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1774 SysFreeString(bstr);
1775 IHTMLInputElement_Release(input);
1776 }
1777
1778 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1779 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1780 {
1781 BSTR src;
1782 HRESULT hres;
1783
1784 hres = IHTMLInputElement_get_src(input, &src);
1785 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1786 if(exsrc)
1787 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1788 else
1789 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1790 SysFreeString(src);
1791 }
1792
1793 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1794 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1795 {
1796 BSTR tmp;
1797 HRESULT hres;
1798
1799 tmp = a2bstr(src);
1800 hres = IHTMLInputElement_put_src(input, tmp);
1801 SysFreeString(tmp);
1802 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1803
1804 _test_input_src(line, input, src);
1805 }
1806
1807 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1808 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1809 {
1810 IHTMLElement *elem = _get_elem_iface(line, unk);
1811 BSTR class = (void*)0xdeadbeef;
1812 HRESULT hres;
1813
1814 hres = IHTMLElement_get_className(elem, &class);
1815 IHTMLElement_Release(elem);
1816 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1817 if(exclass)
1818 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1819 else
1820 ok_(__FILE__,line) (!class, "class != NULL\n");
1821 SysFreeString(class);
1822 }
1823
1824 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1825 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1826 {
1827 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1828 short index = -3;
1829 HRESULT hres;
1830
1831 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1832 IHTMLElement2_Release(elem2);
1833 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1834 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1835 }
1836
1837 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1838 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1839 {
1840 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1841 HRESULT hres;
1842
1843 hres = IHTMLElement2_put_tabIndex(elem2, index);
1844 IHTMLElement2_Release(elem2);
1845 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1846
1847 _test_elem_tabindex(line, unk, index);
1848 }
1849
1850 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1851 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1852 {
1853 IHTMLElement *elem = _get_elem_iface(line, unk);
1854 BSTR tmp;
1855 HRESULT hres;
1856
1857 tmp = class ? a2bstr(class) : NULL;
1858 hres = IHTMLElement_put_className(elem, tmp);
1859 IHTMLElement_Release(elem);
1860 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1861 SysFreeString(tmp);
1862
1863 _test_elem_class(line, unk, class);
1864 }
1865
1866 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1867 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1868 {
1869 IHTMLElement *elem = _get_elem_iface(line, unk);
1870 BSTR id = (void*)0xdeadbeef;
1871 HRESULT hres;
1872
1873 hres = IHTMLElement_get_id(elem, &id);
1874 IHTMLElement_Release(elem);
1875 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1876
1877 if(exid)
1878 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1879 else
1880 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1881
1882 SysFreeString(id);
1883 }
1884
1885 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1886 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1887 {
1888 IHTMLElement *elem = _get_elem_iface(line, unk);
1889 BSTR tmp = a2bstr(new_id);
1890 HRESULT hres;
1891
1892 hres = IHTMLElement_put_id(elem, tmp);
1893 IHTMLElement_Release(elem);
1894 SysFreeString(tmp);
1895 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1896
1897 _test_elem_id(line, unk, new_id);
1898 }
1899
1900 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1901 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1902 {
1903 IHTMLElement *elem = _get_elem_iface(line, unk);
1904 BSTR title;
1905 HRESULT hres;
1906
1907 hres = IHTMLElement_get_title(elem, &title);
1908 IHTMLElement_Release(elem);
1909 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1910 if(extitle)
1911 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1912 else
1913 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1914
1915 SysFreeString(title);
1916 }
1917
1918 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1919 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1920 {
1921 IHTMLElement *elem = _get_elem_iface(line, unk);
1922 BSTR tmp;
1923 HRESULT hres;
1924
1925 tmp = a2bstr(title);
1926 hres = IHTMLElement_put_title(elem, tmp);
1927 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1928
1929 IHTMLElement_Release(elem);
1930 SysFreeString(tmp);
1931 }
1932
1933 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1934 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1935 {
1936 IHTMLDOMNode *node = _get_node_iface(line, unk);
1937 VARIANT var;
1938 HRESULT hres;
1939
1940 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1941 IHTMLDOMNode_Release(node);
1942 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1943
1944 if(exval) {
1945 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1946 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
1947 }else {
1948 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1949 }
1950
1951 VariantClear(&var);
1952 }
1953
1954 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1955 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1956 {
1957 IHTMLDOMNode *node = _get_node_iface(line, unk);
1958 VARIANT var;
1959 HRESULT hres;
1960
1961 V_VT(&var) = VT_BSTR;
1962 V_BSTR(&var) = a2bstr(val);
1963
1964 hres = IHTMLDOMNode_put_nodeValue(node, var);
1965 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1966 IHTMLDOMNode_Release(node);
1967 VariantClear(&var);
1968 }
1969
1970 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1971 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1972 {
1973 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1974 LONG l;
1975 HRESULT hres;
1976
1977 hres = IHTMLElement2_get_clientWidth(elem, &l);
1978 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1979 hres = IHTMLElement2_get_clientHeight(elem, &l);
1980 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1981
1982 IHTMLElement2_Release(elem);
1983 }
1984
1985 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
1986 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
1987 {
1988 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1989 LONG l;
1990 HRESULT hres;
1991
1992 hres = IHTMLElement2_get_clientLeft(elem, &l);
1993 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
1994 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
1995
1996 hres = IHTMLElement2_get_clientTop(elem, &l);
1997 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
1998 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
1999
2000 IHTMLElement2_Release(elem);
2001 }
2002
2003 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2004 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2005 {
2006 IHTMLElement *elem = NULL;
2007 BSTR tmp;
2008 HRESULT hres;
2009
2010 tmp = a2bstr(tag);
2011 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2012 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2013 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2014
2015 return elem;
2016 }
2017
2018 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2019 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2020 {
2021 IHTMLDocument3 *doc3;
2022 IHTMLDOMNode *node = NULL;
2023 BSTR tmp;
2024 HRESULT hres;
2025
2026 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2027 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2028
2029 tmp = a2bstr(text);
2030 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2031 IHTMLDocument3_Release(doc3);
2032 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2033 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2034
2035 return node;
2036 }
2037
2038 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2039 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2040 {
2041 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2042 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2043 IHTMLDOMNode *new_child = NULL;
2044 HRESULT hres;
2045
2046 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2047 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2048 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2049 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2050
2051 IHTMLDOMNode_Release(node);
2052 IHTMLDOMNode_Release(child);
2053
2054 return new_child;
2055 }
2056
2057 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2058 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2059 {
2060 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2061 IHTMLDOMNode *new_child = NULL;
2062 HRESULT hres;
2063
2064 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2065 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2066 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2067 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2068
2069 IHTMLDOMNode_Release(node);
2070
2071 return new_child;
2072 }
2073
2074 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2075 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2076 {
2077 IHTMLDOMNode *node = _get_node_iface(line, unk);
2078 IHTMLDOMNode *new_node = NULL;
2079 HRESULT hres;
2080
2081 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2082 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2083 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2084 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2085
2086 IHTMLDOMNode_Release(node);
2087 IHTMLDOMNode_Release(new_node);
2088 }
2089
2090 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2091 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2092 {
2093 BSTR title = NULL;
2094 HRESULT hres;
2095
2096 hres = IHTMLDocument2_get_title(doc, &title);
2097 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2098 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2099 SysFreeString(title);
2100 }
2101
2102 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2103 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2104 {
2105 BSTR tmp;
2106 HRESULT hres;
2107
2108 tmp = a2bstr(title);
2109 hres = IHTMLDocument2_put_title(doc, tmp);
2110 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2111 SysFreeString(tmp);
2112 }
2113
2114 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2115 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2116 {
2117 HRESULT hres;
2118 DISPID dispid;
2119
2120 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2121 LOCALE_USER_DEFAULT, &dispid);
2122 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2123 if(hres == S_OK)
2124 {
2125 DISPPARAMS params = {NULL,NULL,0,0};
2126 DISPID dispidNamed = DISPID_PROPERTYPUT;
2127 VARIANT ret;
2128 VARIANT vDefault;
2129 VARIANTARG arg;
2130
2131 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2132 DISPATCH_PROPERTYGET, &params, &vDefault, NULL, NULL);
2133 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2134
2135 params.cArgs = 1;
2136 params.cNamedArgs = 1;
2137 params.rgdispidNamedArgs = &dispidNamed;
2138 V_VT(&arg) = VT_BSTR;
2139 V_BSTR(&arg) = a2bstr("none");
2140 params.rgvarg = &arg;
2141 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2142 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2143 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2144 VariantClear(&arg);
2145
2146 V_VT(&arg) = VT_BSTR;
2147 V_BSTR(&arg) = a2bstr("dotted");
2148 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2149 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2150 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2151 VariantClear(&arg);
2152
2153 V_VT(&arg) = VT_BSTR;
2154 V_BSTR(&arg) = a2bstr("dashed");
2155 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2156 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2157 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2158 VariantClear(&arg);
2159
2160 V_VT(&arg) = VT_BSTR;
2161 V_BSTR(&arg) = a2bstr("solid");
2162 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2163 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2164 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2165 VariantClear(&arg);
2166
2167 V_VT(&arg) = VT_BSTR;
2168 V_BSTR(&arg) = a2bstr("double");
2169 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2170 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2171 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2172 VariantClear(&arg);
2173
2174 V_VT(&arg) = VT_BSTR;
2175 V_BSTR(&arg) = a2bstr("groove");
2176 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2177 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2178 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2179 VariantClear(&arg);
2180
2181 V_VT(&arg) = VT_BSTR;
2182 V_BSTR(&arg) = a2bstr("ridge");
2183 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2184 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2185 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2186 VariantClear(&arg);
2187
2188 V_VT(&arg) = VT_BSTR;
2189 V_BSTR(&arg) = a2bstr("inset");
2190 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2191 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2192 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2193 VariantClear(&arg);
2194
2195 V_VT(&arg) = VT_BSTR;
2196 V_BSTR(&arg) = a2bstr("outset");
2197 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2198 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2199 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2200 VariantClear(&arg);
2201
2202 V_VT(&arg) = VT_BSTR;
2203 V_BSTR(&arg) = a2bstr("invalid");
2204 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2205 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2206 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2207 VariantClear(&arg);
2208
2209 params.rgvarg = &vDefault;
2210 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2211 DISPATCH_PROPERTYPUT, &params, &ret, NULL, NULL);
2212 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2213 }
2214 }
2215
2216 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2217 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2218 {
2219 BSTR text = (void*)0xdeadbeef;
2220 HRESULT hres;
2221
2222 hres = IHTMLStyle_get_cssText(style, &text);
2223 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2224 if(extext)
2225 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2226 else
2227 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2228
2229 SysFreeString(text);
2230 }
2231
2232 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2233 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2234 {
2235 BSTR tmp;
2236 HRESULT hres;
2237
2238 tmp = a2bstr(text);
2239 hres = IHTMLStyle_put_cssText(style, tmp);
2240 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2241 SysFreeString(tmp);
2242 }
2243
2244 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2245 const elem_type_t *elem_types, LONG len)
2246 {
2247 IDispatch *disp;
2248 VARIANT name, index;
2249 DWORD i;
2250 HRESULT hres;
2251
2252 V_VT(&index) = VT_EMPTY;
2253 V_VT(&name) = VT_BSTR;
2254 V_BSTR(&name) = a2bstr(n);
2255
2256 hres = IHTMLElementCollection_item(col, name, index, &disp);
2257 ok(hres == S_OK, "item failed: %08x\n", hres);
2258
2259 test_elem_collection((IUnknown*)disp, elem_types, len);
2260 IDispatch_Release(disp);
2261 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2262 if(hres != S_OK)
2263 goto cleanup;
2264
2265 V_VT(&index) = VT_I4;
2266
2267 for(i=0; i<len; i++) {
2268 V_I4(&index) = i;
2269 disp = (void*)0xdeadbeef;
2270 hres = IHTMLElementCollection_item(col, name, index, &disp);
2271 ok(hres == S_OK, "item failed: %08x\n", hres);
2272 ok(disp != NULL, "disp == NULL\n");
2273 if(FAILED(hres) || !disp)
2274 continue;
2275
2276 test_elem_type((IUnknown*)disp, elem_types[i]);
2277
2278 IDispatch_Release(disp);
2279 }
2280
2281 V_I4(&index) = len;
2282 disp = (void*)0xdeadbeef;
2283 hres = IHTMLElementCollection_item(col, name, index, &disp);
2284 ok(hres == S_OK, "item failed: %08x\n", hres);
2285 ok(disp == NULL, "disp != NULL\n");
2286
2287 V_I4(&index) = -1;
2288 disp = (void*)0xdeadbeef;
2289 hres = IHTMLElementCollection_item(col, name, index, &disp);
2290 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2291 ok(disp == NULL, "disp != NULL\n");
2292
2293 cleanup:
2294 SysFreeString(V_BSTR(&name));
2295 }
2296
2297 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2298 {
2299 IHTMLElementCollection *col;
2300 IHTMLElement *elem;
2301 IDispatch *disp = (void*)0xdeadbeef;
2302 VARIANT name, index;
2303 HRESULT hres;
2304
2305 hres = IHTMLDocument2_get_all(doc, &col);
2306 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2307 ok(col != NULL, "col == NULL\n");
2308 if(FAILED(hres) || !col)
2309 return NULL;
2310
2311 V_VT(&index) = VT_EMPTY;
2312 V_VT(&name) = VT_BSTR;
2313 V_BSTR(&name) = a2bstr(id);
2314
2315 hres = IHTMLElementCollection_item(col, name, index, &disp);
2316 IHTMLElementCollection_Release(col);
2317 SysFreeString(V_BSTR(&name));
2318 ok(hres == S_OK, "item failed: %08x\n", hres);
2319 if(!expect_success) {
2320 ok(disp == NULL, "disp != NULL\n");
2321 return NULL;
2322 }
2323
2324 ok(disp != NULL, "disp == NULL\n");
2325 if(!disp)
2326 return NULL;
2327
2328 elem = get_elem_iface((IUnknown*)disp);
2329 IDispatch_Release(disp);
2330
2331 return elem;
2332 }
2333
2334 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2335 {
2336 IHTMLDocument3 *doc3;
2337 IHTMLElement *elem;
2338 BSTR tmp;
2339 HRESULT hres;
2340
2341 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2342 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2343
2344 tmp = a2bstr(id);
2345 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2346 SysFreeString(tmp);
2347 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2348
2349 IHTMLDocument3_Release(doc3);
2350
2351 return elem;
2352 }
2353
2354 static void test_select_elem(IHTMLSelectElement *select)
2355 {
2356 test_select_type(select, "select-one");
2357 test_select_length(select, 2);
2358 test_select_selidx(select, 0);
2359 test_select_put_selidx(select, 1);
2360
2361 test_select_set_value(select, "val1");
2362 test_select_value(select, "val1");
2363
2364 test_select_get_disabled(select, VARIANT_FALSE);
2365 test_select_set_disabled(select, VARIANT_TRUE);
2366 test_select_set_disabled(select, VARIANT_FALSE);
2367 }
2368
2369 static void test_create_option_elem(IHTMLDocument2 *doc)
2370 {
2371 IHTMLOptionElement *option;
2372
2373 option = create_option_elem(doc, "test text", "test value");
2374
2375 test_option_put_text(option, "new text");
2376 test_option_put_value(option, "new value");
2377
2378 IHTMLOptionElement_Release(option);
2379 }
2380
2381 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2382 {
2383 IHTMLBodyElement *body;
2384 IHTMLTxtRange *range;
2385 IHTMLElement *elem;
2386 HRESULT hres;
2387
2388 hres = IHTMLDocument2_get_body(doc, &elem);
2389 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2390
2391 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2392 IHTMLElement_Release(elem);
2393
2394 hres = IHTMLBodyElement_createTextRange(body, &range);
2395 IHTMLBodyElement_Release(body);
2396 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2397
2398 return range;
2399 }
2400
2401 static void test_txtrange(IHTMLDocument2 *doc)
2402 {
2403 IHTMLTxtRange *body_range, *range, *range2;
2404 IHTMLSelectionObject *selection;
2405 IDispatch *disp_range;
2406 HRESULT hres;
2407
2408 body_range = test_create_body_range(doc);
2409
2410 test_range_text(body_range, "test abc 123\r\nit's text");
2411
2412 hres = IHTMLTxtRange_duplicate(body_range, &range);
2413 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2414
2415 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2416 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2417 test_range_isequal(range, range2, VARIANT_TRUE);
2418
2419 test_range_text(range, "test abc 123\r\nit's text");
2420 test_range_text(body_range, "test abc 123\r\nit's text");
2421
2422 test_range_collapse(range, TRUE);
2423 test_range_isequal(range, range2, VARIANT_FALSE);
2424 test_range_inrange(range, range2, VARIANT_FALSE);
2425 test_range_inrange(range2, range, VARIANT_TRUE);
2426 IHTMLTxtRange_Release(range2);
2427
2428 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2429 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2430 test_range_move(range, characterW, 2, 2);
2431 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2432
2433 test_range_collapse(range, FALSE);
2434 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2435
2436 test_range_collapse(range, FALSE);
2437 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2438 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2439 test_range_move(range, characterW, 2, 2);
2440 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2441 test_range_moveend(range, characterW, -5, -5);
2442 test_range_text(range, NULL);
2443 test_range_moveend(range, characterW, 3, 3);
2444 test_range_text(range, "c 1");
2445 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2446 test_range_collapse(range, TRUE);
2447 test_range_move(range, characterW, 4, 4);
2448 test_range_moveend(range, characterW, 1, 1);
2449 test_range_text(range, " ");
2450 test_range_move(range, wordW, 1, 1);
2451 test_range_moveend(range, characterW, 2, 2);
2452 test_range_text(range, "ab");
2453
2454 IHTMLTxtRange_Release(range);
2455
2456 hres = IHTMLTxtRange_duplicate(body_range, &range);
2457 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2458
2459 test_range_text(range, "test abc 123\r\nit's text");
2460 test_range_move(range, characterW, 3, 3);
2461 test_range_moveend(range, characterW, 1, 1);
2462 test_range_text(range, "t");
2463 test_range_moveend(range, characterW, 3, 3);
2464 test_range_text(range, "t ab");
2465 test_range_moveend(range, characterW, -2, -2);
2466 test_range_text(range, "t ");
2467 test_range_move(range, characterW, 6, 6);
2468 test_range_moveend(range, characterW, 3, 3);
2469 test_range_text(range, "123");
2470 test_range_moveend(range, characterW, 2, 2);
2471 test_range_text(range, "123\r\ni");
2472
2473 IHTMLTxtRange_Release(range);
2474
2475 hres = IHTMLTxtRange_duplicate(body_range, &range);
2476 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2477
2478 test_range_move(range, wordW, 1, 1);
2479 test_range_moveend(range, characterW, 2, 2);
2480 test_range_text(range, "ab");
2481
2482 test_range_move(range, characterW, -2, -2);
2483 test_range_moveend(range, characterW, 2, 2);
2484 test_range_text(range, "t ");
2485
2486 test_range_move(range, wordW, 3, 3);
2487 test_range_move(range, wordW, -2, -2);
2488 test_range_moveend(range, characterW, 2, 2);
2489 test_range_text(range, "ab");
2490
2491 test_range_move(range, characterW, -6, -5);
2492 test_range_moveend(range, characterW, -1, 0);
2493 test_range_moveend(range, characterW, -6, 0);
2494 test_range_move(range, characterW, 2, 2);
2495 test_range_moveend(range, characterW, 2, 2);
2496 test_range_text(range, "st");
2497 test_range_moveend(range, characterW, -6, -4);
2498 test_range_moveend(range, characterW, 2, 2);
2499
2500 IHTMLTxtRange_Release(range);
2501
2502 hres = IHTMLTxtRange_duplicate(body_range, &range);
2503 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2504
2505 test_range_move(range, wordW, 2, 2);
2506 test_range_moveend(range, characterW, 2, 2);
2507 test_range_text(range, "12");
2508
2509 test_range_move(range, characterW, 15, 14);
2510 test_range_move(range, characterW, -2, -2);
2511 test_range_moveend(range, characterW, 3, 2);
2512 test_range_text(range, "t");
2513 test_range_moveend(range, characterW, -1, -1);
2514 test_range_text(range, "t");
2515 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2516 test_range_move(range, characterW, -2, -2);
2517 test_range_moveend(range, characterW, 2, 2);
2518 test_range_text(range, "s ");
2519 test_range_move(range, characterW, 100, 7);
2520 test_range_move(range, wordW, 1, 0);
2521 test_range_move(range, characterW, -2, -2);
2522 test_range_moveend(range, characterW, 3, 2);
2523 test_range_text(range, "t");
2524
2525 IHTMLTxtRange_Release(range);
2526
2527 hres = IHTMLTxtRange_duplicate(body_range, &range);
2528 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2529
2530 test_range_collapse(range, TRUE);
2531 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2532 test_range_put_text(range, "word");
2533 test_range_text(body_range, "wordabc 123\r\nit's text");
2534 test_range_text(range, NULL);
2535 test_range_moveend(range, characterW, 3, 3);
2536 test_range_text(range, "abc");
2537 test_range_movestart(range, characterW, -2, -2);
2538 test_range_text(range, "rdabc");
2539 test_range_movestart(range, characterW, 3, 3);
2540 test_range_text(range, "bc");
2541 test_range_movestart(range, characterW, 4, 4);
2542 test_range_text(range, NULL);
2543 test_range_movestart(range, characterW, -3, -3);
2544 test_range_text(range, "c 1");
2545 test_range_movestart(range, characterW, -7, -6);
2546 test_range_text(range, "wordabc 1");
2547 test_range_movestart(range, characterW, 100, 22);
2548 test_range_text(range, NULL);
2549
2550 IHTMLTxtRange_Release(range);
2551 IHTMLTxtRange_Release(body_range);
2552
2553 hres = IHTMLDocument2_get_selection(doc, &selection);
2554 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2555
2556 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2557 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2558 IHTMLSelectionObject_Release(selection);
2559
2560 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2561 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2562 IDispatch_Release(disp_range);
2563
2564 test_range_text(range, NULL);
2565 test_range_moveend(range, characterW, 3, 3);
2566 test_range_text(range, "wor");
2567 test_range_parent(range, ET_BODY);
2568 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2569 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2570 test_range_move(range, characterW, 3, 3);
2571 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2572 test_range_moveend(range, characterW, -4, -4);
2573 test_range_put_text(range, "abc def ");
2574 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2575 test_range_move(range, wordW, 1, 1);
2576 test_range_movestart(range, characterW, -1, -1);
2577 test_range_text(range, " ");
2578 test_range_move(range, wordW, 1, 1);
2579 test_range_moveend(range, characterW, 3, 3);
2580 test_range_text(range, "def");
2581 test_range_put_text(range, "xyz");
2582 test_range_moveend(range, characterW, 1, 1);
2583 test_range_move(range, wordW, 1, 1);
2584 test_range_moveend(range, characterW, 2, 2);
2585 test_range_text(range, "ab");
2586
2587 IHTMLTxtRange_Release(range);
2588 }
2589
2590 static void test_txtrange2(IHTMLDocument2 *doc)
2591 {
2592 IHTMLTxtRange *range;
2593
2594 range = test_create_body_range(doc);
2595
2596 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2597 test_range_move(range, characterW, 5, 5);
2598 test_range_moveend(range, characterW, 1, 1);
2599 test_range_text(range, "2");
2600 test_range_move(range, characterW, -3, -3);
2601 test_range_moveend(range, characterW, 3, 3);
2602 test_range_text(range, "c\r\n\r\n1");
2603 test_range_collapse(range, VARIANT_FALSE);
2604 test_range_moveend(range, characterW, 4, 4);
2605 test_range_text(range, "23");
2606 test_range_moveend(range, characterW, 1, 1);
2607 test_range_text(range, "23\r\n\r\n\r\nd");
2608 test_range_moveend(range, characterW, -1, -1);
2609 test_range_text(range, "23");
2610 test_range_moveend(range, characterW, -1, -1);
2611 test_range_text(range, "23");
2612 test_range_moveend(range, characterW, -2, -2);
2613 test_range_text(range, "2");
2614
2615 IHTMLTxtRange_Release(range);
2616 }
2617
2618 static void test_compatmode(IHTMLDocument2 *doc)
2619 {
2620 IHTMLDocument5 *doc5;
2621 BSTR mode;
2622 HRESULT hres;
2623
2624 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2625 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2626 if(FAILED(hres))
2627 return;
2628
2629 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2630 IHTMLDocument5_Release(doc5);
2631 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2632 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2633 SysFreeString(mode);
2634 }
2635
2636 static void test_location(IHTMLDocument2 *doc)
2637 {
2638 IHTMLLocation *location, *location2;
2639 IHTMLWindow2 *window;
2640 BSTR str;
2641 ULONG ref;
2642 HRESULT hres;
2643
2644 hres = IHTMLDocument2_get_location(doc, &location);
2645 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2646
2647 hres = IHTMLDocument2_get_location(doc, &location2);
2648 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2649
2650 ok(location == location2, "location != location2\n");
2651 IHTMLLocation_Release(location2);
2652
2653 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2654 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2655
2656 hres = IHTMLWindow2_get_location(window, &location2);
2657 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2658 ok(location == location2, "location != location2\n");
2659 IHTMLLocation_Release(location2);
2660
2661 test_ifaces((IUnknown*)location, location_iids);
2662 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2663
2664 hres = IHTMLLocation_get_pathname(location, &str);
2665 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2666 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2667
2668 hres = IHTMLLocation_get_href(location, NULL);
2669 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2670
2671 hres = IHTMLLocation_get_href(location, &str);
2672 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2673 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2674
2675 ref = IHTMLLocation_Release(location);
2676 ok(!ref, "location chould be destroyed here\n");
2677 }
2678
2679 static void test_navigator(IHTMLDocument2 *doc)
2680 {
2681 IHTMLWindow2 *window;
2682 IOmNavigator *navigator, *navigator2;
2683 char buf[512];
2684 DWORD size;
2685 ULONG ref;
2686 BSTR bstr;
2687 HRESULT hres;
2688
2689 static const WCHAR v40[] = {'4','.','0'};
2690
2691 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2692 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2693
2694 hres = IHTMLWindow2_get_navigator(window, &navigator);
2695 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2696 ok(navigator != NULL, "navigator == NULL\n");
2697 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2698
2699 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2700 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2701 ok(navigator != navigator2, "navigator2 != navihgator\n");
2702
2703 IHTMLWindow2_Release(window);
2704 IOmNavigator_Release(navigator2);
2705
2706 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2707 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2708 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2709 SysFreeString(bstr);
2710
2711 bstr = NULL;
2712 hres = IOmNavigator_get_appName(navigator, &bstr);
2713 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2714 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2715 SysFreeString(bstr);
2716
2717 bstr = NULL;
2718 hres = IOmNavigator_get_platform(navigator, &bstr);
2719 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2720 #ifdef _WIN64
2721 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2722 #else
2723 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2724 #endif
2725 SysFreeString(bstr);
2726
2727 bstr = NULL;
2728 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2729 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2730 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2731 SysFreeString(bstr);
2732
2733 hres = IOmNavigator_toString(navigator, NULL);
2734 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2735
2736 bstr = NULL;
2737 hres = IOmNavigator_toString(navigator, &bstr);
2738 ok(hres == S_OK, "toString failed: %08x\n", hres);
2739 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2740 SysFreeString(bstr);
2741
2742 size = sizeof(buf);
2743 hres = ObtainUserAgentString(0, buf, &size);
2744 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2745
2746 bstr = NULL;
2747 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2748 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2749 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2750 SysFreeString(bstr);
2751
2752 ref = IOmNavigator_Release(navigator);
2753 ok(!ref, "navigator should be destroyed here\n");
2754 }
2755
2756 static void test_current_style(IHTMLCurrentStyle *current_style)
2757 {
2758 BSTR str;
2759 HRESULT hres;
2760 VARIANT v;
2761
2762 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2763 test_ifaces((IUnknown*)current_style, cstyle_iids);
2764
2765 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2766 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2767 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2768 SysFreeString(str);
2769
2770 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2771 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2772 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2773 SysFreeString(str);
2774
2775 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2776 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2777 SysFreeString(str);
2778
2779 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2780 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2781 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2782 SysFreeString(str);
2783
2784 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2785 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2786 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2787 SysFreeString(str);
2788
2789 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2790 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2791 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2792 SysFreeString(str);
2793
2794 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2795 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2796 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2797 SysFreeString(str);
2798
2799 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2800 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2801 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2802 SysFreeString(str);
2803
2804 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2805 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2806 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2807 SysFreeString(str);
2808
2809 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2810 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2811 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2812 SysFreeString(str);
2813
2814 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2815 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2816 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2817 SysFreeString(str);
2818
2819 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2820 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2821 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2822 SysFreeString(str);
2823
2824 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2825 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2826 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2827 SysFreeString(str);
2828
2829 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2830 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2831 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2832 SysFreeString(str);
2833
2834 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2835 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2836 SysFreeString(str);
2837
2838 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2839 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2840 SysFreeString(str);
2841
2842 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2843 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2844 SysFreeString(str);
2845
2846 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2847 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2848 SysFreeString(str);
2849
2850 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2851 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2852 SysFreeString(str);
2853
2854 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2855 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2856 SysFreeString(str);
2857
2858 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2859 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2860 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2861 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2862 VariantClear(&v);
2863
2864 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2865 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2866 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2867 VariantClear(&v);
2868
2869 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2870 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2871 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2872 VariantClear(&v);
2873
2874 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2875 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2876 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2877 VariantClear(&v);
2878
2879 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2880 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2881 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2882 VariantClear(&v);
2883
2884 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2885 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2886 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2887 VariantClear(&v);
2888
2889 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2890 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2891 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2892 VariantClear(&v);
2893
2894 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2895 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2896 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2897 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2898 VariantClear(&v);
2899
2900 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2901 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2902 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2903 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2904 VariantClear(&v);
2905
2906 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2907 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2908 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2909 VariantClear(&v);
2910
2911 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2912 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2913 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2914 VariantClear(&v);
2915
2916 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2917 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2918 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2919 VariantClear(&v);
2920
2921 V_BSTR(&v) = NULL;
2922 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2923 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2924 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2925 VariantClear(&v);
2926
2927 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2928 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2929 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2930 VariantClear(&v);
2931
2932 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2933 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2934 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2935 VariantClear(&v);
2936
2937 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2938 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2939 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2940 VariantClear(&v);
2941
2942 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2943 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2944 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2945 VariantClear(&v);
2946
2947 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
2948 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
2949 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2950 VariantClear(&v);
2951
2952 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
2953 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
2954 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2955 VariantClear(&v);
2956
2957 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
2958 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
2959 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2960 VariantClear(&v);
2961
2962 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
2963 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
2964 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2965 VariantClear(&v);
2966
2967 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
2968 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
2969 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2970 VariantClear(&v);
2971
2972 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
2973 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2974 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2975 VariantClear(&v);
2976
2977 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
2978 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2979 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2980 VariantClear(&v);
2981
2982 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
2983 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
2984 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2985 VariantClear(&v);
2986
2987 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
2988 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
2989 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2990 VariantClear(&v);
2991
2992 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
2993 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
2994 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2995 VariantClear(&v);
2996
2997 hres = IHTMLCurrentStyle_get_right(current_style, &v);
2998 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
2999 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3000 VariantClear(&v);
3001
3002 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3003 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3004 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3005 VariantClear(&v);
3006
3007 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3008 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3009 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3010 VariantClear(&v);
3011
3012 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3013 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3014 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3015 VariantClear(&v);
3016 }
3017
3018 static void test_style2(IHTMLStyle2 *style2)
3019 {
3020 BSTR str;
3021 HRESULT hres;
3022
3023 str = (void*)0xdeadbeef;
3024 hres = IHTMLStyle2_get_position(style2, &str);
3025 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3026 ok(!str, "str != NULL\n");
3027
3028 str = a2bstr("absolute");
3029 hres = IHTMLStyle2_put_position(style2, str);
3030 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3031 SysFreeString(str);
3032
3033 str = NULL;
3034 hres = IHTMLStyle2_get_position(style2, &str);
3035 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3036 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3037 SysFreeString(str);
3038 }
3039
3040 static void test_style3(IHTMLStyle3 *style3)
3041 {
3042 BSTR str;
3043 HRESULT hres;
3044
3045 str = (void*)0xdeadbeef;
3046 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3047 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3048 ok(!str, "str != NULL\n");
3049
3050 str = a2bstr("break-word");
3051 hres = IHTMLStyle3_put_wordWrap(style3, str);
3052 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3053 SysFreeString(str);
3054
3055 str = NULL;
3056 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3057 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3058 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3059 SysFreeString(str);
3060 }
3061
3062 static void test_style4(IHTMLStyle4 *style4)
3063 {
3064 HRESULT hres;
3065 VARIANT v;
3066 VARIANT vdefault;
3067
3068 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3069 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3070
3071 V_VT(&v) = VT_BSTR;
3072 V_BSTR(&v) = a2bstr("10px");
3073 hres = IHTMLStyle4_put_minHeight(style4, v);
3074 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3075 VariantClear(&v);
3076
3077 hres = IHTMLStyle4_get_minHeight(style4, &v);
3078 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3079 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3080 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3081
3082 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3083 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3084 VariantClear(&vdefault);
3085 }
3086
3087 static void test_default_style(IHTMLStyle *style)
3088 {
3089 IHTMLStyle2 *style2;
3090 IHTMLStyle3 *style3;
3091 IHTMLStyle4 *style4;
3092 VARIANT_BOOL b;
3093 VARIANT v;
3094 BSTR str;
3095 HRESULT hres;
3096 float f;
3097 BSTR sOverflowDefault;
3098 BSTR sDefault;
3099 VARIANT vDefault;
3100
3101 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3102 test_ifaces((IUnknown*)style, style_iids);
3103
3104 test_style_csstext(style, NULL);
3105
3106 hres = IHTMLStyle_get_position(style, &str);
3107 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3108 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3109
3110 V_VT(&v) = VT_NULL;
3111 hres = IHTMLStyle_get_marginRight(style, &v);
3112 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3113 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3114 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3115
3116 V_VT(&v) = VT_NULL;
3117 hres = IHTMLStyle_get_marginLeft(style, &v);
3118 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3119 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3120 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3121
3122 str = (void*)0xdeadbeef;
3123 hres = IHTMLStyle_get_fontFamily(style, &str);
3124 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3125 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3126
3127 str = (void*)0xdeadbeef;
3128 hres = IHTMLStyle_get_fontWeight(style, &str);
3129 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3130 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3131
3132 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3133 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3134
3135 str = a2bstr("test");
3136 hres = IHTMLStyle_put_fontWeight(style, str);
3137 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3138 SysFreeString(str);
3139
3140 str = a2bstr("bold");
3141 hres = IHTMLStyle_put_fontWeight(style, str);
3142 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3143 SysFreeString(str);
3144
3145 str = a2bstr("bolder");
3146 hres = IHTMLStyle_put_fontWeight(style, str);
3147 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3148 SysFreeString(str);
3149
3150 str = a2bstr("lighter");
3151 hres = IHTMLStyle_put_fontWeight(style, str);
3152 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3153 SysFreeString(str);
3154
3155 str = a2bstr("100");
3156 hres = IHTMLStyle_put_fontWeight(style, str);
3157 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3158 SysFreeString(str);
3159
3160 str = a2bstr("200");
3161 hres = IHTMLStyle_put_fontWeight(style, str);
3162 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3163 SysFreeString(str);
3164
3165 str = a2bstr("300");
3166 hres = IHTMLStyle_put_fontWeight(style, str);
3167 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3168 SysFreeString(str);
3169
3170 str = a2bstr("400");
3171 hres = IHTMLStyle_put_fontWeight(style, str);
3172 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3173 SysFreeString(str);
3174
3175 str = a2bstr("500");
3176 hres = IHTMLStyle_put_fontWeight(style, str);
3177 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3178 SysFreeString(str);
3179
3180 str = a2bstr("600");
3181 hres = IHTMLStyle_put_fontWeight(style, str);
3182 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3183 SysFreeString(str);
3184
3185 str = a2bstr("700");
3186 hres = IHTMLStyle_put_fontWeight(style, str);
3187 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3188 SysFreeString(str);
3189
3190 str = a2bstr("800");
3191 hres = IHTMLStyle_put_fontWeight(style, str);
3192 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3193 SysFreeString(str);
3194
3195 str = a2bstr("900");
3196 hres = IHTMLStyle_put_fontWeight(style, str);
3197 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3198 SysFreeString(str);
3199
3200 hres = IHTMLStyle_get_fontWeight(style, &str);
3201 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3202 ok(!strcmp_wa(str, "900"), "str != style900\n");
3203 SysFreeString(str);
3204
3205 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3206 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3207 SysFreeString(sDefault);
3208
3209 /* font Variant */
3210 hres = IHTMLStyle_get_fontVariant(style, NULL);
3211 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3212
3213 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3214 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3215
3216 str = a2bstr("test");
3217 hres = IHTMLStyle_put_fontVariant(style, str);
3218 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3219 SysFreeString(str);
3220
3221 str = a2bstr("small-caps");
3222 hres = IHTMLStyle_put_fontVariant(style, str);
3223 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3224 SysFreeString(str);
3225
3226 str = a2bstr("normal");
3227 hres = IHTMLStyle_put_fontVariant(style, str);
3228 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3229 SysFreeString(str);
3230
3231 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3232 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3233 SysFreeString(sDefault);
3234
3235 str = (void*)0xdeadbeef;
3236 hres = IHTMLStyle_get_display(style, &str);
3237 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3238 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3239
3240 str = (void*)0xdeadbeef;
3241 hres = IHTMLStyle_get_visibility(style, &str);
3242 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3243 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3244
3245 V_VT(&v) = VT_NULL;
3246 hres = IHTMLStyle_get_fontSize(style, &v);
3247 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3248 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));