symbol-object-contains-symbol-properties-strict-strict.js (938B)
1 'use strict'; 2 // Copyright (C) 2013 the V8 project authors. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 es6id: 19.4 6 description: > 7 Object.preventExtensions(obj) where obj contains symbol properties. 8 flags: [onlyStrict] 9 features: [Symbol] 10 ---*/ 11 var symA = Symbol("A"); 12 var symB = Symbol("B"); 13 var symC = Symbol("C"); 14 var obj = {}; 15 obj[symA] = 1; 16 Object.preventExtensions(obj); 17 obj[symA] = 2; 18 19 assert.throws(TypeError, function() { 20 obj[symB] = 1; 21 }); 22 23 assert.throws(TypeError, function() { 24 Object.defineProperty(obj, symC, { 25 value: 1 26 }); 27 }); 28 29 assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`"); 30 assert.sameValue(delete obj[symA], true, "`delete obj[symA]` is `true`"); 31 assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`"); 32 assert.sameValue(obj[symC], undefined, "The value of `obj[symC]` is `undefined`"); 33 34 reportCompare(0, 0);