summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/breakpoint-12.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/breakpoint-12.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/tests/debug/breakpoint-12.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/breakpoint-12.js b/js/src/jit-test/tests/debug/breakpoint-12.js
new file mode 100644
index 0000000000..96770c8f26
--- /dev/null
+++ b/js/src/jit-test/tests/debug/breakpoint-12.js
@@ -0,0 +1,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');