1 <p>This page verifies that eval can be overridden.
</p>
2 <p>If the test passes, you'll see a series of pass messages below.
</p>
3 <pre id=
"console"></pre>
8 testRunner
.dumpAsText();
10 var x
= "built-in eval";
14 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
17 function shouldBe(aDescription
, a
, b
)
20 log("PASS: " + aDescription
+ " should be " + b
+ " and is.");
22 log("FAIL: " + aDescription
+ " should be " + b
+ " but instead is " + a
+ ".");
26 // Test overriding eval in global scope
27 eval = function() { return "global-scope eval override"; }
28 shouldBe('eval("x")', eval("x"), "global-scope eval override");
30 // Test overriding eval using "with"
31 with ({ eval: function() { return "with-scope eval override"; }}) {
32 shouldBe('eval("x")', eval("x"), "with-scope eval override");
35 // Test overriding eval using "catch"
37 throw function() { return "catch-scope eval override"; };
39 shouldBe('eval("x")', eval("x"), "catch-scope eval override");
42 // Test overriding eval using locally declared function
45 function eval() { return "local-scope eval override"; }
46 shouldBe('eval("x")', eval("x"), "local-scope eval override");