summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/breakpoint-12.js
blob: 96770c8f2697730e8e4c0f76108bec97f7f37c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Removing a global as a debuggee forgets all its breakpoints.


var dbgA = new Debugger;
var logA = '';

var dbgB = new Debugger;
var logB = '';

var g1 = newGlobal({newCompartment: true});
g1.eval('function g1f() { print("Weltuntergang"); }');
var DOAg1 = dbgA.addDebuggee(g1);
var DOAg1f = DOAg1.getOwnPropertyDescriptor('g1f').value;
DOAg1f.script.setBreakpoint(0, { hit: () => { logA += '1'; } });

var DOBg1 = dbgB.addDebuggee(g1);
var DOBg1f = DOBg1.getOwnPropertyDescriptor('g1f').value;
DOBg1f.script.setBreakpoint(0, { hit: () => { logB += '1'; } });


var g2 = newGlobal({newCompartment: true});
g2.eval('function g2f() { print("Mokushi"); }');

var DOAg2 = dbgA.addDebuggee(g2);
var DOAg2f = DOAg2.getOwnPropertyDescriptor('g2f').value;
DOAg2f.script.setBreakpoint(0, { hit: () => { logA += '2'; } });

var DOBg2 = dbgB.addDebuggee(g2);
var DOBg2f = DOBg2.getOwnPropertyDescriptor('g2f').value;
DOBg2f.script.setBreakpoint(0, { hit: () => { logB += '2'; } });

assertEq(logA, '');
assertEq(logB, '');
g1.g1f();
g2.g2f();
assertEq(logA, '12');
assertEq(logB, '12');
logA = logB = '';

// Removing a global as a debuggee should make its breakpoint not hit.
dbgA.removeDebuggee(g2);
dbgB.removeDebuggee(g1);
assertEq(logA, '');
assertEq(logB, '');
g1.g1f();
g2.g2f();
assertEq(logA, '1');
assertEq(logB, '2');
logA = logB = '';

// Adding the global back as a debuggee should not resurrect its breakpoints.
dbgA.addDebuggee(g2);
dbgB.addDebuggee(g1);
assertEq(logA, '');
assertEq(logB, '');
g1.g1f();
g2.g2f();
assertEq(logA, '1');
assertEq(logB, '2');
logA = logB = '';

// But, we can set them again, and it all works.
DOAg2f.script.setBreakpoint(0, { hit: () => { logA += '2'; } });
assertEq(logA, '');
assertEq(logB, '');
g2.g2f();
g1.g1f();
assertEq(logA, '21');
assertEq(logB, '2');
logA = logB = '';

DOBg1f.script.setBreakpoint(0, { hit: () => { logB += '1'; } });
assertEq(logA, '');
assertEq(logB, '');
g2.g2f();
g1.g1f();
assertEq(logA, '21');
assertEq(logB, '21');