switch-dflt-global-existing-non-enumerable-global-init.js (1348B)
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/switch-dflt.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. (Funtion declaration in the `default` 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: 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 switch (1) { 37 default: 38 function f() { return 'inner declaration'; } 39 } 40 41 `); 42 43 $262.evalScript(` 44 assert.sameValue(f(), 'inner declaration'); 45 verifyProperty(global, 'f', { 46 enumerable: false, 47 writable: true, 48 configurable: true 49 }); 50 `); 51 52 reportCompare(0, 0);