blob: 712f6522600ed3156c58c0a4dc482933f4c117ea [file] [log] [blame]
<p>This page tests whether an exception thrown from an eval inside a closure
prematurely tears off the closure's activation.
</p>
<p>If the test passes, you'll see a PASS message below.
</p>
<pre id="console"></pre>
<script>
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
function shouldBe(aDescription, a, b)
{
if (a === b) {
log("PASS: " + aDescription + " should be " + b + " and is.");
} else {
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
}
if (window.layoutTestController)
layoutTestController.dumpAsText();
// Create a function with an activation.
(function () {
var x = 1;
// Throw an exception inside an eval that requires a full scope chain.
try {
eval("(function () { throw 'exception'; })()");
} catch(e) {
}
// Set "x" by resolving through the activation.
(function () {
x = 2;
})();
// Test the local register for "x", which should have been set to 2 above.
shouldBe("x", x, 2);
}());
</script>