summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-source-location.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/debug/Frame-onPop-source-location.js')
-rw-r--r--js/src/jit-test/tests/debug/Frame-onPop-source-location.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Frame-onPop-source-location.js b/js/src/jit-test/tests/debug/Frame-onPop-source-location.js
new file mode 100644
index 0000000000..b0a01436d3
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Frame-onPop-source-location.js
@@ -0,0 +1,58 @@
+// Ensure onPop hook for the final return/yield uses the correct source location
+// (closing '}' of the function body).
+
+var g = newGlobal({newCompartment: true});
+var dbg = new Debugger(g);
+dbg.onEnterFrame = frame => {
+ if (frame.type === "global") {
+ return;
+ }
+ frame.onPop = c => {
+ if (c.yield !== true) {
+ const data = frame.script.getOffsetMetadata(frame.offset);
+ g.log.push(`pop(${data.lineNumber}:${data.columnNumber})`);
+ }
+ };
+};
+g.evaluate(` // line 1
+this.log = []; // 2
+function A() { // 3
+ log.push("A"); // 4
+ if (log === null) { // 5
+ throw "fail"; // 6
+ } // 7
+} // 8
+function* B() { // 9
+ log.push("B"); // 10
+ if (log === null) { // 11
+ throw "fail"; // 12
+ } // 13
+} // 14
+async function C() { // 15
+ log.push("C"); // 16
+ if (log === null) { // 17
+ throw "fail"; // 18
+ } // 19
+} // 20
+let D = async () => { // 21
+ log.push("D"); // 22
+ if (log === null) { // 23
+ throw "fail"; // 24
+ } // 25
+}; // 26
+class E extends class {} { // 27
+ constructor() { // 28
+ log.push("E"); // 29
+ super(); // 30
+ if (log === null) { // 31
+ throw "fail"; // 32
+ } // 33
+ } // 34
+} // 35
+A();
+for (let x of B()) {}
+C();
+D();
+new E();
+`);
+assertEq(g.log.join(","), "A,pop(8:0),B,pop(14:0),C,pop(20:0),D,pop(26:0),E,pop(27:16),pop(34:4)");