FunctionName.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. //
  6. // Test function names showed in stack trace.
  7. //
  8. function Dump(output) {
  9. if (this.WScript) {
  10. WScript.Echo(output);
  11. } else {
  12. alert(output);
  13. }
  14. }
  15. if (this.WScript && this.WScript.LoadScriptFile) {
  16. this.WScript.LoadScriptFile("../UnitTestFramework/TrimStackTracePath.js");
  17. }
  18. try {
  19. var foo = function() {
  20. throw new Error("My Error!");
  21. };
  22. function func(){
  23. foo();
  24. }
  25. var constructed = new Function("func();");
  26. function bar(){
  27. (function(){
  28. eval("constructed();");
  29. })();
  30. }
  31. bar();
  32. } catch(e) {
  33. Dump(TrimStackTracePath(e.stack));
  34. }