Gabriel Ivăncescu : jscript: Allow overriding builtin methods by setting the prop.
Alexandre Julliard
julliard at winehq.org
Mon Mar 21 17:20:25 CDT 2022
Module: wine
Branch: master
Commit: 94349fdd9abae527f6b71d9776663380d9ac81f9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=94349fdd9abae527f6b71d9776663380d9ac81f9
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Mon Mar 21 17:58:29 2022 +0200
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 at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/dispex.c | 6 ++++++
dlls/jscript/tests/run.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 1cacd49a1fa..03062eebb63 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -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;
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 86d6fa46212..5e797a19cb9 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -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);
More information about the wine-cvs
mailing list