Bug 769041 - Remove __proto__ special-casing from arrays' getProperty hook. r=luke
authorJeff Walden <jwalden@mit.edu>
Wed, 27 Jun 2012 14:32:03 -0700
changeset 97955 d8fa108aee43a1afeaedd0ee4d12bfbd75627731
parent 97954 3451a9f921e6823c294f3bf05589d185716e84fb
child 97956 80803faf5851b1d994fb6234d110939e71feb2e5
push id11300
push userjwalden@mit.edu
push dateFri, 29 Jun 2012 18:54:11 +0000
treeherdermozilla-inbound@d8fa108aee43 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs769041
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 769041 - Remove __proto__ special-casing from arrays' getProperty hook. r=luke
js/src/jsarray.cpp
js/src/tests/ecma_5/Object/getPrototypeOf-array.js
js/src/tests/ecma_5/extensions/array-inherited-__proto__.js
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -767,21 +767,16 @@ js_GetDenseArrayElementValue(JSContext *
 static JSBool
 array_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
 {
     if (name == cx->runtime->atomState.lengthAtom) {
         vp->setNumber(obj->getArrayLength());
         return true;
     }
 
-    if (name == cx->runtime->atomState.protoAtom) {
-        vp->setObjectOrNull(obj->getProto());
-        return true;
-    }
-
     if (!obj->isDenseArray()) {
         Rooted<jsid> id(cx, NameToId(name));
         return baseops::GetProperty(cx, obj, receiver, id, vp);
     }
 
     JSObject *proto = obj->getProto();
     if (!proto) {
         vp->setUndefined();
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_5/Object/getPrototypeOf-array.js
@@ -0,0 +1,32 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var gTestfile = 'getPrototypeOf-array.js';
+var BUGNUMBER = 769041;
+var summary =
+  "The [[Prototype]] of an object whose prototype chain contains an array " +
+  "isn't that array's [[Prototype]]";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var arr = [];
+assertEq(Array.isArray(arr), true);
+var objWithArrPrototype = Object.create(arr);
+assertEq(!Array.isArray(objWithArrPrototype), true);
+assertEq(Object.getPrototypeOf(objWithArrPrototype), arr);
+var objWithArrGrandPrototype = Object.create(objWithArrPrototype);
+assertEq(!Array.isArray(objWithArrGrandPrototype), true);
+assertEq(Object.getPrototypeOf(objWithArrGrandPrototype), objWithArrPrototype);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);
+
+print("Tests complete");
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_5/extensions/array-inherited-__proto__.js
@@ -0,0 +1,32 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var gTestfile = 'array-inherited-__proto__.js';
+var BUGNUMBER = 769041;
+var summary =
+  "The [[Prototype]] of an object whose prototype chain contains an array " +
+  "isn't that array's [[Prototype]]";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var arr = [];
+assertEq(Array.isArray(arr), true);
+var objWithArrPrototype = Object.create(arr);
+assertEq(!Array.isArray(objWithArrPrototype), true);
+assertEq(objWithArrPrototype.__proto__, arr);
+var objWithArrGrandPrototype = Object.create(objWithArrPrototype);
+assertEq(!Array.isArray(objWithArrGrandPrototype), true);
+assertEq(objWithArrGrandPrototype.__proto__, objWithArrPrototype);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);
+
+print("Tests complete");