diff --git a/crates/perry-runtime/src/object/global_this.rs b/crates/perry-runtime/src/object/global_this.rs index 0d9c621145..9d8b8ffbc3 100644 --- a/crates/perry-runtime/src/object/global_this.rs +++ b/crates/perry-runtime/src/object/global_this.rs @@ -1037,15 +1037,7 @@ extern "C" fn object_prototype_has_own_property_thunk( key: f64, ) -> f64 { let this_value = f64::from_bits(IMPLICIT_THIS.with(|c| c.get())); - unsafe { - super::js_native_call_method( - this_value, - b"hasOwnProperty".as_ptr() as *const i8, - "hasOwnProperty".len(), - &key as *const f64, - 1, - ) - } + super::object_ops::js_object_has_own(this_value, key) } extern "C" fn object_prototype_property_is_enumerable_thunk( diff --git a/test-parity/node-suite/globals/function-call-bind-builtin-prototypes.ts b/test-parity/node-suite/globals/function-call-bind-builtin-prototypes.ts new file mode 100644 index 0000000000..9dd33ded21 --- /dev/null +++ b/test-parity/node-suite/globals/function-call-bind-builtin-prototypes.ts @@ -0,0 +1,15 @@ +const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty); +const isEnumerable = Function.prototype.call.bind(Object.prototype.propertyIsEnumerable); + +function show(label: string, value: unknown) { + console.log(label, typeof value, String(value)); +} + +show("plain own", hasOwn({ a: 1 }, "a")); +show("array proto push", hasOwn(Array.prototype, "push")); +show("math abs", hasOwn(Math, "abs")); +show("object proto toString", hasOwn(Object.prototype, "toString")); +show("error proto message", hasOwn(Error.prototype, "message")); + +show("object proto toString enumerable", isEnumerable(Object.prototype, "toString")); +show("error proto message enumerable", isEnumerable(Error.prototype, "message"));