From 6f93cab7ffcb73d64d45ecc746f121c37c73586d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 23 Jan 2020 11:54:11 +0100 Subject: [PATCH] Fix enumerability of Error and Function properties. The Error.message, Error.stackTrace, Function.prototype properties were defined with the wrong attributes. x --- jserror.c | 4 ++-- jsvalue.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jserror.c b/jserror.c index 09d1edf..b3a71f0 100644 --- a/jserror.c +++ b/jserror.c @@ -61,10 +61,10 @@ static int jsB_ErrorX(js_State *J, js_Object *prototype) js_pushobject(J, jsV_newobject(J, JS_CERROR, prototype)); if (top > 1) { js_pushstring(J, js_tostring(J, 1)); - js_setproperty(J, -2, "message"); + js_defproperty(J, -2, "message", JS_DONTENUM); } if (jsB_stacktrace(J, 1)) - js_setproperty(J, -2, "stackTrace"); + js_defproperty(J, -2, "stackTrace", JS_DONTENUM); return 1; } diff --git a/jsvalue.c b/jsvalue.c index b6245a8..f9c74cc 100644 --- a/jsvalue.c +++ b/jsvalue.c @@ -417,7 +417,7 @@ void js_newfunction(js_State *J, js_Function *fun, js_Environment *scope) js_copy(J, -2); js_defproperty(J, -2, "constructor", JS_DONTENUM); } - js_defproperty(J, -2, "prototype", JS_DONTCONF); + js_defproperty(J, -2, "prototype", JS_DONTENUM | JS_DONTCONF); } } @@ -445,7 +445,7 @@ void js_newcfunction(js_State *J, js_CFunction cfun, const char *name, int lengt js_copy(J, -2); js_defproperty(J, -2, "constructor", JS_DONTENUM); } - js_defproperty(J, -2, "prototype", JS_DONTCONF); + js_defproperty(J, -2, "prototype", JS_DONTENUM | JS_DONTCONF); } } @@ -464,7 +464,7 @@ void js_newcconstructor(js_State *J, js_CFunction cfun, js_CFunction ccon, const js_rot2(J); /* obj proto */ js_copy(J, -2); /* obj proto obj */ js_defproperty(J, -2, "constructor", JS_DONTENUM); - js_defproperty(J, -2, "prototype", JS_READONLY | JS_DONTENUM | JS_DONTCONF); + js_defproperty(J, -2, "prototype", JS_DONTENUM | JS_DONTCONF); } }