jscript: Allow overriding builtin methods by setting the prop.

Methods can be overriden by simple assignment, not just via defineProperty,
unlike accessors.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2022-03-21 17:58:29 +02:00 committed by Alexandre Julliard
parent 324b82d9ec
commit 94349fdd9a
2 changed files with 6 additions and 1 deletions

View File

@ -495,6 +495,12 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val)
switch(prop->type) {
case PROP_BUILTIN:
if(prop->u.p->invoke) {
prop->type = PROP_JSVAL;
prop->flags = PROPF_CONFIGURABLE | PROPF_WRITABLE;
prop->u.val = jsval_undefined();
break;
}
if(!prop->u.p->setter) {
TRACE("getter with no setter\n");
return S_OK;

View File

@ -2955,7 +2955,6 @@ static void test_script_exprs(void)
hres = parse_script_expr(L"var o=new Object(); Object.prototype.toString = function() {return \"wine\";}; Object.prototype.toLocaleString.call(o)", &v, NULL);
ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
todo_wine
ok(!lstrcmpW(V_BSTR(&v), L"wine"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);