+ * The properties allow to query and set scope and prototype chains for the + * objects. The special meaning of the properties is available + * only when they are used as the right hand side of the dot operator. + * For example, while x.__proto__ = y changes the prototype + * chain of the object x to point to y, + * x["__proto__"] = y simply assigns a new value to the property + * __proto__ in x even when the feature is on. + * + * By default {@link #hasFeature(int)} returns true. + */ + public static final int FEATURE_PARENT_PROTO_PROPRTIES = 5; + /** * Controls certain aspects of script semantics. * Should be overwritten to alter default behavior. @@ -1996,6 +2011,7 @@ public class Context * @see #FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME * @see #FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER * @see #FEATURE_TO_STRING_AS_SOURCE + * @see #FEATURE_PARENT_PROTO_PROPRTIES */ public boolean hasFeature(int featureIndex) { @@ -2024,6 +2040,9 @@ public class Context case FEATURE_TO_STRING_AS_SOURCE: return version == VERSION_1_2; + + case FEATURE_PARENT_PROTO_PROPRTIES: + return true; } // It is a bug to call the method with unknown featureIndex throw new IllegalArgumentException(); diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index 32d8e4e80b0..2f4353ba8b8 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -1247,10 +1247,16 @@ public class ScriptRuntime { } else { throw Kit.codeBug(); } + final boolean + specials = cx.hasFeature(Context.FEATURE_PARENT_PROTO_PROPRTIES); + final Scriptable sobj = toObject(scope, obj); return new Reference() { public Object get() { + if (!specials) { + return getProp(sobj, specialProperty); + } if (id == PROTO) { return getProto(sobj, scope); } else { @@ -1260,6 +1266,9 @@ public class ScriptRuntime { public Object set(Object value) { + if (!specials) { + return setProp(sobj, specialProperty, value); + } Scriptable result; if (value == null) { result = null;