test_framebindings-05.js (1694B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check the environment bindings of a |with| in global scope. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ threadFront, debuggee }) => { 12 const packet = await executeOnNextTickAndWaitForPause( 13 () => evalCode(debuggee), 14 threadFront 15 ); 16 17 const env = await packet.frame.getEnvironment(); 18 Assert.notEqual(env, undefined); 19 20 const objClient = threadFront.pauseGrip(env.object); 21 let response = await objClient.getPrototypeAndProperties(); 22 Assert.equal(response.ownProperties.PI.value, Math.PI); 23 Assert.equal(response.ownProperties.cos.value.getGrip().type, "object"); 24 Assert.equal(response.ownProperties.cos.value.getGrip().class, "Function"); 25 Assert.ok(!!response.ownProperties.cos.value.actorID); 26 27 // Skip the global lexical scope. 28 const parentEnv = env.parent.parent; 29 Assert.notEqual(parentEnv, undefined); 30 31 const parentClient = threadFront.pauseGrip(parentEnv.object); 32 response = await parentClient.getPrototypeAndProperties(); 33 Assert.equal(response.ownProperties.a.value, Math.PI * 100); 34 Assert.equal(response.ownProperties.r.value, 10); 35 Assert.equal(response.ownProperties.Object.value.getGrip().type, "object"); 36 Assert.equal( 37 response.ownProperties.Object.value.getGrip().class, 38 "Function" 39 ); 40 Assert.ok(!!response.ownProperties.Object.value.actorID); 41 42 await threadFront.resume(); 43 }) 44 ); 45 46 function evalCode(debuggee) { 47 debuggee.eval( 48 "var a, r = 10;\n" + 49 "with (Math) {\n" + 50 " a = PI * r * r;\n" + 51 " debugger;\n" + 52 "}" 53 ); 54 }