Bug 1001368 - Tests. (r=jimb)
authorShu-yu Guo <shu@rfrn.org>
Tue, 29 Apr 2014 21:57:36 -0700
changeset 181342 ef50feec881a82d7ad3a195734dba9f389088734
parent 181341 0112ac69a293df106443627dff31f8b367f5af03
child 181343 a0619a71579dac10fdfb2bcbcf8a1059f952f6ac
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjimb
bugs1001368
milestone32.0a1
Bug 1001368 - Tests. (r=jimb)
js/src/jit-test/tests/debug/Frame-onPop-error-scope-unwind-01.js
js/src/jit-test/tests/debug/Frame-onPop-error-scope-unwind-02.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Frame-onPop-error-scope-unwind-01.js
@@ -0,0 +1,32 @@
+// Tests that exception handling works with block scopes.
+
+var g = newGlobal();
+var dbg = new Debugger(g);
+var correct;
+dbg.onEnterFrame = function (f) {
+  if (f.callee && f.callee.name == "f") {
+    f.onPop = function() {
+      // The scope at the point of onPop is the outermost.
+      correct = (f.environment.getVariable("e") === undefined &&
+                 f.environment.getVariable("outer") === 43);
+    };
+  }
+};
+g.eval("" + function f() {
+  var outer = 43;
+  try {
+    eval("");
+    throw 42;
+  } catch (e) {
+    noSuchFn(e);
+  }
+});
+
+
+try {
+  g.eval("f();");
+} catch (e) {
+  // The above is expected to throw.
+}
+
+assertEq(correct, true);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Frame-onPop-error-scope-unwind-02.js
@@ -0,0 +1,35 @@
+// Tests that exception handling works with block scopes.
+
+var g = newGlobal();
+var dbg = new Debugger(g);
+var correct;
+dbg.onEnterFrame = function (f) {
+  if (f.callee && f.callee.name == "f") {
+    f.onPop = function() {
+      // The scope at the point of onPop is the outermost.
+      correct = (f.environment.getVariable("e") === undefined &&
+                 f.environment.getVariable("outer") === 43);
+    };
+  }
+};
+g.eval("" + function f() {
+  var outer = 43;
+  // Surround with a loop to insert a loop trynote.
+  for (;;) {
+    try {
+      eval("");
+      throw 42;
+    } catch (e) {
+      noSuchFn(e);
+    }
+  }
+});
+
+
+try {
+  g.eval("f();");
+} catch (e) {
+  // The above is expected to throw.
+}
+
+assertEq(correct, true);