This should implement all of sessionStorage and most of the missing localStorage (except for the space quota for the latter). Some other common parts are still missing and pending (using props to directly access items in the underlying storage, and StorageEvents, which will come later).
On native, sessionStorage seems to be per-thread, and based on a specific origin, so it's implemented that way using a rbtree for origins in the thread local storage. The diff below (applied after all of the patches) should show that, which works on native as expected, but it's not in the actual commits because it crashes wine-gecko due to known multi-threading issues ([bug 37906](https://bugs.winehq.org/show_bug.cgi?id=37906)).
```diff
diff --git a/dlls/mshtml/tests/misc.c b/dlls/mshtml/tests/misc.c
index c2c8370..e358e9c 100644
--- a/dlls/mshtml/tests/misc.c
+++ b/dlls/mshtml/tests/misc.c
@@ -193,6 +193,32 @@ static HRESULT get_sessionstorage(IHTMLDocument2 *doc, IHTMLStorage **storage)
return hres;
}
+static DWORD WINAPI test_HTMLStorage_thread(void *data)
+{
+ IHTMLStorage *storage;
+ IHTMLDocument2 *doc;
+ BSTR key = data;
+ HRESULT hres;
+ VARIANT var;
+
+ CoInitialize(NULL);
+
+ doc = create_doc_from_url(L"http://www.codeweavers.com/");
+ hres = get_sessionstorage(doc, &storage);
+ ok(hres == S_OK, "got %08lx\n", hres);
+
+ V_VT(&var) = 0xdead;
+ hres = IHTMLStorage_getItem(storage, key, &var);
+ ok(hres == S_OK, "getItem failed: %08lx\n", hres);
+ ok(V_VT(&var) == VT_NULL, "got %d\n", V_VT(&var));
+
+ IHTMLStorage_Release(storage);
+ IHTMLDocument2_Release(doc);
+
+ CoUninitialize();
+ return 0;
+}
+
static void test_HTMLStorage(void)
{
IHTMLDocument2 *doc, *doc2;
@@ -200,7 +226,9 @@ static void test_HTMLStorage(void)
LONG space, length, lval;
VARIANT var;
BSTR key, value;
+ HANDLE thread;
HRESULT hres;
+ DWORD ret;
doc = create_doc_from_url(L"http://www.codeweavers.com/");
doc2 = create_doc_from_url(L"http://www.codeweavers.com/");
@@ -607,6 +635,12 @@ static void test_HTMLStorage(void)
ok(hres == S_OK, "get_remainingSpace failed %08lx\n", hres);
ok(lval == space, "remainingSpace = %ld\n", lval);
+ /* Different thread */
+ thread = CreateThread(NULL, 0, test_HTMLStorage_thread, key, 0, NULL);
+ ret = WaitForSingleObject(thread, INFINITE);
+ ok(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %08lx\n", ret);
+ CloseHandle(thread);
+
hres = IHTMLStorage_clear(storage);
ok(hres == S_OK, "clear failed %08lx\n", hres);
```
There's another rbtree for the actual storage on a given origin, which contains key/value pairs, with keys stored inline because they do not change.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/704
On Thu Aug 25 10:37:24 2022 +0000, Robert Wilhelm wrote:
> Hi Etaash, you have to squash the formatting and whitespace changes into
> the first commit. The test build will run after each commit and bail out
> if there are errors and warnings.
lol it did nothing other than duplicate the commits,
pls help
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/706#note_6910
fixes bug #48988
I am not very familiar with assembly, so feedback is appreciated
--
v11: improve formatting
check correct number of bytes
fix missing newline
remove extra space
fix errors
fix potential logic error
fix print formatting
maybe fixes error?
implement cmp instruction
https://gitlab.winehq.org/wine/wine/-/merge_requests/706