Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug...
[gecko.git] / js / src / jit-test / tests / debug / Script-getPossibleBreakpoints-02.js
blob56ea6620d3a0721b1cfd3b764931bfa988ce5c81
2 var global = newGlobal({newCompartment: true});
3 var dbg = Debugger(global);
4 dbg.onDebuggerStatement = onDebuggerStatement;
6 global.eval(`
7   debugger;
8   function f() {
9     var o = {};         // 4
11     o.a; o.a; o.a; o.a; // 6
12     o.a; o.a;           // 7
13     o.a; o.a; o.a;      // 8
14     o.a;                // 9
15   }                     // 10
16 `);
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);
58   assertBPCount({
59     minOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset,
60   }, 8);
61   assertBPError({ minOffset: "1" }, "minOffset", "not an integer");
62   assertBPCount({
63     maxOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset,
64   }, 4);
65   assertBPError({ maxOffset: "1" }, "maxOffset", "not an integer");
66   assertBPCount({
67     minOffset: fScript.getPossibleBreakpoints({ line: 6 })[2].offset,
68     maxOffset: fScript.getPossibleBreakpoints({ line: 7 })[1].offset,
69   }, 3);
71   function assertBPError(query, field, message) {
72     try {
73       fScript.getPossibleBreakpoints(query);
74       assertEq(false, true);
75     } catch (err) {
76       assertEq(err.message, `getPossibleBreakpoints' '${field}' is ${message}`);
77     }
78   }
80   function assertBPCount(query, count) {
81     assertEq(fScript.getPossibleBreakpoints(query).length, count);
82   }