tor-browser

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

non-definable-global-function.js (1171B)


      1 // Copyright (C) 2015 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es6id: 18.2.1.2
      6 description: Throws a TypeError if a global function cannot be defined.
      7 info: |
      8  Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict)
      9 
     10  ...
     11  8. For each d in varDeclarations, in reverse list order do
     12    a. If d is neither a VariableDeclaration or a ForBinding, then
     13      i. Assert: d is either a FunctionDeclaration or a GeneratorDeclaration.
     14      ii. NOTE If there are multiple FunctionDeclarations for the same name, the last declaration is used.
     15      iii. Let fn be the sole element of the BoundNames of d.
     16      iv. If fn is not an element of declaredFunctionNames, then
     17        1. If varEnvRec is a global Environment Record, then
     18          a. Let fnDefinable be varEnvRec.CanDeclareGlobalFunction(fn).
     19          b. ReturnIfAbrupt(fnDefinable).
     20          c. If fnDefinable is false, throw TypeError exception.
     21        ...
     22 flags: [noStrict]
     23 ---*/
     24 
     25 var error;
     26 try {
     27  eval("function NaN(){}");
     28 } catch (e) {
     29  error = e;
     30 }
     31 
     32 assert(error instanceof TypeError);
     33 
     34 reportCompare(0, 0);