| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-__proto__-property-names-in-object-initializers |
| 5 |
es6id: B.3.1 |
| 6 |
description: > |
| 7 |
The value of the `__proto__` property key is not assigned to the |
| 8 |
[[Prototype]] internal slot, nor to a property named "__proto__" (non-Object, |
| 9 |
non-null value) |
| 10 |
info: | |
| 11 |
... |
| 12 |
6. If propKey is the String value "__proto__" and if |
| 13 |
IsComputedPropertyKey(propKey) is false, then |
| 14 |
a. If Type(propValue) is either Object or Null, then |
| 15 |
[...] |
| 16 |
b. Return NormalCompletion(empty). |
| 17 |
features: [Symbol] |
| 18 |
---*/ |
| 19 |
|
| 20 |
var object; |
| 21 |
|
| 22 |
object = { |
| 23 |
__proto__: undefined |
| 24 |
}; |
| 25 |
assert.sameValue( |
| 26 |
Object.getPrototypeOf(object), |
| 27 |
Object.prototype, |
| 28 |
'prototype (undefined)' |
| 29 |
); |
| 30 |
assert.sameValue( |
| 31 |
Object.getOwnPropertyDescriptor(object, '__proto__'), |
| 32 |
undefined, |
| 33 |
'property (undefined)' |
| 34 |
); |
| 35 |
|
| 36 |
object = { |
| 37 |
__proto__: 1 |
| 38 |
}; |
| 39 |
assert.sameValue( |
| 40 |
Object.getPrototypeOf(object), |
| 41 |
Object.prototype, |
| 42 |
'prototype (numeric primitive)' |
| 43 |
); |
| 44 |
assert.sameValue( |
| 45 |
Object.getOwnPropertyDescriptor(object, '__proto__'), |
| 46 |
undefined, |
| 47 |
'property (numeric primitive)' |
| 48 |
); |
| 49 |
|
| 50 |
object = { |
| 51 |
__proto__: false |
| 52 |
}; |
| 53 |
assert.sameValue( |
| 54 |
Object.getPrototypeOf(object), |
| 55 |
Object.prototype, |
| 56 |
'prototype (boolean primitive)' |
| 57 |
); |
| 58 |
assert.sameValue( |
| 59 |
Object.getOwnPropertyDescriptor(object, '__proto__'), |
| 60 |
undefined, |
| 61 |
'property (boolean primitive)' |
| 62 |
); |
| 63 |
|
| 64 |
object = { |
| 65 |
__proto__: 'string literal' |
| 66 |
}; |
| 67 |
assert.sameValue( |
| 68 |
Object.getPrototypeOf(object), |
| 69 |
Object.prototype, |
| 70 |
'prototype (string primitive)' |
| 71 |
); |
| 72 |
assert.sameValue( |
| 73 |
Object.getOwnPropertyDescriptor(object, '__proto__'), |
| 74 |
undefined, |
| 75 |
'property (string primitive)' |
| 76 |
); |
| 77 |
|
| 78 |
object = { |
| 79 |
__proto__: Symbol('') |
| 80 |
}; |
| 81 |
assert.sameValue( |
| 82 |
Object.getPrototypeOf(object), |
| 83 |
Object.prototype, |
| 84 |
'prototype (symbol)' |
| 85 |
); |
| 86 |
assert.sameValue( |
| 87 |
Object.getOwnPropertyDescriptor(object, '__proto__'), |
| 88 |
undefined, |
| 89 |
'property (symbol)' |
| 90 |
); |
| 91 |
|
| 92 |
reportCompare(0, 0); |