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-non-configurable.js (1393B)


      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: >
      6    Modification of previously-existing non-configurable global property
      7 info: |
      8    [...]
      9    15. For each production f in functionsToInitialize, do
     10        a. Let fn be the sole element of the BoundNames of f.
     11        b. Let fo be the result of performing InstantiateFunctionObject for f
     12           with argument lexEnv.
     13        c. If varEnvRec is a global Environment Record, then
     14           i. Perform ? varEnvRec.CreateGlobalFunctionBinding(fn, fo, true).
     15    [...]
     16 
     17    8.1.1.4.18 CreateGlobalFunctionBinding
     18 
     19    [...]
     20    5. If existingProp is undefined or existingProp.[[Configurable]] is true,
     21       then
     22       [...]
     23    6. Else,
     24       b. Let desc be the PropertyDescriptor{[[Value]]: V }.
     25    7. Perform ? DefinePropertyOrThrow(globalObject, N, desc).
     26    [...]
     27 flags: [noStrict]
     28 includes: [propertyHelper.js]
     29 ---*/
     30 
     31 var initial;
     32 
     33 Object.defineProperty(this, 'f', {
     34  enumerable: true,
     35  writable: true,
     36  configurable: false
     37 });
     38 
     39 eval('initial = f; function f() { return 2222; }');
     40 
     41 verifyProperty(this, 'f', {
     42  writable: true,
     43  enumerable: true,
     44  configurable: false,
     45 });
     46 
     47 assert.sameValue(typeof initial, 'function');
     48 assert.sameValue(initial(), 2222);
     49 
     50 reportCompare(0, 0);