joepeck@webkit.org | 094223d5 | 2017-09-21 03:23:17 +0000 | [diff] [blame] | 1 | // Copyright (C) 2017 Ecma International. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | /*--- |
| 4 | description: | |
| 5 | Used to assert the correctness of object behavior in the presence |
| 6 | and context of Proxy objects. |
| 7 | ---*/ |
| 8 | |
keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 9 | function allowProxyTraps(overrides) { |
joepeck@webkit.org | 094223d5 | 2017-09-21 03:23:17 +0000 | [diff] [blame] | 10 | function throwTest262Error(msg) { |
| 11 | return function () { throw new Test262Error(msg); }; |
| 12 | } |
| 13 | if (!overrides) { overrides = {}; } |
| 14 | return { |
| 15 | getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), |
| 16 | setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), |
| 17 | isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), |
| 18 | preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), |
| 19 | getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), |
| 20 | has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), |
| 21 | get: overrides.get || throwTest262Error('[[Get]] trap called'), |
| 22 | set: overrides.set || throwTest262Error('[[Set]] trap called'), |
| 23 | deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), |
| 24 | defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), |
| 25 | enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), |
| 26 | ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), |
| 27 | apply: overrides.apply || throwTest262Error('[[Call]] trap called'), |
| 28 | construct: overrides.construct || throwTest262Error('[[Construct]] trap called') |
| 29 | }; |
keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 30 | } |