tor-browser

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

var-env-func-init-global-update-configurable.js (1447B)


      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: Modification of previously-existing configurable global property
      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           i. Perform ? varEnvRec.CreateGlobalFunctionBinding(fn, fo, true).
     14    [...]
     15 
     16    8.1.1.4.18 CreateGlobalFunctionBinding
     17 
     18    [...]
     19    5. If existingProp is undefined or existingProp.[[Configurable]] is true,
     20       then
     21       a. Let desc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true,
     22          [[Enumerable]]: true, [[Configurable]]: D}.
     23    6. Else,
     24       [...]
     25    7. Perform ? DefinePropertyOrThrow(globalObject, N, desc).
     26    [...]
     27 includes: [propertyHelper.js]
     28 ---*/
     29 
     30 var initial = null;
     31 
     32 Object.defineProperty(this, 'f', {
     33  enumerable: false,
     34  writable: false,
     35  configurable: true
     36 });
     37 
     38 (0, eval)('initial = f; function f() { return 345; }');
     39 
     40 verifyProperty(this, 'f', {
     41  writable: true,
     42  enumerable: true,
     43  configurable: true,
     44 });
     45 
     46 assert.sameValue(typeof initial, 'function');
     47 assert.sameValue(initial(), 345);
     48 
     49 reportCompare(0, 0);