tor-browser

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

var-env-func-init-local-new-delete.js (1311B)


      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-evaldeclarationinstantiation
      5 description: Newly-created local binding may be deleted
      6 info: |
      7    [...]
      8    15. For each production f in functionsToInitialize, do
      9        a. Let fn be the sole element of the BoundNames of f.
     10        b. Let fo be the result of performing InstantiateFunctionObject for f
     11           with argument lexEnv.
     12        c. If varEnvRec is a global Environment Record, then
     13           [...]
     14        d. Else,
     15           i. Let bindingExists be varEnvRec.HasBinding(fn).
     16           ii. If bindingExists is false, then
     17               1. Let status be ! varEnvRec.CreateMutableBinding(fn, true).
     18               2. Assert: status is not an abrupt completion because of
     19                  validation preceding step 12.
     20               3. Perform ! varEnvRec.InitializeBinding(fn, fo).
     21           [...]
     22 flags: [noStrict]
     23 ---*/
     24 
     25 var initial, postDeletion;
     26 (function() {
     27  eval('initial = f; delete f; postDeletion = function() { f; }; function f() { return 33; }');
     28 }());
     29 
     30 assert.sameValue(typeof initial, 'function');
     31 assert.sameValue(initial(), 33);
     32 assert.throws(ReferenceError, postDeletion, 'binding may be deleted');
     33 
     34 reportCompare(0, 0);