test_objectgrips-19.js (1921B)
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 debuggee.eval( 14 // These arguments are tested. 15 // eslint-disable-next-line no-unused-vars 16 function stopMe(arg1) { 17 debugger; 18 }.toString() 19 ); 20 const tests = [ 21 { 22 value: true, 23 class: "Boolean", 24 }, 25 { 26 value: 123, 27 class: "Number", 28 }, 29 { 30 value: "foo", 31 class: "String", 32 }, 33 { 34 value: Symbol("bar"), 35 class: "Symbol", 36 name: "bar", 37 }, 38 ]; 39 for (const data of tests) { 40 debuggee.primitive = data.value; 41 const packet = await executeOnNextTickAndWaitForPause(() => { 42 debuggee.eval("stopMe(Object(primitive));"); 43 }, threadFront); 44 45 const [grip] = packet.frame.arguments; 46 check_wrapped_primitive_grip(grip, data); 47 48 await threadFront.resume(); 49 } 50 }) 51 ); 52 53 function check_wrapped_primitive_grip(grip, data) { 54 strictEqual(grip.class, data.class, "The grip has the proper class."); 55 56 if (!grip.preview) { 57 // In a worker thread Cu does not exist, the objects are considered unsafe and 58 // can't be unwrapped, so there is no preview. 59 return; 60 } 61 62 const value = grip.preview.wrappedValue; 63 if (data.class === "Symbol") { 64 strictEqual( 65 value.type, 66 "symbol", 67 "The wrapped value grip has symbol type." 68 ); 69 strictEqual( 70 value.name, 71 data.name, 72 "The wrapped value grip has the proper name." 73 ); 74 } else { 75 strictEqual(value, data.value, "The wrapped value is the primitive one."); 76 } 77 }