summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/object/hasOwn.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/non262/object/hasOwn.js')
-rw-r--r--js/src/tests/non262/object/hasOwn.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/tests/non262/object/hasOwn.js b/js/src/tests/non262/object/hasOwn.js
new file mode 100644
index 0000000000..cb9ebda5db
--- /dev/null
+++ b/js/src/tests/non262/object/hasOwn.js
@@ -0,0 +1,18 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+assertEq(Object.hasOwn({}, "any"), false);
+assertThrowsInstanceOf(() => Object.hasOwn(null, "any"), TypeError);
+
+var x = { test: 'test value'}
+var y = {}
+var z = Object.create(x);
+
+assertEq(Object.hasOwn(x, "test"), true);
+assertEq(Object.hasOwn(y, "test"), false);
+assertEq(Object.hasOwn(z, "test"), false);
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);