seal.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 a = {x:20, y:30};
  6. Object.seal(a);
  7. var b = {x:20, y:30};
  8. Object.seal(b);
  9. WScript.SetTimeout(testFunction, 50);
  10. /////////////////
  11. function testFunction()
  12. {
  13. a.x = 40;
  14. a.z = 50;
  15. telemetryLog(`${Object.getOwnPropertyNames(a)}`, true);
  16. telemetryLog(`${Object.isSealed(a)}`, true);
  17. telemetryLog(`${a.x}`, true);
  18. try
  19. {
  20. Object.defineProperty(a, 'x', { get: function() { return 'ohai'; } });
  21. }
  22. catch(e)
  23. {
  24. telemetryLog(`${e}`, true);
  25. }
  26. b.x = 40;
  27. delete b.x;
  28. b.z = 50;
  29. telemetryLog(`${Object.getOwnPropertyNames(b)}`, true);
  30. telemetryLog(`${Object.isSealed(b)}`, true);
  31. telemetryLog(`${b.x}`, true);
  32. }