2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <wine/test.h>
31 static void test_HTMLLoadOptions(void)
33 IHtmlLoadOptions
*loadopts
;
35 DWORD size
, i
, data
= 0xdeadbeef;
38 hres
= CoCreateInstance(&CLSID_HTMLLoadOptions
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
39 &IID_IHtmlLoadOptions
, (void**)&loadopts
);
40 ok(hres
== S_OK
, "creating HTMLLoadOptions failed: %08lx\n", hres
);
44 for(i
=0; i
<= HTMLLOADOPTION_FRAMELOAD
+3; i
++) {
46 memset(buf
, 0xdd, sizeof(buf
));
47 hres
= IHtmlLoadOptions_QueryOption(loadopts
, i
, NULL
, &size
);
48 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
49 ok(size
== 0, "size = %ld\n", size
);
50 ok(buf
[0] == 0xdd, "buf changed\n");
54 hres
= IHtmlLoadOptions_QueryOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, NULL
, &size
);
55 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
56 ok(size
== 0, "size = %ld\n", size
);
58 hres
= IHtmlLoadOptions_SetOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, &data
, sizeof(data
));
59 ok(hres
== S_OK
, "SetOption failed: %08lx\n", hres
);
62 memset(buf
, 0xdd, sizeof(buf
));
63 hres
= IHtmlLoadOptions_QueryOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, buf
, &size
);
64 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
65 ok(size
== sizeof(data
), "size = %ld\n", size
);
66 ok(*(DWORD
*)buf
== data
, "unexpected buf\n");
68 size
= sizeof(data
)-1;
69 memset(buf
, 0xdd, sizeof(buf
));
70 hres
= IHtmlLoadOptions_QueryOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, buf
, &size
);
71 ok(hres
== E_FAIL
, "QueryOption failed: %08lx\n", hres
);
72 ok(size
== sizeof(data
) || !size
, "size = %ld\n", size
);
73 ok(buf
[0] == 0xdd, "buf changed\n");
76 hres
= IHtmlLoadOptions_SetOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, &data
, 0);
77 ok(hres
== S_OK
, "SetOption failed: %08lx\n", hres
);
80 memset(buf
, 0xdd, sizeof(buf
));
81 hres
= IHtmlLoadOptions_QueryOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, buf
, &size
);
82 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
83 ok(size
== 0, "size = %ld\n", size
);
84 ok(buf
[0] == 0xdd, "buf changed\n");
86 hres
= IHtmlLoadOptions_SetOption(loadopts
, HTMLLOADOPTION_CODEPAGE
, NULL
, 0);
87 ok(hres
== S_OK
, "SetOption failed: %08lx\n", hres
);
89 hres
= IHtmlLoadOptions_SetOption(loadopts
, 1000, &data
, sizeof(data
));
90 ok(hres
== S_OK
, "SetOption failed: %08lx\n", hres
);
93 memset(buf
, 0xdd, sizeof(buf
));
94 hres
= IHtmlLoadOptions_QueryOption(loadopts
, 1000, buf
, &size
);
95 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
96 ok(size
== sizeof(data
), "size = %ld\n", size
);
97 ok(*(DWORD
*)buf
== data
, "unexpected buf\n");
99 hres
= IHtmlLoadOptions_SetOption(loadopts
, 1000, buf
, sizeof(buf
));
100 ok(hres
== S_OK
, "SetOption failed: %08lx\n", hres
);
103 hres
= IHtmlLoadOptions_QueryOption(loadopts
, 1000, buf
, &size
);
104 ok(hres
== S_OK
, "QueryOption failed: %08lx\n", hres
);
105 ok(size
== sizeof(buf
), "size = %ld\n", size
);
107 IHtmlLoadOptions_Release(loadopts
);
110 static IHTMLDocument2
*create_doc_from_url(const WCHAR
*start_url
)
115 IPersistMoniker
*persist_mon
;
119 hres
= CreateBindCtx(0, &bc
);
120 ok(hres
== S_OK
, "CreateBindCtx failed: 0x%08lx\n", hres
);
122 url
= SysAllocString(start_url
);
123 hres
= CreateURLMoniker(NULL
, url
, &url_mon
);
124 ok(hres
== S_OK
, "CreateURLMoniker failed: 0x%08lx\n", hres
);
126 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
,
127 CLSCTX_INPROC_SERVER
| CLSCTX_INPROC_HANDLER
, &IID_IHTMLDocument2
,
129 ok(hres
== S_OK
, "CoCreateInstance failed: 0x%08lx\n", hres
);
131 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistMoniker
,
132 (void**)&persist_mon
);
133 ok(hres
== S_OK
, "IHTMLDocument2_QueryInterface failed: 0x%08lx\n", hres
);
135 hres
= IPersistMoniker_Load(persist_mon
, FALSE
, url_mon
, bc
,
136 STGM_SHARE_EXCLUSIVE
| STGM_READWRITE
);
137 ok(hres
== S_OK
, "IPersistMoniker_Load failed: 0x%08lx\n", hres
);
139 IPersistMoniker_Release(persist_mon
);
140 IMoniker_Release(url_mon
);
141 IBindCtx_Release(bc
);
146 static HRESULT
get_localstorage(IHTMLDocument2
*doc
, IHTMLStorage
**storage
)
148 IHTMLWindow2
*window
;
149 IHTMLWindow6
*window6
;
152 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
153 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
154 ok(window
!= NULL
, "window == NULL\n");
156 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow6
, (void**)&window6
);
157 IHTMLWindow2_Release(window
);
159 win_skip("IHTMLWindow6 not supported\n");
163 hres
= IHTMLWindow6_get_localStorage(window6
, storage
);
164 ok(hres
== S_OK
, "get_localStorage failed: %08lx\n", hres
);
165 ok(*storage
!= NULL
, "*storage == NULL\n");
167 IHTMLWindow6_Release(window6
);
171 static HRESULT
get_sessionstorage(IHTMLDocument2
*doc
, IHTMLStorage
**storage
)
173 IHTMLWindow2
*window
;
174 IHTMLWindow6
*window6
;
177 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
178 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
179 ok(window
!= NULL
, "window == NULL\n");
181 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow6
, (void**)&window6
);
182 IHTMLWindow2_Release(window
);
184 win_skip("IHTMLWindow6 not supported\n");
188 hres
= IHTMLWindow6_get_sessionStorage(window6
, storage
);
189 ok(hres
== S_OK
, "get_sessionStorage failed: %08lx\n", hres
);
190 ok(*storage
!= NULL
, "*storage == NULL\n");
192 IHTMLWindow6_Release(window6
);
196 static void test_HTMLStorage(void)
198 IHTMLDocument2
*doc
, *doc2
;
199 IHTMLStorage
*storage
, *storage2
;
200 LONG space
, length
, lval
;
205 doc
= create_doc_from_url(L
"http://www.codeweavers.com/");
206 doc2
= create_doc_from_url(L
"http://www.codeweavers.com/");
208 hres
= get_localstorage(doc
, &storage
);
209 ok(hres
== S_OK
, "got %08lx\n", hres
);
211 hres
= get_localstorage(doc2
, &storage2
);
212 ok(hres
== S_OK
, "got %08lx\n", hres
);
214 key
= SysAllocString(L
"");
216 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
217 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
218 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
220 key
= SysAllocString(L
"undefined");
221 hres
= IHTMLStorage_removeItem(storage
, key
);
222 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
224 hres
= IHTMLStorage_get_length(storage
, &length
);
225 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
226 ok(length
>= 0, "length = %ld\n", lval
);
228 value
= SysAllocString(L
"null");
229 hres
= IHTMLStorage_setItem(storage
, key
, value
);
230 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
233 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
234 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
235 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
236 if (V_VT(&var
) == VT_BSTR
) ok(!wcscmp(V_BSTR(&var
), L
"null"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
239 hres
= IHTMLStorage_key(storage
, 0, &key
);
240 ok(hres
== S_OK
, "key failed %08lx\n", hres
);
241 ok(!wcscmp(key
, L
"undefined"), "key(0) = %s\n", wine_dbgstr_w(key
));
244 hres
= IHTMLStorage_key(storage
, 1, &key
);
245 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
246 hres
= IHTMLStorage_key(storage
, -1, &key
);
247 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
249 key
= SysAllocString(L
"undefined");
250 hres
= IHTMLStorage_removeItem(storage
, key
);
251 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
253 SysFreeString(value
);
255 key
= SysAllocString(L
"winetest");
256 value
= SysAllocString(L
"winetest");
257 hres
= IHTMLStorage_setItem(storage
, key
, value
);
258 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
260 /* retrieve value from different storage instance */
262 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
263 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
264 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
265 if (V_VT(&var
) == VT_BSTR
) ok(!wcscmp(V_BSTR(&var
), L
"winetest"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
267 hres
= IHTMLStorage_removeItem(storage
, key
);
268 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
271 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
272 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
273 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
275 SysFreeString(value
);
277 /* item doesn't exist */
278 key
= SysAllocString(L
"nosuch");
279 hres
= IHTMLStorage_removeItem(storage
, key
);
280 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
283 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
284 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
285 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
287 hres
= IHTMLStorage_getItem(storage
, NULL
, NULL
);
288 ok(hres
== E_POINTER
, "getItem returned: %08lx\n", hres
);
290 hres
= IHTMLStorage_getItem(storage
, key
, NULL
);
291 ok(hres
== E_POINTER
, "getItem failed: %08lx\n", hres
);
295 hres
= IHTMLStorage_getItem(storage
, NULL
, &var
);
296 ok(hres
== S_OK
, "getItem returned: %08lx\n", hres
);
297 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
299 hres
= IHTMLStorage_setItem(storage
, NULL
, NULL
);
300 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
302 key
= SysAllocString(L
"winetest2");
303 hres
= IHTMLStorage_setItem(storage
, key
, NULL
);
304 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
306 hres
= IHTMLStorage_setItem(storage
, NULL
, key
);
307 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
309 hres
= IHTMLStorage_removeItem(storage
, key
);
310 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
313 hres
= IHTMLStorage_removeItem(storage
, NULL
);
314 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
316 /* Unicode characters */
317 key
= SysAllocString(L
"winetest");
318 value
= SysAllocString(L
"\x20ac");
319 hres
= IHTMLStorage_setItem(storage
, key
, value
);
320 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
321 hres
= IHTMLStorage_removeItem(storage
, key
);
322 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
323 SysFreeString(value
);
326 key
= SysAllocString(L
"\x20ac");
327 value
= SysAllocString(L
"winetest");
328 hres
= IHTMLStorage_setItem(storage
, key
, value
);
329 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
330 hres
= IHTMLStorage_removeItem(storage
, key
);
331 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
332 SysFreeString(value
);
335 IHTMLStorage_Release(storage
);
336 IHTMLStorage_Release(storage2
);
338 /* Session storage on same docs */
339 hres
= get_sessionstorage(doc
, &storage
);
340 ok(hres
== S_OK
, "got %08lx\n", hres
);
342 hres
= get_sessionstorage(doc2
, &storage2
);
343 ok(hres
== S_OK
, "got %08lx\n", hres
);
345 hres
= IHTMLStorage_get_length(storage
, &lval
);
346 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
347 ok(lval
== 0, "length = %ld\n", lval
);
349 hres
= IHTMLStorage_get_remainingSpace(storage
, &space
);
350 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
351 ok(space
>= 5000000, "remainingSpace = %ld\n", space
);
353 key
= SysAllocString(L
"");
355 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
356 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
357 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
360 key
= SysAllocString(L
"undefined");
361 hres
= IHTMLStorage_removeItem(storage
, key
);
362 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
364 value
= SysAllocString(L
"null");
365 hres
= IHTMLStorage_setItem(storage
, key
, value
);
366 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
367 SysFreeString(value
);
369 hres
= IHTMLStorage_get_length(storage
, &lval
);
370 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
371 ok(lval
== 1, "length = %ld\n", lval
);
372 hres
= IHTMLStorage_get_length(storage2
, &lval
);
373 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
374 ok(lval
== 1, "length = %ld\n", lval
);
376 hres
= IHTMLStorage_get_remainingSpace(storage
, &lval
);
377 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
378 ok(lval
== space
- 13, "remainingSpace = %ld\n", lval
);
379 hres
= IHTMLStorage_get_remainingSpace(storage2
, &lval
);
380 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
381 ok(lval
== space
- 13, "remainingSpace = %ld\n", lval
);
384 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
385 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
386 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
387 ok(!wcscmp(V_BSTR(&var
), L
"null"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
391 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
392 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
393 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
394 ok(!wcscmp(V_BSTR(&var
), L
"null"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
398 value
= SysAllocString(L
"asdf");
399 hres
= IHTMLStorage_setItem(storage
, NULL
, value
);
400 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
401 SysFreeString(value
);
404 hres
= IHTMLStorage_getItem(storage2
, NULL
, &var
);
405 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
406 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
407 ok(!wcscmp(V_BSTR(&var
), L
"asdf"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
411 key
= SysAllocString(L
"");
412 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
413 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
414 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
415 ok(!wcscmp(V_BSTR(&var
), L
"asdf"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
419 key
= SysAllocString(L
"null-value");
420 hres
= IHTMLStorage_setItem(storage
, key
, NULL
);
421 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
424 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
425 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
426 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
427 ok(!wcscmp(V_BSTR(&var
), L
""), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
430 hres
= IHTMLStorage_removeItem(storage
, NULL
);
431 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
432 hres
= IHTMLStorage_removeItem(storage2
, key
);
433 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
436 key
= SysAllocString(L
"aaaa");
437 value
= SysAllocString(L
"bbbb");
438 hres
= IHTMLStorage_setItem(storage2
, key
, value
);
439 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
440 SysFreeString(value
);
443 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
444 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
445 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
446 ok(!wcscmp(V_BSTR(&var
), L
"bbbb"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
450 hres
= IHTMLStorage_get_length(storage
, &lval
);
451 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
452 ok(lval
== 2, "length = %ld\n", lval
);
453 hres
= IHTMLStorage_get_length(storage2
, &lval
);
454 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
455 ok(lval
== 2, "length = %ld\n", lval
);
457 hres
= IHTMLStorage_get_remainingSpace(storage
, &lval
);
458 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
459 ok(lval
== space
- 21, "remainingSpace = %ld\n", lval
);
460 hres
= IHTMLStorage_get_remainingSpace(storage2
, &lval
);
461 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
462 ok(lval
== space
- 21, "remainingSpace = %ld\n", lval
);
464 hres
= IHTMLStorage_key(storage
, 0, &key
);
465 ok(hres
== S_OK
, "key failed %08lx\n", hres
);
466 ok(!wcscmp(key
, L
"undefined"), "key(0) = %s\n", wine_dbgstr_w(key
));
469 hres
= IHTMLStorage_key(storage
, 1, &key
);
470 ok(hres
== S_OK
, "key failed %08lx\n", hres
);
471 ok(!wcscmp(key
, L
"aaaa"), "key(0) = %s\n", wine_dbgstr_w(key
));
474 hres
= IHTMLStorage_key(storage
, 2, &key
);
475 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
476 hres
= IHTMLStorage_key(storage
, -1, &key
);
477 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
479 key
= SysAllocString(L
"undefined");
480 hres
= IHTMLStorage_removeItem(storage2
, key
);
481 ok(hres
== S_OK
, "removeItem failed: %08lx\n", hres
);
484 hres
= IHTMLStorage_key(storage
, 0, &key
);
485 ok(hres
== S_OK
, "key failed %08lx\n", hres
);
486 ok(!wcscmp(key
, L
"aaaa"), "key(0) = %s\n", wine_dbgstr_w(key
));
489 hres
= IHTMLStorage_key(storage
, 1, &key
);
490 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
493 key
= SysAllocString(L
"undefined");
494 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
495 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
496 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
499 hres
= IHTMLStorage_clear(storage2
);
500 ok(hres
== S_OK
, "clear failed %08lx\n", hres
);
502 hres
= IHTMLStorage_get_length(storage
, &lval
);
503 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
504 ok(lval
== 0, "length = %ld\n", lval
);
505 hres
= IHTMLStorage_get_length(storage2
, &lval
);
506 ok(hres
== S_OK
, "get_length failed %08lx\n", hres
);
507 ok(lval
== 0, "length = %ld\n", lval
);
509 hres
= IHTMLStorage_get_remainingSpace(storage
, &lval
);
510 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
511 ok(lval
== space
, "remainingSpace = %ld\n", lval
);
512 hres
= IHTMLStorage_get_remainingSpace(storage2
, &lval
);
513 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
514 ok(lval
== space
, "remainingSpace = %ld\n", lval
);
516 hres
= IHTMLStorage_key(storage
, 0, &key
);
517 ok(hres
== E_INVALIDARG
, "key failed %08lx\n", hres
);
519 key
= SysAllocString(L
"foo");
520 value
= SysAllocString(L
"bar");
521 hres
= IHTMLStorage_setItem(storage
, key
, value
);
522 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
524 IHTMLStorage_Release(storage2
);
525 IHTMLDocument2_Release(doc2
);
527 /* Case insensitive domain */
528 doc2
= create_doc_from_url(L
"htTp://www.CodeWeavers.com/");
529 hres
= get_sessionstorage(doc2
, &storage2
);
530 ok(hres
== S_OK
, "got %08lx\n", hres
);
533 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
534 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
535 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
536 ok(!wcscmp(V_BSTR(&var
), L
"bar"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
539 IHTMLStorage_Release(storage2
);
540 IHTMLDocument2_Release(doc2
);
542 /* Different schemes */
543 doc2
= create_doc_from_url(L
"https://www.codeweavers.com/");
544 hres
= get_sessionstorage(doc2
, &storage2
);
545 ok(hres
== S_OK
, "got %08lx\n", hres
);
548 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
549 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
550 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
551 ok(!wcscmp(V_BSTR(&var
), L
"bar"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
554 hres
= IHTMLStorage_get_remainingSpace(storage
, &lval
);
555 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
556 ok(lval
== space
- 6, "remainingSpace = %ld\n", lval
);
558 IHTMLStorage_Release(storage2
);
559 IHTMLDocument2_Release(doc2
);
561 doc2
= create_doc_from_url(L
"ftp://www.codeweavers.com/");
562 hres
= get_sessionstorage(doc2
, &storage2
);
563 ok(hres
== S_OK
, "got %08lx\n", hres
);
566 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
567 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
568 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
570 hres
= IHTMLStorage_get_remainingSpace(storage2
, &lval
);
571 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
572 ok(lval
== space
, "remainingSpace = %ld\n", lval
);
574 hres
= IHTMLStorage_setItem(storage2
, key
, value
);
575 ok(hres
== S_OK
, "setItem failed: %08lx\n", hres
);
578 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
579 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
580 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
581 ok(!wcscmp(V_BSTR(&var
), L
"bar"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
584 hres
= IHTMLStorage_clear(storage2
);
585 ok(hres
== S_OK
, "clear failed %08lx\n", hres
);
587 IHTMLStorage_Release(storage2
);
588 IHTMLDocument2_Release(doc2
);
590 /* Different domain */
591 doc2
= create_doc_from_url(L
"https://www.winehq.org/");
592 hres
= get_sessionstorage(doc2
, &storage2
);
593 ok(hres
== S_OK
, "got %08lx\n", hres
);
596 hres
= IHTMLStorage_getItem(storage
, key
, &var
);
597 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
598 ok(V_VT(&var
) == VT_BSTR
, "got %d\n", V_VT(&var
));
599 ok(!wcscmp(V_BSTR(&var
), L
"bar"), "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
602 hres
= IHTMLStorage_getItem(storage2
, key
, &var
);
603 ok(hres
== S_OK
, "getItem failed: %08lx\n", hres
);
604 ok(V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
606 hres
= IHTMLStorage_get_remainingSpace(storage2
, &lval
);
607 ok(hres
== S_OK
, "get_remainingSpace failed %08lx\n", hres
);
608 ok(lval
== space
, "remainingSpace = %ld\n", lval
);
610 hres
= IHTMLStorage_clear(storage
);
611 ok(hres
== S_OK
, "clear failed %08lx\n", hres
);
613 IHTMLStorage_Release(storage2
);
614 IHTMLStorage_Release(storage
);
615 IHTMLDocument2_Release(doc2
);
616 IHTMLDocument2_Release(doc
);
617 SysFreeString(value
);
625 test_HTMLLoadOptions();