Reviewers: Mads Ager,
Description:
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.
Please review this at http://codereview.chromium.org/2904015/show
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/v8natives.js
M test/mjsunit/object-freeze.js
Index: src/v8natives.js
===================================================================
--- src/v8natives.js (revision 5067)
+++ src/v8natives.js (working copy)
@@ -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;
Index: test/mjsunit/object-freeze.js
===================================================================
--- test/mjsunit/object-freeze.js (revision 5067)
+++ test/mjsunit/object-freeze.js (working copy)
@@ -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