proxy-issue884.js 834 B

123456789101112131415161718192021222324
  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 proxyHandler = {
  6. has(t, p) { WScript.Echo("has " + p); return true; }
  7. };
  8. var p = new Proxy({}, proxyHandler);
  9. var obj = {};
  10. try {
  11. Object.defineProperty(obj, "x", p);
  12. } catch (e) {
  13. if (e instanceof TypeError) {
  14. if (e.message !== "Invalid property descriptor: cannot both specify accessors and a 'value' attribute") {
  15. print('FAIL');
  16. } else {
  17. print('PASS');
  18. }
  19. } else {
  20. print('FAIL');
  21. }
  22. }