15.2.3.5-4-275.js (1045B)
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-275 6 description: > 7 Object.create - 'set' property of one property in 'Properties' is 8 own accessor property that overrides an inherited accessor 9 property (8.10.5 step 8.a) 10 ---*/ 11 12 var data1 = "data"; 13 var data2 = "data"; 14 var proto = {}; 15 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 get: function() { 29 return function(value) { 30 data1 = value; 31 }; 32 } 33 }); 34 35 var newObj = Object.create({}, { 36 prop: child 37 }); 38 39 var hasProperty = newObj.hasOwnProperty("prop"); 40 41 newObj.prop = "overrideData"; 42 43 assert(hasProperty, 'hasProperty !== true'); 44 assert.sameValue(data1, "overrideData", 'data1'); 45 assert.sameValue(data2, "data", 'data2'); 46 47 reportCompare(0, 0);