script-decl-var-err.js (1467B)
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: > 7 Declaration of variable when there is no corresponding global property and 8 the global object is non-extensible 9 info: | 10 [...] 11 11. Let declaredVarNames be a new empty List. 12 12. For each d in varDeclarations, do 13 a. If d is a VariableDeclaration or a ForBinding, then 14 i. For each String vn in the BoundNames of d, do 15 1. If vn is not an element of declaredFunctionNames, then 16 a. Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn). 17 b. If vnDefinable is false, throw a TypeError exception. 18 c. If vn is not an element of declaredVarNames, then 19 i. Append vn to declaredVarNames. 20 21 8.1.1.4.15 CanDeclareGlobalVar 22 23 1. Let envRec be the global Environment Record for which the method was 24 invoked. 25 2. Let ObjRec be envRec.[[ObjectRecord]]. 26 3. Let globalObject be the binding object for ObjRec. 27 4. Let hasProperty be ? HasOwnProperty(globalObject, N). 28 5. If hasProperty is true, return true. 29 6. Return ? IsExtensible(globalObject). 30 ---*/ 31 32 var executed = false; 33 34 Object.preventExtensions(this); 35 36 assert.throws(TypeError, function() { 37 $262.evalScript('executed = true; var test262;'); 38 }); 39 40 assert.sameValue(executed, false); 41 42 reportCompare(0, 0);