| OLD | NEW |
| (Empty) |
| 1 <p>This tests verifies the identity of function.arguments vs 'arguments' used lo
cally. | |
| 2 </p> | |
| 3 <pre id="console"></pre> | |
| 4 | |
| 5 <script> | |
| 6 function log(s) | |
| 7 { | |
| 8 document.getElementById("console").appendChild(document.createTextNode(s
+ "\r\n")); | |
| 9 } | |
| 10 | |
| 11 function shouldBe(a, aDescription, b) | |
| 12 { | |
| 13 if (a == b) { | |
| 14 log("PASS: " + aDescription + " should be " + b + " and is."); | |
| 15 return; | |
| 16 } | |
| 17 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a
+ "."); | |
| 18 } | |
| 19 | |
| 20 if (window.testRunner) { | |
| 21 testRunner.dumpAsText(); | |
| 22 } | |
| 23 | |
| 24 function getArguments() { return arguments.callee.caller.arguments; } | |
| 25 | |
| 26 (function() { | |
| 27 shouldBe( | |
| 28 getArguments() == arguments, | |
| 29 "getArguments() == arguments", | |
| 30 false | |
| 31 ); | |
| 32 })(); | |
| 33 | |
| 34 (function() { | |
| 35 shouldBe( | |
| 36 getArguments() == eval('arguments'), | |
| 37 "getArguments() == eval('arguments')", | |
| 38 false | |
| 39 ); | |
| 40 })(); | |
| 41 | |
| 42 (function() { | |
| 43 eval(""); | |
| 44 shouldBe( | |
| 45 getArguments() == arguments, | |
| 46 "getArguments() == arguments {eval present}", | |
| 47 false | |
| 48 ); | |
| 49 })(); | |
| 50 | |
| 51 (function() { | |
| 52 var f = function() { }; | |
| 53 shouldBe( | |
| 54 getArguments() == arguments, | |
| 55 "getArguments() == arguments {function present}", | |
| 56 false | |
| 57 ); | |
| 58 })(); | |
| 59 | |
| 60 (function(x) { | |
| 61 var f = function() { return x; }; | |
| 62 shouldBe( | |
| 63 getArguments() == arguments, | |
| 64 "getArguments() == arguments {closure present}", | |
| 65 false | |
| 66 ); | |
| 67 })(0); | |
| 68 | |
| 69 (function() { | |
| 70 with ({ }) { }; | |
| 71 shouldBe( | |
| 72 getArguments() == arguments, | |
| 73 "getArguments() == arguments {with present}", | |
| 74 false | |
| 75 ); | |
| 76 })(); | |
| 77 | |
| 78 (function() { | |
| 79 try { } catch(e) { }; | |
| 80 shouldBe( | |
| 81 getArguments() == arguments, | |
| 82 "getArguments() == arguments {catch present}", | |
| 83 false | |
| 84 ); | |
| 85 })(); | |
| 86 (function() { | |
| 87 var arguments; | |
| 88 shouldBe( | |
| 89 getArguments() == arguments, | |
| 90 "getArguments() == arguments {var declaration}", | |
| 91 false | |
| 92 ); | |
| 93 })(); | |
| 94 | |
| 95 (function() { | |
| 96 function arguments() { }; | |
| 97 shouldBe( | |
| 98 getArguments() == arguments, | |
| 99 "getArguments() == arguments {function declaration}", | |
| 100 false | |
| 101 ); | |
| 102 })(); | |
| 103 </script> | |
| OLD | NEW |