diff options
Diffstat (limited to 'js/src/tests/ecma_6/Proxy/ownkeys-allowed-types.js')
-rw-r--r-- | js/src/tests/ecma_6/Proxy/ownkeys-allowed-types.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Proxy/ownkeys-allowed-types.js b/js/src/tests/ecma_6/Proxy/ownkeys-allowed-types.js new file mode 100644 index 000000000..028ab8512 --- /dev/null +++ b/js/src/tests/ecma_6/Proxy/ownkeys-allowed-types.js @@ -0,0 +1,20 @@ +function makeProxy(type) { + return new Proxy({}, { ownKeys() { return [type]; } }); +} + +for (var type of [123, 12.5, true, false, undefined, null, {}, []]) { + var proxy = makeProxy(type); + assertThrowsInstanceOf(() => Object.ownKeys(proxy), TypeError); + assertThrowsInstanceOf(() => Object.getOwnPropertyNames(proxy), TypeError); +} + +type = Symbol(); +proxy = makeProxy(type); +assertEq(Object.getOwnPropertySymbols(proxy)[0], type); + +type = "abc"; +proxy = makeProxy(type); +assertEq(Object.getOwnPropertyNames(proxy)[0], type); + +if (typeof reportCompare === "function") + reportCompare(true, true); |