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 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5068 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
db23321704
commit
e2fab5fd9f
@ -784,8 +784,8 @@ function ObjectIsFrozen(obj) {
|
||||
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;
|
||||
|
@ -172,3 +172,22 @@ Object.defineProperty(obj3, 'y', {configurable: false, writable: false});
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user