tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

script-decl-func-err-non-extensible.js (1608B)


      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 function when there is no corresponding global property and
      8  the global object is non-extensible
      9 info: |
     10  [...]
     11  9. Let declaredFunctionNames be a new empty List.
     12  10. For each d in varDeclarations, in reverse list order do
     13      a. If d is neither a VariableDeclaration or a ForBinding, then
     14         i. Assert: d is either a FunctionDeclaration or a
     15            GeneratorDeclaration.
     16         ii. NOTE If there are multiple FunctionDeclarations for the same name,
     17             the last declaration is used.
     18         iii. Let fn be the sole element of the BoundNames of d.
     19         iv. If fn is not an element of declaredFunctionNames, then
     20             1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
     21             2. If fnDefinable is false, throw a TypeError exception.
     22 
     23  8.1.1.4.16 CanDeclareGlobalFunction
     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 existingProp be ? globalObject.[[GetOwnProperty]](N).
     30  5. If existingProp is undefined, return ? IsExtensible(globalObject).
     31 ---*/
     32 
     33 var executed = false;
     34 
     35 Object.preventExtensions(this);
     36 
     37 assert.throws(TypeError, function() {
     38  $262.evalScript('executed = true; function test262() {}');
     39 });
     40 
     41 assert.sameValue(executed, false);
     42 
     43 reportCompare(0, 0);