eval.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. var evalCode1;
  6. eval("evalCode1 = function() { return evalCode1 + ' ' + captured; }");
  7. var evalCode2 = undefined;
  8. var evalCode3 = undefined;
  9. var captured = "ok";
  10. function setCode2()
  11. {
  12. var notCaptured = 5;
  13. var captured = "bob in setCode2";
  14. eval("evalCode2 = function() { return evalCode2 + ' ' + captured; }");
  15. eval.call(this, "evalCode3 = function() { return evalCode3 + ' ' + captured; }")
  16. }
  17. setCode2();
  18. WScript.SetTimeout(testFunction, 50);
  19. function testFunction()
  20. {
  21. telemetryLog(`evalCode1: ${evalCode1()}`, true); //function () { return evalCode1 + ' ' + captured; } ok"
  22. telemetryLog(`evalCode2: ${evalCode2()}`, true); //function () { return evalCode2 + ' ' + captured; } bob in setCode2"
  23. telemetryLog(`evalCode3: ${evalCode3()}`, true); //function () { return evalCode3 + ' ' + captured; } ok"
  24. emitTTDLog(ttdLogURI);
  25. }