tor-browser

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

block-decl-global-existing-non-enumerable-global-init.js (1300B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/annex-b-fns/global-existing-non-enumerable-global-init.case
      3 // - src/annex-b-fns/global/block.template
      4 /*---
      5 description: Variable binding is left in place by legacy function hoisting. CreateGlobalVariableBinding leaves the binding as non-enumerable even if it has the chance to change it to be enumerable. (Block statement in the global scope containing a function declaration)
      6 esid: sec-web-compat-globaldeclarationinstantiation
      7 flags: [generated, noStrict]
      8 includes: [fnGlobalObject.js, propertyHelper.js]
      9 info: |
     10    B.3.3.3 Changes to GlobalDeclarationInstantiation
     11 
     12    [...]
     13    Perform ? varEnvRec.CreateGlobalVarBinding(F, true).
     14    [...]
     15 
     16 ---*/
     17 var global = fnGlobalObject();
     18 Object.defineProperty(global, 'f', {
     19  value: 'x',
     20  enumerable: false,
     21  writable: true,
     22  configurable: true
     23 });
     24 
     25 $262.evalScript(`
     26 assert.sameValue(f, 'x');
     27 verifyProperty(global, 'f', {
     28  enumerable: false,
     29  writable: true,
     30  configurable: true
     31 }, { restore: true });
     32 `);
     33 
     34 $262.evalScript(`
     35 
     36 {
     37  function f() { return 'inner declaration'; }
     38 }
     39 
     40 `);
     41 
     42 $262.evalScript(`
     43 assert.sameValue(f(), 'inner declaration');
     44 verifyProperty(global, 'f', {
     45  enumerable: false,
     46  writable: true,
     47  configurable: true
     48 });
     49 `);
     50 
     51 reportCompare(0, 0);