extensible.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.preventExtensions(a);
  7. var b = {x:20, y:30};
  8. Object.preventExtensions(b);
  9. var c = {x:20, y:30};
  10. Object.preventExtensions(c);
  11. var d = {x:20, y:30};
  12. Object.preventExtensions(d);
  13. var e = {get x() {return 0;}, y:30};
  14. Object.preventExtensions(e);
  15. WScript.SetTimeout(testFunction, 50);
  16. /////////////////
  17. function testFunction()
  18. {
  19. a.z = 50;
  20. telemetryLog(`${Object.getOwnPropertyNames(a)}`, true);
  21. telemetryLog(`${Object.isExtensible(a)}`, true);
  22. delete b.x;
  23. telemetryLog(`${b.x}`, true);
  24. telemetryLog(`${Object.isExtensible(b)}`, true);
  25. c.x = 40;
  26. c.y = 60;
  27. telemetryLog(`${Object.getOwnPropertyNames(c)}`, true);
  28. telemetryLog(`${Object.isExtensible(c)}`, true);
  29. telemetryLog(`${c.x}`, true);
  30. delete d.x;
  31. Object.defineProperty(d, "y", {configurable: false});
  32. telemetryLog(`${Object.isSealed(d)}`, true);
  33. Object.defineProperty(d, "y", {writable: false});
  34. telemetryLog(`${Object.isFrozen(d)}`, true);
  35. delete e.x;
  36. Object.defineProperty(e, "y", {configurable: false});
  37. telemetryLog(`${Object.isSealed(e)}`, true);
  38. Object.defineProperty(e, "y", {writable: false});
  39. telemetryLog(`${Object.isFrozen(e)}`, true);
  40. }