From 628c8791a75b5f46707ba31be6286967dad0e74f Mon Sep 17 00:00:00 2001 From: fur Date: Fri, 26 Jun 1998 05:44:02 +0000 Subject: [PATCH] When running in ECMA-compatibility mode, silently ignore attempts to delete properties of JavaArray objects. --- js/ref/liveconnect/jsj_JavaArray.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/js/ref/liveconnect/jsj_JavaArray.c b/js/ref/liveconnect/jsj_JavaArray.c index 9c98cbf72be..b85170e5fc6 100644 --- a/js/ref/liveconnect/jsj_JavaArray.c +++ b/js/ref/liveconnect/jsj_JavaArray.c @@ -79,9 +79,17 @@ access_java_array_element(JSContext *cx, member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval)); if (do_assignment) { - JS_ReportError(cx, "Attempt to write to invalid Java array " - "element \"%s\"", member_name); - return JS_FALSE; + JSVersion version = JS_GetVersion(cx); + + if (!JSVERSION_IS_ECMA(version)) { + + JS_ReportError(cx, "Attempt to write to invalid Java array " + "element \"%s\"", member_name); + return JS_FALSE; + } else { + *vp = JSVAL_VOID; + return JS_TRUE; + } } else { if (!strcmp(member_name, "length")) { array_length = jsj_GetJavaArrayLength(cx, jEnv, java_array); @@ -170,7 +178,7 @@ JavaArray_defineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSPropertyOp setter, uintN attrs, JSProperty **propp) { - JS_ReportError(cx, "Elements of JavaArray objects may not be deleted"); + JS_ReportError(cx, "Cannot define a new property in a JavaArray"); return JS_FALSE; } @@ -200,8 +208,16 @@ JavaArray_setAttributes(JSContext *cx, JSObject *obj, jsid id, static JSBool JavaArray_deleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { - JS_ReportError(cx, "Elements of JavaArray objects may not be deleted"); - return JS_FALSE; + JSVersion version = JS_GetVersion(cx); + + if (!JSVERSION_IS_ECMA(version)) { + JS_ReportError(cx, "Properties of JavaArray objects may not be deleted"); + return JS_FALSE; + } else { + /* Attempts to delete permanent properties are silently ignored + by ECMAScript. */ + return JS_TRUE; + } } static JSBool