15.2.3.5-4-271.js (1010B)
1 // Copyright (c) 2012 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 15.2.3.5-4-271 6 description: > 7 Object.create - 'set' property of one property in 'Properties' is 8 own data property that overrides an inherited accessor property 9 (8.10.5 step 8.a) 10 ---*/ 11 12 var data1 = "data"; 13 var data2 = "data"; 14 15 var proto = {}; 16 Object.defineProperty(proto, "set", { 17 get: function() { 18 return function(value) { 19 data2 = value; 20 }; 21 } 22 }); 23 24 var ConstructFun = function() {}; 25 ConstructFun.prototype = proto; 26 var child = new ConstructFun(); 27 Object.defineProperty(child, "set", { 28 value: function(value) { 29 data1 = value; 30 } 31 }); 32 33 var newObj = Object.create({}, { 34 prop: child 35 }); 36 37 var hasProperty = newObj.hasOwnProperty("prop"); 38 39 newObj.prop = "overrideData"; 40 41 assert(hasProperty, 'hasProperty !== true'); 42 assert.sameValue(data1, "overrideData", 'data1'); 43 assert.sameValue(data2, "data", 'data2'); 44 45 reportCompare(0, 0);