envChain_object-executeInGlobalWithBindings-no-use.js (1641B)
1 // Verify the environment chain for Debugger.Object described in 2 // js/src/vm/EnvironmentObject.h. 3 4 // WithEnvironmentObject shouldn't be created if no binding is used. 5 6 const g = newGlobal({newCompartment: true}); 7 const dbg = new Debugger(); 8 const gw = dbg.addDebuggee(g); 9 10 const bindings = { 11 bindings_prop: 61, 12 }; 13 14 const envs = JSON.parse(gw.executeInGlobalWithBindings(` 15 var qualified = 10; 16 unqualified = 20; 17 let lexical = 30; 18 this.prop = 40; 19 20 const envs = []; 21 let env = getInnerMostEnvironmentObject(); 22 while (env) { 23 envs.push({ 24 type: getEnvironmentObjectType(env) || "*global*", 25 qualified: !!Object.getOwnPropertyDescriptor(env, "qualified"), 26 unqualified: !!Object.getOwnPropertyDescriptor(env, "unqualified"), 27 lexical: !!Object.getOwnPropertyDescriptor(env, "lexical"), 28 prop: !!Object.getOwnPropertyDescriptor(env, "prop"), 29 }); 30 31 env = getEnclosingEnvironmentObject(env); 32 } 33 JSON.stringify(envs); 34 `, bindings).return); 35 36 assertEq(envs.length, 2, 37 "WithEnvironmentObject shouldn't be created if no binding is " + 38 "used"); 39 40 let i = 0, env; 41 42 env = envs[i]; i++; 43 assertEq(env.type, "GlobalLexicalEnvironmentObject"); 44 assertEq(env.qualified, false); 45 assertEq(env.unqualified, false); 46 assertEq(env.lexical, true, "lexical must live in the GlobalLexicalEnvironmentObject"); 47 assertEq(env.prop, false); 48 49 env = envs[i]; i++; 50 assertEq(env.type, "*global*"); 51 assertEq(env.qualified, true, "qualified var must live in the global"); 52 assertEq(env.unqualified, true, "unqualified name must live in the global"); 53 assertEq(env.lexical, false); 54 assertEq(env.prop, true, "this property must live in the global");