From 8cd730631bad452f2180926ed7061f29215ebfd2 Mon Sep 17 00:00:00 2001 From: Zhenbo Li Date: Sat, 18 Oct 2014 11:52:47 +0800 Subject: [PATCH] Add partially support for sessionStorage --- README.md | 3 +- patches/Makefile | 19 ++ ...html-Added-nsIDOMStorage-declaration.patch | 49 +++++ ...ate_storage-and-IHTMLStorage-Release.patch | 152 ++++++++++++++ ...MLStorage-getItem-setItem-methods-im.patch | 189 ++++++++++++++++++ patches/mshtml-sessionStorage/definition | 5 + 6 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 patches/mshtml-sessionStorage/0001-mshtml-Added-nsIDOMStorage-declaration.patch create mode 100644 patches/mshtml-sessionStorage/0002-mshtml-Fixed-create_storage-and-IHTMLStorage-Release.patch create mode 100644 patches/mshtml-sessionStorage/0003-mshtml-Added-IHTMLStorage-getItem-setItem-methods-im.patch create mode 100644 patches/mshtml-sessionStorage/definition diff --git a/README.md b/README.md index b1c5334d..e8d4a2ae 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,9 @@ Wine. All those differences are also documented on the Included bugfixes and improvements ================================== -**Bugfixes and features included in the next upcoming release [6]:** +**Bugfixes and features included in the next upcoming release [7]:** +* Add partially support for sessionStorage * Anno 1602 installer depends on Windows 98 behavior of SHFileOperationW * FEAR 1 installer expects basic_string_wchar_dtor to return NULL ([Wine Bug #37358](http://bugs.winehq.org/show_bug.cgi?id=37358)) * Support for D3DXGetShaderInputSemantics ([Wine Bug #22682](http://bugs.winehq.org/show_bug.cgi?id=22682)) diff --git a/patches/Makefile b/patches/Makefile index 9a2a6b05..c4800c37 100644 --- a/patches/Makefile +++ b/patches/Makefile @@ -40,6 +40,7 @@ PATCHLIST := \ kernel32-Named_Pipe.ok \ kernel32-UTF7_Support.ok \ libs-Unicode_Collation.ok \ + mshtml-sessionStorage.ok \ msvcp90-basic_string_wchar_dtor.ok \ ntdll-ATL_Thunk.ok \ ntdll-DOS_Attributes.ok \ @@ -560,6 +561,24 @@ libs-Unicode_Collation.ok: echo '+ { "libs-Unicode_Collation", "Dmitry Timoshkov", "Fix comparison of punctuation characters." },'; \ ) > libs-Unicode_Collation.ok +# Patchset mshtml-sessionStorage +# | +# | Included patches: +# | * Implement sessionStorage(partially). [by Zhenbo Li] +# | +# | Modified files: +# | * dlls/mshtml/htmlstorage.c, dlls/mshtml/htmlwindow.c, dlls/mshtml/mshtml_private.h, dlls/mshtml/nsiface.idl, +# | dlls/mshtml/tests/htmldoc.c +# | +.INTERMEDIATE: mshtml-sessionStorage.ok +mshtml-sessionStorage.ok: + $(call APPLY_FILE,mshtml-sessionStorage/0001-mshtml-Added-nsIDOMStorage-declaration.patch) + $(call APPLY_FILE,mshtml-sessionStorage/0002-mshtml-Fixed-create_storage-and-IHTMLStorage-Release.patch) + $(call APPLY_FILE,mshtml-sessionStorage/0003-mshtml-Added-IHTMLStorage-getItem-setItem-methods-im.patch) + @( \ + echo '+ { "mshtml-sessionStorage", "Zhenbo Li", "Implement sessionStorage(partially)." },'; \ + ) > mshtml-sessionStorage.ok + # Patchset msvcp90-basic_string_wchar_dtor # | # | Included patches: diff --git a/patches/mshtml-sessionStorage/0001-mshtml-Added-nsIDOMStorage-declaration.patch b/patches/mshtml-sessionStorage/0001-mshtml-Added-nsIDOMStorage-declaration.patch new file mode 100644 index 00000000..6d124822 --- /dev/null +++ b/patches/mshtml-sessionStorage/0001-mshtml-Added-nsIDOMStorage-declaration.patch @@ -0,0 +1,49 @@ +From de10d96b512a279fcd24e402ad5249680c6c5970 Mon Sep 17 00:00:00 2001 +From: Zhenbo Li +Date: Sat, 23 Aug 2014 21:25:19 +0800 +Subject: [PATCH 1/3] mshtml: Added nsIDOMStorage declaration. +To: wine-patches@winehq.org +Reply-To: wine-devel@winehq.org +CC: litimetal@gmail.com + +--- + dlls/mshtml/nsiface.idl | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl +index a5275e7..d2bfd8c 100644 +--- a/dlls/mshtml/nsiface.idl ++++ b/dlls/mshtml/nsiface.idl +@@ -155,7 +155,6 @@ typedef nsISupports nsIContentViewer; + typedef nsISupports nsIDocumentCharsetInfo; + typedef nsISupports nsILayoutHistoryState; + typedef nsISupports nsISecureBrowserUI; +-typedef nsISupports nsIDOMStorage; + typedef nsISupports nsIDOMDOMTokenList; + typedef nsISupports nsITransferable; + typedef nsISupports nsIDOMFileList; +@@ -1360,6 +1359,21 @@ interface nsIDOMWindowCollection : nsISupports + + [ + object, ++ uuid(43e5edad-1e02-42c4-9d99-c3d9dee22a20), ++ local ++] ++interface nsIDOMStorage : nsISupports ++{ ++ nsresult GetLength(uint32_t *aLength); ++ nsresult Key(uint32_t index, nsAString *_retval); ++ nsresult GetItem(const nsAString *key, nsAString *_retval); ++ nsresult SetItem(const nsAString *key, const nsAString *data); ++ nsresult RemoveItem(const nsAString *key); ++ nsresult Clear(); ++}; ++ ++[ ++ object, + uuid(be62660a-e3f6-409c-a4a9-378364a9526f), + local + ] +-- +1.9.3 + diff --git a/patches/mshtml-sessionStorage/0002-mshtml-Fixed-create_storage-and-IHTMLStorage-Release.patch b/patches/mshtml-sessionStorage/0002-mshtml-Fixed-create_storage-and-IHTMLStorage-Release.patch new file mode 100644 index 00000000..ba34532a --- /dev/null +++ b/patches/mshtml-sessionStorage/0002-mshtml-Fixed-create_storage-and-IHTMLStorage-Release.patch @@ -0,0 +1,152 @@ +From 9bff529406fa08caff24dc208f4e0506f0952d0f Mon Sep 17 00:00:00 2001 +From: Zhenbo Li +Date: Thu, 4 Sep 2014 21:08:57 +0800 +Subject: [PATCH 2/3] mshtml: Fixed create_storage() and + IHTMLStorage::Release(). +To: wine-patches@winehq.org +Reply-To: wine-devel@winehq.org +CC: litimetal@gmail.com + +--- + dlls/mshtml/htmlstorage.c | 7 ++++++- + dlls/mshtml/htmlwindow.c | 12 ++++++++++-- + dlls/mshtml/mshtml_private.h | 2 +- + dlls/mshtml/tests/htmldoc.c | 37 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 54 insertions(+), 4 deletions(-) + +diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c +index 60a2a3a..2d391f8 100644 +--- a/dlls/mshtml/htmlstorage.c ++++ b/dlls/mshtml/htmlstorage.c +@@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + typedef struct { + DispatchEx dispex; + IHTMLStorage IHTMLStorage_iface; ++ nsIDOMStorage *nsstorage; + LONG ref; + } HTMLStorage; + +@@ -82,6 +83,8 @@ static ULONG WINAPI HTMLStorage_Release(IHTMLStorage *iface) + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) { ++ if (This->nsstorage) ++ nsIDOMStorage_Release(This->nsstorage); + release_dispex(&This->dispex); + heap_free(This); + } +@@ -198,7 +201,7 @@ static dispex_static_data_t HTMLStorage_dispex = { + HTMLStorage_iface_tids + }; + +-HRESULT create_storage(IHTMLStorage **p) ++HRESULT create_storage(nsIDOMStorage *nsstorage, IHTMLStorage **p) + { + HTMLStorage *storage; + +@@ -211,5 +214,7 @@ HRESULT create_storage(IHTMLStorage **p) + init_dispex(&storage->dispex, (IUnknown*)&storage->IHTMLStorage_iface, &HTMLStorage_dispex); + + *p = &storage->IHTMLStorage_iface; ++ storage->nsstorage = nsstorage; ++ nsIDOMStorage_AddRef(nsstorage); + return S_OK; + } +diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c +index 6c6c328..a26cf4e 100644 +--- a/dlls/mshtml/htmlwindow.c ++++ b/dlls/mshtml/htmlwindow.c +@@ -2018,12 +2018,20 @@ static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLS + { + HTMLWindow *This = impl_from_IHTMLWindow6(iface); + +- FIXME("(%p)->(%p)\n", This, p); ++ TRACE("(%p)->(%p)\n", This, p); + + if(!This->inner_window->session_storage) { + HRESULT hres; ++ nsresult nsres; ++ nsIDOMStorage *nsstorage; + +- hres = create_storage(&This->inner_window->session_storage); ++ nsres = nsIDOMWindow_GetSessionStorage(This->outer_window->nswindow, &nsstorage); ++ if (NS_FAILED(nsres)) { ++ ERR("GetSessionStorage failed: %08x\n", nsres); ++ return E_FAIL; ++ } ++ hres = create_storage(nsstorage, &This->inner_window->session_storage); ++ nsIDOMStorage_Release(nsstorage); + if(FAILED(hres)) + return hres; + } +diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h +index b69fd26..b118177 100644 +--- a/dlls/mshtml/mshtml_private.h ++++ b/dlls/mshtml/mshtml_private.h +@@ -767,7 +767,7 @@ HRESULT HTMLScreen_Create(IHTMLScreen**) DECLSPEC_HIDDEN; + HRESULT create_history(HTMLInnerWindow*,OmHistory**) DECLSPEC_HIDDEN; + HRESULT create_dom_implementation(IHTMLDOMImplementation**) DECLSPEC_HIDDEN; + +-HRESULT create_storage(IHTMLStorage**) DECLSPEC_HIDDEN; ++HRESULT create_storage(nsIDOMStorage*,IHTMLStorage**) DECLSPEC_HIDDEN; + + void HTMLDocument_Persist_Init(HTMLDocument*) DECLSPEC_HIDDEN; + void HTMLDocument_OleCmd_Init(HTMLDocument*) DECLSPEC_HIDDEN; +diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c +index 84b8806..d79f4b5 100644 +--- a/dlls/mshtml/tests/htmldoc.c ++++ b/dlls/mshtml/tests/htmldoc.c +@@ -7431,6 +7431,42 @@ static void test_QueryInterface(IHTMLDocument2 *htmldoc) + IUnknown_Release(qi); + } + ++static void test_sessionStorage(IHTMLWindow6 *window) ++{ ++ HRESULT hres; ++ IHTMLStorage *storage; ++ ++ hres = IHTMLWindow6_get_sessionStorage(window, &storage); ++ ok(hres == S_OK, "get_sessionStorage failed: %08x\n", hres); ++ ok(storage != NULL, "storage == NULL\n"); ++ if(hres != S_OK || storage == NULL) ++ return; ++ ++ IHTMLStorage_Release(storage); ++} ++ ++static void test_Storage(IHTMLDocument2 *doc) ++{ ++ IHTMLWindow2 *win2; ++ IHTMLWindow6 *win6; ++ HRESULT hres; ++ ++ trace("Testing HTMLStorage\n"); ++ ++ hres = IHTMLDocument2_get_parentWindow(doc, &win2); ++ ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres); ++ ++ hres = IHTMLWindow2_QueryInterface(win2, &IID_IHTMLWindow6, (void**)&win6); ++ if(hres == S_OK) { ++ test_sessionStorage(win6); ++ IHTMLWindow6_Release(win6); ++ }else { ++ win_skip("IHTMLWindow6 not support: %08x\n", hres); ++ } ++ ++ IHTMLWindow2_Release(win2); ++} ++ + static void init_test(enum load_state_t ls) { + doc_unk = NULL; + doc_hwnd = last_hwnd = NULL; +@@ -7687,6 +7723,7 @@ static void test_HTMLDocument_http(BOOL with_wbapp) + nav_url = nav_serv_url = "http://test.winehq.org/tests/winehq_snapshot/"; /* for valid prev nav_url */ + if(support_wbapp) { + test_put_href(doc, FALSE, "#test", "http://test.winehq.org/tests/winehq_snapshot/#test", FALSE, TRUE, 0); ++ test_Storage(doc); + test_travellog(doc); + test_refresh(doc); + } +-- +1.9.3 + diff --git a/patches/mshtml-sessionStorage/0003-mshtml-Added-IHTMLStorage-getItem-setItem-methods-im.patch b/patches/mshtml-sessionStorage/0003-mshtml-Added-IHTMLStorage-getItem-setItem-methods-im.patch new file mode 100644 index 00000000..4d2fafa0 --- /dev/null +++ b/patches/mshtml-sessionStorage/0003-mshtml-Added-IHTMLStorage-getItem-setItem-methods-im.patch @@ -0,0 +1,189 @@ +From 0f801caf1a0f94eb13198afda3ef1f484e1fac19 Mon Sep 17 00:00:00 2001 +From: Zhenbo Li +Date: Tue, 26 Aug 2014 23:02:38 +0800 +Subject: [PATCH 3/3] mshtml: Added IHTMLStorage:: getItem/setItem methods + implementation. +To: wine-patches@winehq.org +Reply-To: wine-devel@winehq.org +CC: litimetal@gmail.com + +--- + dlls/mshtml/htmlstorage.c | 50 ++++++++++++++++++++++++++++++--- + dlls/mshtml/tests/htmldoc.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 113 insertions(+), 4 deletions(-) + +diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c +index 2d391f8..b46c474 100644 +--- a/dlls/mshtml/htmlstorage.c ++++ b/dlls/mshtml/htmlstorage.c +@@ -148,15 +148,57 @@ static HRESULT WINAPI HTMLStorage_key(IHTMLStorage *iface, LONG lIndex, BSTR *p) + static HRESULT WINAPI HTMLStorage_getItem(IHTMLStorage *iface, BSTR bstrKey, VARIANT *p) + { + HTMLStorage *This = impl_from_IHTMLStorage(iface); +- FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrKey), p); +- return E_NOTIMPL; ++ nsAString key, value; ++ const PRUnichar *pval; ++ nsresult nsres; ++ ++ TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrKey), p); ++ ++ nsAString_InitDepend(&key, bstrKey); ++ nsAString_Init(&value, NULL); ++ ++ nsres = nsIDOMStorage_GetItem(This->nsstorage, &key, &value); ++ nsAString_Finish(&key); ++ if (NS_FAILED(nsres)) { ++ ERR("GetItem failed: %08x\n", nsres); ++ V_VT(p) = VT_NULL; ++ nsAString_Finish(&value); ++ return E_FAIL; ++ } ++ ++ nsAString_GetData(&value, &pval); ++ if(*pval) { ++ V_VT(p) = VT_BSTR; ++ V_BSTR(p) = SysAllocString(pval); ++ }else { ++ V_VT(p) = VT_NULL; ++ } ++ nsAString_Finish(&value); ++ ++ return S_OK; + } + + static HRESULT WINAPI HTMLStorage_setItem(IHTMLStorage *iface, BSTR bstrKey, BSTR bstrValue) + { + HTMLStorage *This = impl_from_IHTMLStorage(iface); +- FIXME("(%p)->(%s %s)\n", This, debugstr_w(bstrKey), debugstr_w(bstrValue)); +- return E_NOTIMPL; ++ nsAString key, value; ++ nsresult nsres; ++ ++ TRACE("(%p)->(%s %s)\n", This, debugstr_w(bstrKey), debugstr_w(bstrValue)); ++ ++ nsAString_InitDepend(&key, bstrKey); ++ nsAString_InitDepend(&value, bstrValue); ++ ++ nsres = nsIDOMStorage_SetItem(This->nsstorage, &key, &value); ++ nsAString_Finish(&key); ++ nsAString_Finish(&value); ++ ++ if (NS_FAILED(nsres)) { ++ ERR("SetItem failed: %08x\n", nsres); ++ return E_FAIL; ++ } ++ ++ return S_OK; + } + + static HRESULT WINAPI HTMLStorage_removeItem(IHTMLStorage *iface, BSTR bstrKey) +diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c +index d79f4b5..45accdb 100644 +--- a/dlls/mshtml/tests/htmldoc.c ++++ b/dlls/mshtml/tests/htmldoc.c +@@ -262,6 +262,35 @@ static const WCHAR wszTimesNewRoman[] = + static const WCHAR wszArial[] = + {'A','r','i','a','l',0}; + ++/* Based on debugstr_variant in dlls/jscript/jsutils.c. */ ++static const char *debugstr_variant(const VARIANT *var) ++{ ++ static char buf[400]; ++ ++ if (!var) ++ return "(null)"; ++ ++ switch (V_VT(var)) ++ { ++ case VT_EMPTY: ++ return "{VT_EMPTY}"; ++ case VT_BSTR: ++ sprintf(buf, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var))); ++ break; ++ case VT_BOOL: ++ sprintf(buf, "{VT_BOOL: %x}", V_BOOL(var)); ++ break; ++ case VT_UI4: ++ sprintf(buf, "{VT_UI4: %u}", V_UI4(var)); ++ break; ++ default: ++ sprintf(buf, "{vt %d}", V_VT(var)); ++ break; ++ } ++ ++ return buf; ++} ++ + static int strcmp_wa(LPCWSTR strw, const char *stra) + { + CHAR buf[512]; +@@ -979,6 +1008,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D + case 3000030: + case 3000031: + case 3000032: ++ case 3000033: + /* TODO */ + return S_OK; + } +@@ -3272,6 +3302,7 @@ static HRESULT WINAPI EventDispatch_Invoke(IDispatch *iface, DISPID dispIdMember + case 1044: + case 1048: + case 1049: ++ case 1057: + break; /* FIXME: Handle these events. */ + default: + ok(0, "Unexpected DISPID: %d\n", dispIdMember); +@@ -7431,6 +7462,38 @@ static void test_QueryInterface(IHTMLDocument2 *htmldoc) + IUnknown_Release(qi); + } + ++#define test_storage_set(s,k,v) _test_storage_set(__LINE__,s,k,v) ++static void _test_storage_set(unsigned line, IHTMLStorage *storage, const char *key, const char *value) ++{ ++ BSTR bstrKey, bstrValue; ++ HRESULT hres; ++ ++ bstrKey = a2bstr(key); ++ bstrValue = a2bstr(value); ++ hres = IHTMLStorage_setItem(storage, bstrKey, bstrValue); ++ SysFreeString(bstrKey); ++ SysFreeString(bstrValue); ++ ++ ok_(__FILE__,line) (hres == S_OK, "setItem (\"%s\": \"%s\") failed: %08x\n", key, value, hres); ++} ++ ++#define test_storage_get(s,k,e) _test_storage_get(__LINE__,s,k,e) ++static void _test_storage_get(unsigned line, IHTMLStorage *storage, const char *key, const char *exval) ++{ ++ BSTR bstrKey; ++ VARIANT var; ++ HRESULT hres; ++ ++ bstrKey = a2bstr(key); ++ hres = IHTMLStorage_getItem(storage, bstrKey, &var); ++ ++ ok_(__FILE__,line) (hres == S_OK, "getItem (\"%s\") failed: %08x\n", key, hres); ++ ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "expect %s, got %s\n", exval, debugstr_variant(&var)); ++ ++ SysFreeString(bstrKey); ++ VariantClear(&var); ++} ++ + static void test_sessionStorage(IHTMLWindow6 *window) + { + HRESULT hres; +@@ -7442,6 +7505,10 @@ static void test_sessionStorage(IHTMLWindow6 *window) + if(hres != S_OK || storage == NULL) + return; + ++ test_storage_set(storage, "test key", "test value"); ++ test_storage_get(storage, "test key", "test value"); ++ ++ + IHTMLStorage_Release(storage); + } + +-- +1.9.3 + diff --git a/patches/mshtml-sessionStorage/definition b/patches/mshtml-sessionStorage/definition new file mode 100644 index 00000000..fe0aad77 --- /dev/null +++ b/patches/mshtml-sessionStorage/definition @@ -0,0 +1,5 @@ +Author: Zhenbo Li +Subject: Implement sessionStorage(partially). +Revision: 1 +Fixes: Add partially support for sessionStorage +