evalThis.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. "use strict";
  6. var echo = WScript.Echo;
  7. echo("** Checking 'this' using 'eval' in global scope");
  8. eval("echo(this);");
  9. eval("'use strict'; echo(this);");
  10. eval("eval('echo(this);');");
  11. eval("'use strict'; eval('echo(this);');");
  12. echo("** Checking 'this' using 'my_eval' in global scope");
  13. var my_eval = eval;
  14. my_eval("echo(this);");
  15. my_eval("'use strict'; echo(this);");
  16. my_eval("eval('echo(this);');");
  17. my_eval("'use strict'; eval('echo(this);');");
  18. function foo() {
  19. echo("** Checking 'this' using 'eval' in function scope");
  20. eval("echo(this);");
  21. eval("'use strict'; echo(this);");
  22. eval("eval('echo(this);');");
  23. eval("'use strict'; eval('echo(this);');");
  24. echo("** Checking 'this' using 'my_eval' in function scope");
  25. var my_eval = eval;
  26. my_eval("echo(this);");
  27. my_eval("'use strict'; echo(this);");
  28. my_eval("eval('echo(this);');");
  29. my_eval("'use strict'; eval('echo(this);');");
  30. }
  31. foo();