blob: 4f507cd9ee53c51b2c219c728c4d3c55edd77c5c [file] [log] [blame]
// This tests Object.seal and Object.freeze affect on Symbol properties.
var object = {
[Symbol.iterator]: 42
};
if (!object.hasOwnProperty(Symbol.iterator))
throw "Error: object doesn't have Symbol.iterator";
if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":true,"enumerable":true,"configurable":true}')
throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));
if (Object.getOwnPropertySymbols(object).length !== 1)
throw "Error: bad value " + Object.getOwnPropertySymbols(object).length;
if (Object.getOwnPropertySymbols(object)[0] !== Symbol.iterator)
throw "Error: bad value " + String(Object.getOwnPropertySymbols(object)[0]);
Object.seal(object);
if (!object.hasOwnProperty(Symbol.iterator))
throw "Error: object doesn't have Symbol.iterator";
if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":true,"enumerable":true,"configurable":false}')
throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));
Object.freeze(object);
if (!object.hasOwnProperty(Symbol.iterator))
throw "Error: object doesn't have Symbol.iterator";
if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":false,"enumerable":true,"configurable":false}')
throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));