summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Proxy/ownkeys-allowed-types.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/Proxy/ownkeys-allowed-types.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/js/src/tests/non262/Proxy/ownkeys-allowed-types.js b/js/src/tests/non262/Proxy/ownkeys-allowed-types.js
new file mode 100644
index 0000000000..028ab85128
--- /dev/null
+++ b/js/src/tests/non262/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);