[PATCH 2/5] jscript: Allow overriding builtin methods by setting the prop.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Mon Mar 21 10:58:29 CDT 2022
Methods can be overriden by simple assignment, not just via defineProperty,
unlike accessors.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
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 1cacd49..03062ee 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 86d6fa4..5e797a1 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);
--
2.34.1
More information about the wine-devel
mailing list