Commit fbb763a5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use the value returned from constructor in 'new' expression if the value if an object.

parent fded8dc0
...@@ -226,20 +226,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, ...@@ -226,20 +226,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{ {
DispatchEx *this_obj; DispatchEx *this_obj;
VARIANT var;
HRESULT hres; HRESULT hres;
hres = create_object(ctx, &function->dispex, &this_obj); hres = create_object(ctx, &function->dispex, &this_obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, retv, ei, caller); hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, &var, ei, caller);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(this_obj); jsdisp_release(this_obj);
return hres; return hres;
} }
V_VT(retv) = VT_DISPATCH; V_VT(retv) = VT_DISPATCH;
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); if(V_VT(&var) == VT_DISPATCH) {
jsdisp_release(this_obj);
V_DISPATCH(retv) = V_DISPATCH(&var);
}else {
VariantClear(&var);
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj);
}
return S_OK; return S_OK;
} }
......
...@@ -148,6 +148,21 @@ obj2.pvar = 3; ...@@ -148,6 +148,21 @@ obj2.pvar = 3;
testConstr1.prototype.pvar = 1; testConstr1.prototype.pvar = 1;
ok(obj2.pvar === 3, "obj2.pvar is not 3"); ok(obj2.pvar === 3, "obj2.pvar is not 3");
obj1 = new Object();
function testConstr3() {
return obj1;
}
obj2 = new testConstr3();
ok(obj1 === obj2, "obj1 != obj2");
function testConstr4() {
return 2;
}
obj2 = new testConstr3();
ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
var obj3 = new Object; var obj3 = new Object;
ok(typeof(obj3) === "object", "typeof(obj3) is not object"); ok(typeof(obj3) === "object", "typeof(obj3) is not object");
......
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