2 var global = newGlobal({newCompartment: true});
3 var dbg = Debugger(global);
4 dbg.onDebuggerStatement = onDebuggerStatement;
11 o.a; o.a; o.a; o.a; // 6
18 function onDebuggerStatement(frame) {
19 const fScript = frame.script.getChildScripts()[0];
21 const allBreakpoints = fScript.getPossibleBreakpoints();
22 assertEq(allBreakpoints.length, 12);
24 assertBPCount({ line: 4 }, 1);
25 assertBPCount({ line: 5 }, 0);
26 assertBPCount({ line: 6 }, 4);
27 assertBPCount({ line: 7 }, 2);
28 assertBPCount({ line: 8 }, 3);
29 assertBPCount({ line: 9 }, 1);
30 assertBPCount({ line: 10 }, 1);
32 assertBPCount({ line: 6, minColumn: 7 }, 3);
33 assertBPCount({ line: 6, maxColumn: 16 }, 3);
34 assertBPCount({ line: 6, minColumn: 7, maxColumn: 16 }, 2);
35 assertBPError({ line: 1, minLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'");
36 assertBPError({ line: 1, maxLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'");
37 assertBPError({ line: "1" }, "line", "not an integer");
39 assertBPCount({ minLine: 9 }, 2);
40 assertBPCount({ minLine: 9, minColumn: 0 }, 2);
41 assertBPCount({ minLine: 9, minColumn: 8 }, 1);
42 assertBPError({ minLine: "1" }, "minLine", "not an integer");
43 assertBPError({ minColumn: 1 }, "minColumn", "not allowed without 'line' or 'minLine'");
44 assertBPError({ minLine: 1, minColumn: "1" }, "minColumn", "not an integer");
46 assertBPCount({ maxLine: 7 }, 5);
47 assertBPCount({ maxLine: 7, maxColumn: 0 }, 5);
48 assertBPCount({ maxLine: 7, maxColumn: 8 }, 6);
49 assertBPError({ maxLine: "1" }, "maxLine", "not an integer");
50 assertBPError({ maxColumn: 1 }, "maxColumn", "not allowed without 'line' or 'maxLine'");
51 assertBPError({ maxLine: 1, maxColumn: "1" }, "maxColumn", "not an integer");
53 assertBPCount({ minLine: 6, maxLine: 8 }, 6);
54 assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8 }, 5);
55 assertBPCount({ minLine: 6, maxLine: 8, maxColumn: 8 }, 7);
56 assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8, maxColumn: 8 }, 6);
59 minOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset,
61 assertBPError({ minOffset: "1" }, "minOffset", "not an integer");
63 maxOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset,
65 assertBPError({ maxOffset: "1" }, "maxOffset", "not an integer");
67 minOffset: fScript.getPossibleBreakpoints({ line: 6 })[2].offset,
68 maxOffset: fScript.getPossibleBreakpoints({ line: 7 })[1].offset,
71 function assertBPError(query, field, message) {
73 fScript.getPossibleBreakpoints(query);
74 assertEq(false, true);
76 assertEq(err.message, `getPossibleBreakpoints' '${field}' is ${message}`);
80 function assertBPCount(query, count) {
81 assertEq(fScript.getPossibleBreakpoints(query).length, count);