test_threadlifetime-02.js (1949B)
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 that thread-lifetime grips last past a resume. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ threadFront, debuggee, client }) => { 12 const packet = await executeOnNextTickAndWaitForPause( 13 () => evaluateTestCode(debuggee), 14 threadFront 15 ); 16 17 const pauseGrip = packet.frame.arguments[0]; 18 19 // Create a thread-lifetime actor for this object. 20 const response = await client.request({ 21 to: pauseGrip.actor, 22 type: "threadGrip", 23 }); 24 // Successful promotion won't return an error. 25 Assert.equal(response.error, undefined); 26 27 const packet2 = await resumeAndWaitForPause(threadFront); 28 29 // Verify that the promoted actor is returned again. 30 Assert.equal(pauseGrip.actor, packet2.frame.arguments[0].actor); 31 // Now that we've resumed, release the thread-lifetime grip. 32 const objFront = new ObjectFront( 33 threadFront.conn, 34 threadFront.targetFront, 35 threadFront, 36 pauseGrip 37 ); 38 await objFront.release(); 39 const objFront2 = new ObjectFront( 40 threadFront.conn, 41 threadFront.targetFront, 42 threadFront, 43 pauseGrip 44 ); 45 46 try { 47 await objFront2 48 .request({ to: pauseGrip.actor, type: "bogusRequest" }) 49 .catch(function (error) { 50 Assert.ok(!!error.message.match(/noSuchActor/)); 51 threadFront.resume(); 52 throw new Error(); 53 }); 54 ok(false, "bogusRequest should throw"); 55 } catch (e) { 56 ok(true, "bogusRequest thrown"); 57 } 58 }) 59 ); 60 61 function evaluateTestCode(debuggee) { 62 debuggee.eval( 63 "(" + 64 function () { 65 // These arguments are tested. 66 // eslint-disable-next-line no-unused-vars 67 function stopMe(arg1) { 68 debugger; 69 debugger; 70 } 71 stopMe({ obj: true }); 72 } + 73 ")()" 74 ); 75 }