Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / exception-thrown-from-eval-inside-closure.html
blob2203f853cf394c8d4c607817b03c02f2fb79a199
1 <p>This page tests whether an exception thrown from an eval inside a closure
2 prematurely tears off the closure's activation.
3 </p>
4 <p>If the test passes, you'll see a PASS message below.
5 </p>
6 <pre id="console"></pre>
8 <script>
9 function log(s)
11 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
14 function shouldBe(aDescription, a, b)
16 if (a === b) {
17 log("PASS: " + aDescription + " should be " + b + " and is.");
18 } else {
19 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
23 if (window.testRunner)
24 testRunner.dumpAsText();
26 // Create a function with an activation.
27 (function () {
28 var x = 1;
30 // Throw an exception inside an eval that requires a full scope chain.
31 try {
32 eval("(function () { throw 'exception'; })()");
33 } catch(e) {
36 // Set "x" by resolving through the activation.
37 (function () {
38 x = 2;
39 })();
41 // Test the local register for "x", which should have been set to 2 above.
42 shouldBe("x", x, 2);
43 }());
44 </script>