15.2.3.5-4-270.js (889B)
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-270 6 description: > 7 Object.create - 'set' property of one property in 'Properties' is 8 own data property that overrides an inherited data property 9 (8.10.5 step 8.a) 10 ---*/ 11 12 var data1 = "data"; 13 var data2 = "data"; 14 var proto = { 15 set: function(value) { 16 data2 = value; 17 } 18 }; 19 20 var ConstructFun = function() {}; 21 ConstructFun.prototype = proto; 22 var child = new ConstructFun(); 23 child.set = function(value) { 24 data1 = value; 25 }; 26 27 var newObj = Object.create({}, { 28 prop: child 29 }); 30 31 var hasProperty = newObj.hasOwnProperty("prop"); 32 33 newObj.prop = "overrideData"; 34 35 assert(hasProperty, 'hasProperty !== true'); 36 assert.sameValue(data1, "overrideData", 'data1'); 37 assert.sameValue(data2, "data", 'data2'); 38 39 reportCompare(0, 0);