freeze.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.freeze(a);
  7. var b = {x:20, y:30};
  8. Object.freeze(b);
  9. var c = {x:20, y:30};
  10. Object.freeze(c);
  11. WScript.SetTimeout(testFunction, 50);
  12. /////////////////
  13. function testFunction()
  14. {
  15. a.z = 50;
  16. try
  17. {
  18. Object.defineProperty(a, 'ohai', { value: 17 });
  19. }
  20. catch(e)
  21. {
  22. telemetryLog(`${e}`, true);
  23. }
  24. telemetryLog(`${Object.getOwnPropertyNames(a)}`, true);
  25. telemetryLog(`${Object.isFrozen(a)}`, true);
  26. delete b.x;
  27. telemetryLog(`${Object.getOwnPropertyNames(b)}`, true);
  28. telemetryLog(`${Object.isFrozen(b)}`, true);
  29. telemetryLog(`${b.x}`, true);
  30. a.c = 40;
  31. a.c = 60;
  32. telemetryLog(`${Object.getOwnPropertyNames(c)}`, true);
  33. telemetryLog(`${Object.isFrozen(c)}`, true);
  34. telemetryLog(`${c.x}`, true);
  35. emitTTDLog(ttdLogURI);
  36. }