dynamic.js 941 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 throw from dynamic script.
  7. //
  8. function Dump(output)
  9. {
  10. if (this.WScript)
  11. {
  12. WScript.Echo(output);
  13. }
  14. else
  15. {
  16. alert(output);
  17. }
  18. }
  19. function runtest()
  20. {
  21. try {
  22. (function () {
  23. var f = new Function("function foo(){ throw new Error('This is my error'); } foo();");
  24. f();
  25. })();
  26. } catch(e) {
  27. Dump(TrimStackTracePath(e.stack));
  28. }
  29. }
  30. if (this.WScript && this.WScript.LoadScriptFile) {
  31. this.WScript.LoadScriptFile("../UnitTestFramework/TrimStackTracePath.js");
  32. }
  33. runtest();