Proxy.js 634 B

123456789101112131415161718192021222324252627282930
  1. load("test-common.js");
  2. try {
  3. new Proxy({}, {});
  4. assertThrowsError(() => {
  5. new Proxy();
  6. }, {
  7. error: TypeError,
  8. message: "Proxy constructor requires at least two arguments",
  9. });
  10. assertThrowsError(() => {
  11. Proxy();
  12. }, {
  13. error: TypeError,
  14. message: "Proxy must be called with the 'new' operator",
  15. });
  16. assertThrowsError(() => {
  17. new Proxy(1, {});
  18. }, {
  19. error: TypeError,
  20. message: "Expected target argument of Proxy constructor to be object, got 1",
  21. });
  22. console.log("PASS");
  23. } catch (e) {
  24. console.log("FAIL: " + e);
  25. }