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