rootObj-1.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 x = "x.original";
  6. var reset = function () {
  7. x = "x.original";
  8. }
  9. var test = function () {
  10. var z = "z.original";
  11. function innerTest() {
  12. x = "x.overwritten";
  13. z = x;
  14. }
  15. innerTest();
  16. return z;
  17. }
  18. test();
  19. reset();
  20. test();
  21. reset();
  22. function makeGlobalPropertyReadOnly(p) {
  23. Object.defineProperty(this, p, { writable: false });
  24. }
  25. function reportGlobalPropertyDescriptor(p) {
  26. WScript.Echo(p + ".configurable = " + Object.getOwnPropertyDescriptor(this, p).configurable);
  27. WScript.Echo(p + ".writable = " + Object.getOwnPropertyDescriptor(this, p).writable);
  28. }
  29. reportGlobalPropertyDescriptor("x");
  30. makeGlobalPropertyReadOnly("x");
  31. reportGlobalPropertyDescriptor("x");
  32. var result = test();
  33. WScript.Echo("x: " + x);
  34. WScript.Echo("result: " + result);