diff options
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 30 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectproto_p.h | 1 | ||||
-rw-r--r-- | tests/auto/qml/ecmascripttests/TestExpectations | 11 |
3 files changed, 31 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 53113debb2..8d5eaa74c0 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -98,6 +98,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor) ctor->defineReadonlyConfigurableProperty(v4->id_length(), Primitive::fromInt32(1)); ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2); + ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptors"), method_getOwnPropertyDescriptors, 1); ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1); ctor->defineDefaultProperty(QStringLiteral("getOwnPropertySymbols"), method_getOwnPropertySymbols, 1); ctor->defineDefaultProperty(QStringLiteral("assign"), method_assign, 2); @@ -174,6 +175,35 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj return fromPropertyDescriptor(scope.engine, desc, attrs); } +ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptors(const FunctionObject *f, const Value *, const Value *argv, int argc) +{ + Scope scope(f); + if (!argc) + return scope.engine->throwTypeError(); + + ScopedObject o(scope, argv[0].toObject(scope.engine)); + if (scope.engine->hasException) + return Encode::undefined(); + + ScopedObject descriptors(scope, scope.engine->newObject()); + + ObjectIterator it(scope, o, ObjectIterator::NoFlags); + ScopedProperty pd(scope); + PropertyAttributes attrs; + ScopedPropertyKey key(scope); + ScopedObject entry(scope); + while (1) { + key = it.next(pd, &attrs); + if (!key->isValid()) + break; + entry = fromPropertyDescriptor(scope.engine, pd, attrs); + descriptors->put(key, entry); + } + + return descriptors.asReturnedValue(); + +} + ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject *b, const Value *, const Value *argv, int argc) { Scope scope(b); diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index 51f0e32a2c..5a225239ab 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -85,6 +85,7 @@ struct ObjectPrototype: Object static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_freeze(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertyDescriptors(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_getOwnPropertyNames(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_getOwnPropertySymbols(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index bab0e9cdd0..27da1d0f83 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -469,20 +469,9 @@ built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-212.js fails built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-213.js fails built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-214.js fails built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-215.js fails -built-ins/Object/getOwnPropertyDescriptors/function-length.js fails -built-ins/Object/getOwnPropertyDescriptors/function-name.js fails -built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js fails -built-ins/Object/getOwnPropertyDescriptors/inherited-properties-omitted.js fails -built-ins/Object/getOwnPropertyDescriptors/normal-object.js fails built-ins/Object/getOwnPropertyDescriptors/observable-operations.js fails -built-ins/Object/getOwnPropertyDescriptors/primitive-booleans.js fails -built-ins/Object/getOwnPropertyDescriptors/primitive-numbers.js fails -built-ins/Object/getOwnPropertyDescriptors/primitive-strings.js fails -built-ins/Object/getOwnPropertyDescriptors/primitive-symbols.js fails built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js fails built-ins/Object/getOwnPropertyDescriptors/symbols-included.js fails -built-ins/Object/getOwnPropertyDescriptors/tamper-with-global-object.js fails -built-ins/Object/getOwnPropertyDescriptors/tamper-with-object-keys.js fails built-ins/Object/keys/proxy-keys.js fails built-ins/Object/proto-from-ctor.js fails built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js strictFails |