15.2.3.7-5-b-231.js (978B)
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.7-5-b-231 6 description: > 7 Object.defineProperties - 'set' property of 'descObj' is own data 8 property that overrides an inherited accessor property (8.10.5 9 step 8.a) 10 ---*/ 11 12 var data1 = "data"; 13 var data2 = "data"; 14 var fun = function(value) { 15 data2 = value; 16 }; 17 var proto = {}; 18 Object.defineProperty(proto, "set", { 19 get: function() { 20 return fun; 21 }, 22 set: function(value) { 23 fun = value; 24 } 25 }); 26 27 var Con = function() {}; 28 Con.prototype = proto; 29 30 var child = new Con(); 31 child.set = function(value) { 32 data1 = value; 33 }; 34 35 var obj = {}; 36 37 Object.defineProperties(obj, { 38 prop: child 39 }); 40 41 obj.prop = "overrideData"; 42 43 assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); 44 assert.sameValue(data1, "overrideData", 'data1'); 45 assert.sameValue(data2, "data", 'data2'); 46 47 reportCompare(0, 0);