test_framebindings-03.js (1765B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /* strict mode code may not contain 'with' statements */ 5 /* eslint-disable strict */ 6 7 /** 8 * Check a |with| frame actor's bindings. 9 */ 10 11 add_task( 12 threadFrontTest(async ({ threadFront, debuggee }) => { 13 const packet = await executeOnNextTickAndWaitForPause( 14 () => evalCode(debuggee), 15 threadFront 16 ); 17 18 const env = await packet.frame.getEnvironment(); 19 Assert.notEqual(env, undefined); 20 21 const parentEnv = env.parent; 22 Assert.notEqual(parentEnv, undefined); 23 24 const bindings = parentEnv.bindings; 25 const args = bindings.arguments; 26 const vars = bindings.variables; 27 Assert.equal(args.length, 1); 28 Assert.equal(args[0].number.value, 10); 29 Assert.equal(vars.r.value, 10); 30 Assert.equal(vars.a.value, Math.PI * 100); 31 Assert.equal(vars.arguments.value.class, "Arguments"); 32 Assert.ok(!!vars.arguments.value.actor); 33 34 const objClient = threadFront.pauseGrip(env.object); 35 const response = await objClient.getPrototypeAndProperties(); 36 Assert.equal(response.ownProperties.PI.value, Math.PI); 37 Assert.equal(response.ownProperties.cos.value.getGrip().type, "object"); 38 Assert.equal(response.ownProperties.cos.value.getGrip().class, "Function"); 39 Assert.ok(!!response.ownProperties.cos.value.actorID); 40 41 await threadFront.resume(); 42 }) 43 ); 44 45 function evalCode(debuggee) { 46 /* eslint-disable */ 47 debuggee.eval( 48 "(" + 49 function () { 50 function stopMe(number) { 51 var a; 52 var r = number; 53 with (Math) { 54 a = PI * r * r; 55 debugger; 56 } 57 } 58 stopMe(10); 59 } + 60 ")()" 61 ); 62 /* eslint-enable */ 63 }