test_stepping-17.js (2176B)
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 you can step from one script or event to another 8 */ 9 10 add_task( 11 threadFrontTest(async ({ commands, threadFront, debuggee }) => { 12 Cu.evalInSandbox( 13 `function blackboxed(callback) { return () => callback(); }`, 14 debuggee, 15 "1.8", 16 "http://example.com/blackboxed.js", 17 1 18 ); 19 20 const { sources } = await getSources(threadFront); 21 const blackboxedSourceFront = threadFront.source( 22 sources.find(source => source.url == "http://example.com/blackboxed.js") 23 ); 24 blackBox(blackboxedSourceFront); 25 26 const testStepping = async function (wrapperName, stepHandler, message) { 27 commands.scriptCommand.execute(`(function () { 28 const p = Promise.resolve(); 29 p.then(${wrapperName}(() => { debugger; })) 30 .then(${wrapperName}(() => { })); 31 })();`); 32 33 await waitForEvent(threadFront, "paused"); 34 const step = await stepHandler(threadFront); 35 Assert.equal(step.frame.where.line, 4, message); 36 await resume(threadFront); 37 }; 38 39 const stepTwice = async function () { 40 await stepOver(threadFront); 41 return stepOver(threadFront); 42 }; 43 44 await testStepping("", stepTwice, "Step over on the outermost frame"); 45 await testStepping("blackboxed", stepTwice, "Step over with blackboxing"); 46 await testStepping("", stepOut, "Step out on the outermost frame"); 47 await testStepping("blackboxed", stepOut, "Step out with blackboxing"); 48 49 commands.scriptCommand.execute(`(async function () { 50 const p = Promise.resolve(); 51 const p2 = p.then(() => { 52 debugger; 53 return "async stepping!"; 54 }); 55 debugger; 56 await p; 57 const result = await p2; 58 return result; 59 })(); 60 `); 61 62 await waitForEvent(threadFront, "paused"); 63 await stepOver(threadFront); 64 await stepOver(threadFront); 65 const step = await stepOut(threadFront); 66 await resume(threadFront); 67 Assert.equal(step.frame.where.line, 9, "Step out of promise into async fn"); 68 }) 69 );