From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlstorage.c | 17 +++++++++++++++-- dlls/mshtml/tests/misc.c | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c index a7feba6ce69..e9498306a81 100644 --- a/dlls/mshtml/htmlstorage.c +++ b/dlls/mshtml/htmlstorage.c @@ -668,8 +668,21 @@ static HRESULT WINAPI HTMLStorage_removeItem(IHTMLStorage *iface, BSTR bstrKey) static HRESULT WINAPI HTMLStorage_clear(IHTMLStorage *iface) { HTMLStorage *This = impl_from_IHTMLStorage(iface); - FIXME("(%p)->()\n", This); - return E_NOTIMPL; + HRESULT hres = S_OK; + + if(!This->filename) { + clear_session_storage(This->session_storage); + return S_OK; + } + + WaitForSingleObject(This->mutex, INFINITE); + if(!DeleteFileW(This->filename)) { + DWORD error = GetLastError(); + if(error != ERROR_FILE_NOT_FOUND && error != ERROR_PATH_NOT_FOUND) + hres = HRESULT_FROM_WIN32(error); + } + ReleaseMutex(This->mutex); + return hres; }
static const IHTMLStorageVtbl HTMLStorageVtbl = { diff --git a/dlls/mshtml/tests/misc.c b/dlls/mshtml/tests/misc.c index 1a60ce4f70d..c2a8c87f473 100644 --- a/dlls/mshtml/tests/misc.c +++ b/dlls/mshtml/tests/misc.c @@ -415,6 +415,9 @@ static void test_HTMLStorage(void) ok(V_VT(&var) == VT_NULL, "got %d\n", V_VT(&var)); SysFreeString(key);
+ hres = IHTMLStorage_clear(storage2); + ok(hres == S_OK, "clear failed %08lx\n", hres); + key = SysAllocString(L"foo"); value = SysAllocString(L"bar"); hres = IHTMLStorage_setItem(storage, key, value); @@ -472,6 +475,9 @@ static void test_HTMLStorage(void) ok(!wcscmp(V_BSTR(&var), L"bar"), "got %s\n", wine_dbgstr_w(V_BSTR(&var))); VariantClear(&var);
+ hres = IHTMLStorage_clear(storage2); + ok(hres == S_OK, "clear failed %08lx\n", hres); + IHTMLStorage_Release(storage2); IHTMLDocument2_Release(doc2);
@@ -491,6 +497,9 @@ static void test_HTMLStorage(void) ok(hres == S_OK, "getItem failed: %08lx\n", hres); ok(V_VT(&var) == VT_NULL, "got %d\n", V_VT(&var));
+ hres = IHTMLStorage_clear(storage); + ok(hres == S_OK, "clear failed %08lx\n", hres); + IHTMLStorage_Release(storage2); IHTMLStorage_Release(storage); IHTMLDocument2_Release(doc2);