vso_os_1091425_2.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. function foo() {
  6. // override global accessor property 'foo' with a function
  7. // this should convert the property to a data property with
  8. // writable true, enumerable true, configurable false
  9. }
  10. eval("function bar() { /* same deal except for eval defined global functions configurable will be true */ }");
  11. (function verifyGlobalPropertyDescriptors() {
  12. var d = Object.getOwnPropertyDescriptor(this, 'foo');
  13. assertPropertyDoesNotExist(d, 'get');
  14. assertPropertyDoesNotExist(d, 'set');
  15. assertPropertyExists(d, 'configurable', false);
  16. assertPropertyExists(d, 'enumerable', true);
  17. assertPropertyExists(d, 'writable', true);
  18. assertPropertyExists(d, 'value', foo);
  19. d = Object.getOwnPropertyDescriptor(this, 'bar');
  20. assertPropertyDoesNotExist(d, 'get');
  21. assertPropertyDoesNotExist(d, 'set');
  22. assertPropertyExists(d, 'configurable', true);
  23. assertPropertyExists(d, 'enumerable', true);
  24. assertPropertyExists(d, 'writable', true);
  25. assertPropertyExists(d, 'value', bar);
  26. }).call(this);
  27. try {
  28. eval("function nonConfigurableBar() { /* try to override non-configurable global accessor property with a function definition */ }");
  29. } catch (e) {
  30. if (!(e instanceof TypeError) || e.message != "Cannot redefine non-configurable property 'nonConfigurableBar'")
  31. throw e;
  32. }