jscript: Properly handle builtin properties in Object.prototype.hasOwnProperty implementation.

This commit is contained in:
Jacek Caban 2012-07-23 15:53:52 +02:00 committed by Alexandre Julliard
parent 15a83f0ff5
commit 10179c210e
3 changed files with 14 additions and 9 deletions

View File

@ -1388,16 +1388,15 @@ HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
return delete_prop(prop);
}
VARIANT_BOOL jsdisp_is_own_prop(jsdisp_t *obj, BSTR name)
HRESULT jsdisp_is_own_prop(jsdisp_t *obj, BSTR name, VARIANT_BOOL *ret)
{
dispex_prop_t *prop;
HRESULT hres;
hres = find_prop_name(obj, string_hash(name), name, &prop);
if(FAILED(hres))
return VARIANT_FALSE;
else if(!prop)
return VARIANT_FALSE;
return hres;
return prop->type==PROP_VARIANT ? VARIANT_TRUE : VARIANT_FALSE;
*ret = prop && (prop->type == PROP_VARIANT || prop->type == PROP_BUILTIN) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}

View File

@ -222,7 +222,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,VARIANT*,jsexcept_t*) DECLSPEC_HID
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
VARIANT_BOOL jsdisp_is_own_prop(jsdisp_t *obj, BSTR name) DECLSPEC_HIDDEN;
HRESULT jsdisp_is_own_prop(jsdisp_t*,BSTR,VARIANT_BOOL*) DECLSPEC_HIDDEN;
HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;

View File

@ -110,7 +110,6 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
VARIANT *retv, jsexcept_t *ei)
{
BSTR name;
BOOL result;
DISPID id;
HRESULT hres;
@ -130,14 +129,21 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return hres;
if(is_jsdisp(jsthis)) {
result = jsdisp_is_own_prop(jsthis->u.jsdisp, name);
VARIANT_BOOL result;
hres = jsdisp_is_own_prop(jsthis->u.jsdisp, name, &result);
if(FAILED(hres))
return hres;
if(retv) {
V_VT(retv) = VT_BOOL;
V_BOOL(retv) = result;
}
return S_OK;
} else if(is_dispex(jsthis)) {
}
if(is_dispex(jsthis)) {
hres = IDispatchEx_GetDispID(jsthis->u.dispex, name,
make_grfdex(ctx, fdexNameCaseSensitive), &id);
} else {