| 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-globaldeclarationinstantiation |
| 5 |
es6id: 15.1.8 |
| 6 |
description: Declaration of variable where permissible |
| 7 |
info: | |
| 8 |
[...] |
| 9 |
11. Let declaredVarNames be a new empty List. |
| 10 |
12. For each d in varDeclarations, do |
| 11 |
a. If d is a VariableDeclaration or a ForBinding, then |
| 12 |
i. For each String vn in the BoundNames of d, do |
| 13 |
1. If vn is not an element of declaredFunctionNames, then |
| 14 |
a. Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn). |
| 15 |
b. If vnDefinable is false, throw a TypeError exception. |
| 16 |
c. If vn is not an element of declaredVarNames, then |
| 17 |
i. Append vn to declaredVarNames. |
| 18 |
[...] |
| 19 |
18. For each String vn in declaredVarNames, in list order do |
| 20 |
a. Perform ? envRec.CreateGlobalVarBinding(vn, false). |
| 21 |
[...] |
| 22 |
|
| 23 |
8.1.1.4.15 CanDeclareGlobalVar |
| 24 |
|
| 25 |
1. Let envRec be the global Environment Record for which the method was |
| 26 |
invoked. |
| 27 |
2. Let ObjRec be envRec.[[ObjectRecord]]. |
| 28 |
3. Let globalObject be the binding object for ObjRec. |
| 29 |
4. Let hasProperty be ? HasOwnProperty(globalObject, N). |
| 30 |
5. If hasProperty is true, return true. |
| 31 |
6. Return ? IsExtensible(globalObject). |
| 32 |
includes: [propertyHelper.js] |
| 33 |
---*/ |
| 34 |
|
| 35 |
$262.evalScript('var brandNew;'); |
| 36 |
|
| 37 |
verifyProperty(this, 'brandNew', { |
| 38 |
value: undefined, |
| 39 |
writable: true, |
| 40 |
enumerable: true, |
| 41 |
configurable: false, |
| 42 |
}); |
| 43 |
|
| 44 |
Object.defineProperty( |
| 45 |
this, |
| 46 |
'configurable', |
| 47 |
{ configurable: true, writable: false, enumerable: false, value: 0 } |
| 48 |
); |
| 49 |
Object.defineProperty( |
| 50 |
this, |
| 51 |
'nonConfigurable', |
| 52 |
{ configurable: false, writable: false, enumerable: false, value: 0 } |
| 53 |
); |
| 54 |
|
| 55 |
// Prevent extensions on the global object to ensure that detail is not |
| 56 |
// considered by any of the declarations which follow. |
| 57 |
Object.preventExtensions(this); |
| 58 |
|
| 59 |
$262.evalScript('var configurable;'); |
| 60 |
|
| 61 |
verifyProperty(this, 'configurable', { |
| 62 |
value: 0, |
| 63 |
writable: false, |
| 64 |
enumerable: false, |
| 65 |
configurable: true, |
| 66 |
}); |
| 67 |
|
| 68 |
$262.evalScript('var nonConfigurable;'); |
| 69 |
|
| 70 |
verifyProperty(this, 'nonConfigurable', { |
| 71 |
value: 0, |
| 72 |
writable: false, |
| 73 |
enumerable: false, |
| 74 |
configurable: false, |
| 75 |
}); |
| 76 |
|
| 77 |
reportCompare(0, 0); |