test_objectgrips-04.js (1797B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true); 7 registerCleanupFunction(() => { 8 Services.prefs.clearUserPref("security.allow_eval_with_system_principal"); 9 }); 10 11 add_task( 12 threadFrontTest(async ({ threadFront, debuggee }) => { 13 const packet = await executeOnNextTickAndWaitForPause( 14 () => evalCode(debuggee), 15 threadFront 16 ); 17 18 const args = packet.frame.arguments; 19 20 Assert.equal(args[0].class, "Object"); 21 22 const objectFront = threadFront.pauseGrip(args[0]); 23 const { ownProperties, prototype } = 24 await objectFront.getPrototypeAndProperties(); 25 Assert.equal(ownProperties.x.configurable, true); 26 Assert.equal(ownProperties.x.enumerable, true); 27 Assert.equal(ownProperties.x.writable, true); 28 Assert.equal(ownProperties.x.value, 10); 29 30 Assert.equal(ownProperties.y.configurable, true); 31 Assert.equal(ownProperties.y.enumerable, true); 32 Assert.equal(ownProperties.y.writable, true); 33 Assert.equal(ownProperties.y.value, "kaiju"); 34 35 Assert.equal(ownProperties.a.configurable, true); 36 Assert.equal(ownProperties.a.enumerable, true); 37 Assert.equal(ownProperties.a.get.getGrip().type, "object"); 38 Assert.equal(ownProperties.a.get.getGrip().class, "Function"); 39 Assert.equal(ownProperties.a.set.type, "undefined"); 40 41 Assert.notEqual(prototype, undefined); 42 43 await threadFront.resume(); 44 }) 45 ); 46 47 function evalCode(debuggee) { 48 debuggee.eval( 49 // These arguments are tested. 50 // eslint-disable-next-line no-unused-vars 51 function stopMe(arg1) { 52 debugger; 53 }.toString() 54 ); 55 debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })"); 56 }