| This page verifies that eval has two meanings: |
| |
| An operator: executes a script in local scope with the local scope's variable object and "this" object. |
| A global function: executes a script in global scope with the global scope's variable object and "this" object. |
| Meaning #2 should remain constant even if the global eval function is copied into a global variable ("globalEval") or a local variable ("localEval"). |
| If the test passes, you'll see a series of pass messages below. |
| |
| |
| ----- Scope Chain for Getters: ----- |
| |
| PASS: eval("x") should be 1 and is. |
| PASS: window.eval("x") should be 0 and is. |
| PASS: globalEval("x") should be 0 and is. |
| PASS: localEval("x") should be 0 and is. |
| PASS: (function() { var eval = window.eval; return eval("x"); })() should be 1 and is. |
| |
| ----- Variable Object: ----- |
| |
| PASS: eval("var y; "y" in window") should be false and is. |
| PASS: window.eval("var y; "y" in window") should be true and is. |
| PASS: globalEval("var y; "y" in window") should be true and is. |
| PASS: localEval("var y; "y" in window") should be true and is. |
| PASS: (function() { var eval = window.eval; return eval("var y; "y" in window"); })() should be false and is. |
| |
| ----- Scope Chain for Setters: ----- |
| |
| PASS: eval("z = 1; window.z") should be 0 and is. |
| PASS: window.eval("z = 2; window.z") should be 2 and is. |
| PASS: globalEval("z = 3; window.z") should be 3 and is. |
| PASS: localEval("z = 4; window.z") should be 4 and is. |
| PASS: (function() { var eval = window.eval; return eval("z = 5; window.z"); })() should be 4 and is. |
| |
| ----- This Object: ----- |
| |
| PASS: eval("this") should be ["this" object passed to .call()] and is. |
| PASS: window.eval("this") should be [object Window] and is. |
| PASS: globalEval("this") should be [object Window] and is. |
| PASS: localEval("this") should be [object Window] and is. |
| PASS: (function() { var eval = window.eval; return eval("this"); })() should be [object Window] and is. |
| |