Commit c2402a92 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Retrieve the proper 'this' object for bytecodes with named items.

parent ef0f2c7f
......@@ -1237,8 +1237,14 @@ static HRESULT interp_this(script_ctx_t *ctx)
TRACE("\n");
if(!this_obj)
this_obj = lookup_global_host(ctx);
if(!this_obj) {
named_item_t *item = ctx->call_ctx->bytecode->named_item;
if(item)
this_obj = (item->flags & SCRIPTITEM_CODEONLY) ? to_disp(item->script_obj) : item->disp;
else
this_obj = lookup_global_host(ctx);
}
IDispatch_AddRef(this_obj);
return stack_push(ctx, jsval_disp(this_obj));
......
......@@ -1252,7 +1252,6 @@ static void test_named_items(void)
SET_EXPECT(OnLeaveScript);
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"visibleCodeItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
todo_wine
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == disp,
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
VariantClear(&var);
......@@ -1413,7 +1412,6 @@ static void test_named_items(void)
SET_EXPECT(OnLeaveScript);
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"visibleItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
todo_wine
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &visible_named_item,
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
VariantClear(&var);
......@@ -1424,7 +1422,6 @@ static void test_named_items(void)
SET_EXPECT(OnLeaveScript);
hr = IActiveScriptParse_ParseScriptText(parse, L"this", L"codeOnlyItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
ok(hr == S_OK, "ParseScriptText failed: %08x\n", hr);
todo_wine
ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)dispex2,
"Unexpected 'this': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var));
VariantClear(&var);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment