From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/jscript/tests/run.c | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c index ec054f03d0d..f40ffb3a84e 100644 --- a/dlls/jscript/tests/run.c +++ b/dlls/jscript/tests/run.c @@ -114,6 +114,7 @@ DEFINE_EXPECT(testobj_newenum); DEFINE_EXPECT(testobj_getidfail_d); DEFINE_EXPECT(testobj_tolocalestr_d); DEFINE_EXPECT(testobj_tolocalestr_i); +DEFINE_EXPECT(testdestrobj); DEFINE_EXPECT(enumvariant_next_0); DEFINE_EXPECT(enumvariant_next_1); DEFINE_EXPECT(enumvariant_reset); @@ -172,6 +173,7 @@ DEFINE_EXPECT(BindHandler); #define DISPID_GLOBAL_VDATE 0x1023 #define DISPID_GLOBAL_VCY 0x1024 #define DISPID_GLOBAL_TODOWINE 0x1025 +#define DISPID_GLOBAL_TESTDESTROBJ 0x1026
#define DISPID_GLOBAL_TESTPROPDELETE 0x2000 #define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001 @@ -342,6 +344,7 @@ static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, else return E_NOINTERFACE;
+ IUnknown_AddRef((IUnknown *)*ppv); return S_OK; }
@@ -626,6 +629,40 @@ static IDispatchExVtbl testObjVtbl = {
static IDispatchEx testObj = { &testObjVtbl };
+static LONG test_destr_ref; + +static ULONG WINAPI testDestrObj_AddRef(IDispatchEx *iface) +{ + return ++test_destr_ref; +} + +static ULONG WINAPI testDestrObj_Release(IDispatchEx *iface) +{ + if (!--test_destr_ref) + CHECK_EXPECT(testdestrobj); + return test_destr_ref; +} + +static IDispatchExVtbl testDestrObjVtbl = { + DispatchEx_QueryInterface, + testDestrObj_AddRef, + testDestrObj_Release, + DispatchEx_GetTypeInfoCount, + DispatchEx_GetTypeInfo, + DispatchEx_GetIDsOfNames, + DispatchEx_Invoke, + DispatchEx_GetDispID, + DispatchEx_InvokeEx, + DispatchEx_DeleteMemberByName, + DispatchEx_DeleteMemberByDispID, + DispatchEx_GetMemberProperties, + DispatchEx_GetMemberName, + DispatchEx_GetNextDispID, + DispatchEx_GetNameSpaceParent +}; + +static IDispatchEx testDestrObj = { &testDestrObjVtbl }; + static HRESULT WINAPI dispexFunc_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *res, EXCEPINFO *pei, IServiceProvider *pspCaller) { @@ -1065,6 +1102,11 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD return S_OK; }
+ if(!lstrcmpW(bstrName, L"testDestrObj")) { + *pid = DISPID_GLOBAL_TESTDESTROBJ; + return S_OK; + } + if(strict_dispid_check && lstrcmpW(bstrName, L"t")) ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName)); return DISP_E_UNKNOWNNAME; @@ -1268,6 +1310,22 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, V_DISPATCH(pvarRes) = (IDispatch*)&testObj; return S_OK;
+ case DISPID_GLOBAL_TESTDESTROBJ: + ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags); + ok(pdp != NULL, "pdp == NULL\n"); + ok(!pdp->rgvarg, "rgvarg != NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pvarRes != NULL, "pvarRes == NULL\n"); + ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes)); + ok(pei != NULL, "pei == NULL\n"); + + V_VT(pvarRes) = VT_DISPATCH; + V_DISPATCH(pvarRes) = (IDispatch*)&testDestrObj; + IDispatch_AddRef(V_DISPATCH(pvarRes)); + return S_OK; + case DISPID_GLOBAL_PUREDISP: ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags); ok(pdp != NULL, "pdp == NULL\n"); @@ -3386,6 +3444,25 @@ static void test_invokeex(void) IActiveScript_Release(script); }
+static void test_destructors(void) +{ + IActiveScript *script; + VARIANT v; + HRESULT hres; + + V_VT(&v) = VT_EMPTY; + hres = parse_script_expr(L"Math.ref = testDestrObj, isNaN.ref = testDestrObj, true", &v, &script); + ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres); + ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v)); + + SET_EXPECT(testdestrobj); + hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED); + ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08lx\n", hres); + CHECK_CALLED(testdestrobj); + + IActiveScript_Release(script); +} + static void test_eval(void) { IActiveScriptParse *parser; @@ -3914,6 +3991,7 @@ static BOOL run_tests(void)
test_script_exprs(); test_invokeex(); + test_destructors(); test_eval(); test_error_reports();
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/jscript/set.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index d1ea6637956..0ef014b86d0 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -223,6 +223,7 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j static HRESULT Map_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { + struct jsval_map_entry *entry, *entry2; MapInstance *map; HRESULT hres;
@@ -232,10 +233,8 @@ static HRESULT Map_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned
TRACE("%p\n", map);
- while(!list_empty(&map->entries)) { - struct jsval_map_entry *entry = LIST_ENTRY(list_head(&map->entries), struct jsval_map_entry, list_entry); + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &map->entries, struct jsval_map_entry, list_entry) delete_map_entry(map, entry); - }
if(r) *r = jsval_undefined(); return S_OK; @@ -443,6 +442,7 @@ static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { + struct jsval_map_entry *entry, *entry2; MapInstance *set; HRESULT hres;
@@ -452,10 +452,8 @@ static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned
TRACE("%p\n", set);
- while(!list_empty(&set->entries)) { - struct jsval_map_entry *entry = LIST_ENTRY(list_head(&set->entries), struct jsval_map_entry, list_entry); + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &set->entries, struct jsval_map_entry, list_entry) delete_map_entry(set, entry); - }
if(r) *r = jsval_undefined(); return S_OK;
From: Jacek Caban jacek@codeweavers.com
Based on patch by Gabriel Ivăncescu.
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/jscript/set.c | 12 +++++++++--- dlls/mshtml/tests/documentmode.js | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 0ef014b86d0..c64a5598026 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -183,7 +183,7 @@ static HRESULT set_map_entry(MapInstance *map, jsval_t key, jsval_t value, jsval
static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsval_t *r) { - struct jsval_map_entry *entry; + struct list *iter = list_head(&map->entries); IDispatch *context_obj = NULL; HRESULT hres;
@@ -200,16 +200,22 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j context_obj = get_object(argv[1]); }
- LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { + while(iter) { + struct jsval_map_entry *entry = LIST_ENTRY(iter, struct jsval_map_entry, list_entry); jsval_t args[3], v; - if(entry->deleted) + + if(entry->deleted) { + iter = list_next(&map->entries, iter); continue; + } + args[0] = entry->value; args[1] = entry->key; args[2] = jsval_obj(&map->dispex); grab_map_entry(entry); hres = disp_call_value(ctx, get_object(argv[0]), context_obj, DISPATCH_METHOD, ARRAY_SIZE(args), args, &v); + iter = list_next(&map->entries, iter); release_map_entry(entry); if(FAILED(hres)) return hres; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index f2da8113e18..299d46e5727 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1019,6 +1019,18 @@ sync_test("set_obj", function() {
s = new Set([1, 2, 3]); ok(s.size === 0, "size = " + s.size); + + s = new Set(); + s.add(1); + s.add(2); + s.add(3); + r = 0; + s.forEach(function(value, key, obj) { + r++; + s.clear(); + ok(s.size === 0, "size = " + s.size); + }); + ok(r === 1, "r = " + r); });
sync_test("map_obj", function() { @@ -1161,6 +1173,18 @@ sync_test("map_obj", function() { }catch(e) { ok(e.number === 0xa13fc - 0x80000000, "e.number = " + e.number); } + + s = new Map(); + s.set(1, 10); + s.set(2, 20); + s.set(3, 30); + r = 0; + s.forEach(function(value, key) { + r++; + s.clear(); + ok(s.size === 0, "size = " + s.size); + }); + ok(r === 1, "r = " + r); });
sync_test("elem_attr", function() {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116388
Your paranoid android.
=== w7u_el (32 bit report) ===
mshtml: script.c:644: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1654621858533 expected 1654621858596"