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