1 This page verifies that eval has two meanings:
3 An operator: executes a script in local scope with the local scope's variable object and "this" object.
4 A global function: executes a script in global scope with the global scope's variable object and "this" object.
5 Meaning #2 should remain constant even if the global eval function is copied into a global variable ("globalEval") or a local variable ("localEval").
6 If the test passes, you'll see a series of pass messages below.
9 ----- Scope Chain for Getters: -----
11 PASS: eval("x") should be 1 and is.
12 PASS: window.eval("x") should be 0 and is.
13 PASS: globalEval("x") should be 0 and is.
14 PASS: localEval("x") should be 0 and is.
15 PASS: (function() { var eval = window.eval; return eval("x"); })() should be 1 and is.
17 ----- Variable Object: -----
19 PASS: eval("var y; "y" in window") should be false and is.
20 PASS: window.eval("var y; "y" in window") should be true and is.
21 PASS: globalEval("var y; "y" in window") should be true and is.
22 PASS: localEval("var y; "y" in window") should be true and is.
23 PASS: (function() { var eval = window.eval; return eval("var y; "y" in window"); })() should be false and is.
25 ----- Scope Chain for Setters: -----
27 PASS: eval("z = 1; window.z") should be 0 and is.
28 PASS: window.eval("z = 2; window.z") should be 2 and is.
29 PASS: globalEval("z = 3; window.z") should be 3 and is.
30 PASS: localEval("z = 4; window.z") should be 4 and is.
31 PASS: (function() { var eval = window.eval; return eval("z = 5; window.z"); })() should be 4 and is.
33 ----- This Object: -----
35 PASS: eval("this") should be ["this" object passed to .call()] and is.
36 PASS: window.eval("this") should be [object Window] and is.
37 PASS: globalEval("this") should be [object Window] and is.
38 PASS: localEval("this") should be [object Window] and is.
39 PASS: (function() { var eval = window.eval; return eval("this"); })() should be [object Window] and is.