|
| 1 | +/* Any copyright is dedicated to the Public Domain. |
| 2 | + * http://creativecommons.org/publicdomain/zero/1.0/ */ |
| 3 | + |
| 4 | + requestLongerTimeout(2); |
| 5 | + |
| 6 | + async function stepOvers(dbg, count, onStep = () => {}) { |
| 7 | + let i = 0; |
| 8 | + while (i++ <= count) { |
| 9 | + await dbg.actions.stepOver(); |
| 10 | + await waitForPaused(dbg); |
| 11 | + onStep(dbg.getState()); |
| 12 | + } |
| 13 | + } |
| 14 | + |
| 15 | + |
| 16 | +async function testCase(dbg, { name, count, steps }) { |
| 17 | + invokeInTab(name); |
| 18 | + let locations = [] |
| 19 | + |
| 20 | + await stepOvers(dbg, count, state => { |
| 21 | + locations.push(dbg.selectors.getTopFrame(state).location) |
| 22 | + }); |
| 23 | + |
| 24 | + const formattedSteps = locations.map( |
| 25 | + ({line, column}) => `(${line},${column})` |
| 26 | + ).join(", ") |
| 27 | + |
| 28 | + is(formattedSteps, steps, name) |
| 29 | + |
| 30 | + await resume(dbg); |
| 31 | +} |
| 32 | + |
| 33 | +add_task(async function test() { |
| 34 | + const dbg = await initDebugger("doc-pause-points.html"); |
| 35 | + |
| 36 | + await testCase(dbg, { |
| 37 | + name: "statements", |
| 38 | + count: 7, |
| 39 | + steps: "(9,2), (10,4), (10,13), (11,2), (11,21), (12,2), (12,12), (13,0)" |
| 40 | + }); |
| 41 | + |
| 42 | + await testCase(dbg, { |
| 43 | + name: "expressions", |
| 44 | + count: 4, |
| 45 | + steps: "(40,2), (41,2), (41,8), (42,8), (43,0)" |
| 46 | + }); |
| 47 | + |
| 48 | + await testCase(dbg, { |
| 49 | + name: "sequences", |
| 50 | + count: 4, |
| 51 | + steps: "(23,2), (25,8), (29,8), (34,2), (37,0)" |
| 52 | + }); |
| 53 | + |
| 54 | + await testCase(dbg, { |
| 55 | + name: "flow", |
| 56 | + count: 8, |
| 57 | + steps: "(16,2), (17,12), (18,6), (19,8), (19,17), (19,8), (19,17), (19,8), (20,0)" |
| 58 | + }); |
| 59 | +}); |
0 commit comments