tor-browser

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

switch-case-global-existing-global-init.js (1286B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/annex-b-fns/global-existing-global-init.case
      3 // - src/annex-b-fns/global/switch-case.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. (Function declaration in the `case` clause of a `switch` statement in the global scope)
      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: true,
     21  writable: true,
     22  configurable: false
     23 });
     24 
     25 $262.evalScript(`
     26 assert.sameValue(f, 'x');
     27 verifyProperty(global, 'f', {
     28  enumerable: true,
     29  writable: true,
     30  configurable: false
     31 }, { restore: true });
     32 `);
     33 
     34 $262.evalScript(`
     35 
     36 switch (1) {
     37  case 1:
     38    function f() { return 'inner declaration'; }
     39 }
     40 
     41 `);
     42 
     43 $262.evalScript(`
     44 verifyProperty(global, 'f', {
     45  enumerable: true,
     46  writable: true,
     47  configurable: false
     48 });
     49 `);
     50 
     51 reportCompare(0, 0);