| 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-4-415 |
| 6 |
description: > |
| 7 |
ES5 Attributes - Failed to add properties to an object when the |
| 8 |
object's prototype has properties with the same name and |
| 9 |
[[Writable]] set to false (Object.create) |
| 10 |
includes: [propertyHelper.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
var appointment = new Object(); |
| 14 |
|
| 15 |
Object.defineProperty(appointment, "startTime", { |
| 16 |
value: 1001, |
| 17 |
writable: false, |
| 18 |
enumerable: false, |
| 19 |
configurable: true |
| 20 |
}); |
| 21 |
Object.defineProperty(appointment, "name", { |
| 22 |
value: "NAME", |
| 23 |
writable: false, |
| 24 |
enumerable: false, |
| 25 |
configurable: true |
| 26 |
}); |
| 27 |
|
| 28 |
var meeting = Object.create(appointment); |
| 29 |
Object.defineProperty(meeting, "conferenceCall", { |
| 30 |
value: "In-person meeting", |
| 31 |
writable: false, |
| 32 |
enumerable: false, |
| 33 |
configurable: true |
| 34 |
}); |
| 35 |
|
| 36 |
var teamMeeting = Object.create(meeting); |
| 37 |
|
| 38 |
//teamMeeting.name = "Team Meeting"; |
| 39 |
verifyNotWritable(teamMeeting, "name", "noCheckOwnProp"); |
| 40 |
|
| 41 |
var dateObj = new Date("10/31/2010 08:00"); |
| 42 |
//teamMeeting.startTime = dateObj; |
| 43 |
verifyNotWritable(teamMeeting, "startTime", "noCheckOwnProp"); |
| 44 |
|
| 45 |
//teamMeeting.conferenceCall = "4255551212"; |
| 46 |
verifyNotWritable(teamMeeting, "conferenceCall", "noCheckOwnProp"); |
| 47 |
|
| 48 |
assert(!teamMeeting.hasOwnProperty("name")); |
| 49 |
assert(!teamMeeting.hasOwnProperty("startTime")); |
| 50 |
assert(!teamMeeting.hasOwnProperty('conferenceCall')); |
| 51 |
|
| 52 |
assert.sameValue(teamMeeting.name, "NAME"); |
| 53 |
assert.sameValue(teamMeeting.startTime, 1001); |
| 54 |
assert.sameValue(teamMeeting.conferenceCall, "In-person meeting"); |