browser_dbg-pause-points.js (1946B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 "use strict"; 6 7 requestLongerTimeout(2); 8 9 async function testCase(dbg, { name, steps }) { 10 info(` ### Execute testCase "${name}"`); 11 12 const { 13 selectors: { getTopFrame, getCurrentThread }, 14 } = dbg; 15 const locations = []; 16 17 const recordFrame = () => { 18 const { line, column } = getTopFrame(getCurrentThread()).location; 19 locations.push([line, column]); 20 info(`Break on ${line}:${column}`); 21 }; 22 23 info("Trigger the expected debugger statement"); 24 const onPaused = waitForPaused(dbg); 25 invokeInTab(name); 26 await onPaused; 27 recordFrame(); 28 29 info("Start stepping over"); 30 for (let i = 0; i < steps.length - 1; i++) { 31 await dbg.actions.stepOver(); 32 await waitForPaused(dbg); 33 recordFrame(); 34 } 35 36 is(formatSteps(locations), formatSteps(steps), name); 37 38 await resume(dbg); 39 } 40 41 add_task(async function test() { 42 const dbg = await initDebugger("doc-pause-points.html", "pause-points.js"); 43 44 await selectSource(dbg, "pause-points.js"); 45 await testCase(dbg, { 46 name: "statements", 47 steps: [ 48 [9, 2], 49 [10, 4], 50 [10, 13], 51 [11, 2], 52 [11, 21], 53 [12, 2], 54 [12, 12], 55 [13, 0], 56 ], 57 }); 58 59 await testCase(dbg, { 60 name: "expressions", 61 steps: [ 62 [40, 2], 63 [41, 2], 64 [42, 12], 65 [43, 0], 66 ], 67 }); 68 69 await testCase(dbg, { 70 name: "sequences", 71 steps: [ 72 [23, 2], 73 [25, 12], 74 [29, 12], 75 [34, 2], 76 [37, 0], 77 ], 78 }); 79 80 await testCase(dbg, { 81 name: "flow", 82 steps: [ 83 [16, 2], 84 [17, 12], 85 [18, 10], 86 [19, 8], 87 [19, 17], 88 [19, 8], 89 [19, 17], 90 [19, 8], 91 ], 92 }); 93 }); 94 95 function formatSteps(steps) { 96 return steps.map(loc => `(${loc.join(",")})`).join(", "); 97 }