Revision: 5068
Author: [email protected]
Date: Wed Jul 14 06:15:43 2010
Log: Fix bug in Object.isFrozen which always classifies non-extensible
objects as frozen.
Since out internal representation of a property descriptor does not have
configurable and writable
attributes Object.isFrozen returns true whenever an object is not
extensible.
This change makes use of the right method calls on our internal
representation (isWritable() and
isConfigurable()). Tests added directly to the mjsunit test.
Review URL: http://codereview.chromium.org/2904015
http://code.google.com/p/v8/source/detail?r=5068
Modified:
/branches/bleeding_edge/src/v8natives.js
/branches/bleeding_edge/test/mjsunit/object-freeze.js
=======================================
--- /branches/bleeding_edge/src/v8natives.js Tue Jul 13 05:58:02 2010
+++ /branches/bleeding_edge/src/v8natives.js Wed Jul 14 06:15:43 2010
@@ -784,8 +784,8 @@
for (var key in names) {
var name = names[key];
var desc = GetOwnProperty(obj, name);
- if (IsDataDescriptor(desc) && desc.writable) return false;
- if (desc.configurable) return false;
+ if (IsDataDescriptor(desc) && desc.isWritable()) return false;
+ if (desc.isConfigurable()) return false;
}
if (!ObjectIsExtensible(obj)) {
return true;
=======================================
--- /branches/bleeding_edge/test/mjsunit/object-freeze.js Tue Jul 13
05:58:02 2010
+++ /branches/bleeding_edge/test/mjsunit/object-freeze.js Wed Jul 14
06:15:43 2010
@@ -172,3 +172,22 @@
Object.preventExtensions(obj3);
assertTrue(Object.isFrozen(obj3));
+
+
+// Make sure that an object that has only non-configurable, but one
+// writable property, is not classified as frozen.
+var obj4 = {};
+Object.defineProperty(obj4, 'x', {configurable: false, writable: true});
+Object.defineProperty(obj4, 'y', {configurable: false, writable: false});
+Object.preventExtensions(obj4);
+
+assertFalse(Object.isFrozen(obj4));
+
+// Make sure that an object that has only non-writable, but one
+// configurable property, is not classified as frozen.
+var obj5 = {};
+Object.defineProperty(obj5, 'x', {configurable: true, writable: false});
+Object.defineProperty(obj5, 'y', {configurable: false, writable: false});
+Object.preventExtensions(obj5);
+
+assertFalse(Object.isFrozen(obj5));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev