diff --git a/src/builtins/BuiltinObject.cpp b/src/builtins/BuiltinObject.cpp index 63d942fc5..c2ce37482 100644 --- a/src/builtins/BuiltinObject.cpp +++ b/src/builtins/BuiltinObject.cpp @@ -156,6 +156,13 @@ static Value builtinObjectToString(ExecutionState& state, Value thisValue, size_ return strings->lazyObjectObjectToString().string(); } +static Value builtinObjectHasOwn(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional newTarget) +{ + Object* obj = argv[0].toObject(state); + Value key = argv[1].toPropertyKey(state); + return Value(obj->hasOwnProperty(state, ObjectPropertyName(state, key))); +} + static Value builtinObjectHasOwnProperty(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional newTarget) { Value key = argv[0].toPrimitive(state, Value::PrimitiveTypeHint::PreferString); @@ -869,6 +876,10 @@ void GlobalObject::installObject(ExecutionState& state) ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings.entries, builtinObjectEntries, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent))); + // Object.hasOwn + m_object->defineOwnProperty(state, ObjectPropertyName(strings.hasOwn), + ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings.hasOwn, builtinObjectHasOwn, 2, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent))); + // $19.1.3.2 Object.prototype.hasOwnProperty(V) m_objectPrototype->defineOwnProperty(state, ObjectPropertyName(strings.hasOwnProperty), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings.hasOwnProperty, builtinObjectHasOwnProperty, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent))); diff --git a/src/runtime/StaticStrings.h b/src/runtime/StaticStrings.h index c9c52bbcd..e7451c7f1 100644 --- a/src/runtime/StaticStrings.h +++ b/src/runtime/StaticStrings.h @@ -269,6 +269,7 @@ namespace Escargot { F(groups) \ F(has) \ F(hasInstance) \ + F(hasOwn) \ F(hasOwnProperty) \ F(hourCycle) \ F(hypot) \ diff --git a/tools/test/test262/excludelist.orig.xml b/tools/test/test262/excludelist.orig.xml index fc2b191e6..93420929f 100644 --- a/tools/test/test262/excludelist.orig.xml +++ b/tools/test/test262/excludelist.orig.xml @@ -246,64 +246,6 @@ TODO TODO TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO - TODO TODO TODO TODO