getOwnPropertyDescriptor.js 1.1 KB

123456789101112131415161718192021222324252627282930
  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. // Tests that getOwnPropertyDescriptor is not supported in IE8-mode for non-DOM objects.
  6. function TestGetOwnPropertyDescriptor(obj, property) {
  7. CatchAndWriteExceptions(function () {
  8. var desc = Object.getOwnPropertyDescriptor(obj, property);
  9. var exists = (desc != undefined);
  10. WScript.Echo("Found descriptor for " + property + ": " + exists);
  11. if (exists) {
  12. for (var i in desc) {
  13. WScript.Echo(i + "=" + desc[i]);
  14. }
  15. }
  16. });
  17. }
  18. function CatchAndWriteExceptions(func) {
  19. try {
  20. func();
  21. }
  22. catch (e) {
  23. WScript.Echo(e.name + ": " + e.number);
  24. }
  25. }
  26. TestGetOwnPropertyDescriptor({ foo: "fooValue" }, "foo");