diff options
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectproto_p.h | 1 | ||||
-rw-r--r-- | tests/auto/qml/ecmascripttests/TestExpectations | 14 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 8d5eaa74c0..ed810cb456 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -115,6 +115,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor) ctor->defineDefaultProperty(QStringLiteral("isExtensible"), method_isExtensible, 1); ctor->defineDefaultProperty(QStringLiteral("keys"), method_keys, 1); ctor->defineDefaultProperty(QStringLiteral("setPrototypeOf"), method_setPrototypeOf, 2); + ctor->defineDefaultProperty(QStringLiteral("values"), method_values, 1); defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(v4->id_toString(), method_toString, 0); @@ -589,6 +590,34 @@ ReturnedValue ObjectPrototype::method_setPrototypeOf(const FunctionObject *f, co return o->asReturnedValue(); } +ReturnedValue ObjectPrototype::method_values(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 QV4::Encode::undefined(); + + ScopedArrayObject a(scope, scope.engine->newArrayObject()); + + ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); + ScopedPropertyKey key(scope); + ScopedProperty pd(scope); + ScopedValue value(scope); + PropertyAttributes attrs; + while (1) { + key = it.next(pd, &attrs); + if (!key->isValid()) + break; + value = o->getValue(pd->value, attrs); + a->push_back(value); + } + + return a.asReturnedValue(); +} + ReturnedValue ObjectPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) { ExecutionEngine *v4 = b->engine(); diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index 5a225239ab..e9515b5b68 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -97,6 +97,7 @@ struct ObjectPrototype: Object static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_seal(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_setPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_toLocaleString(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 27da1d0f83..b495be9f26 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -479,22 +479,8 @@ built-ins/Object/prototype/toString/no-prototype-property.js fails built-ins/Object/prototype/toString/proxy-array.js fails built-ins/Object/prototype/toString/proxy-function.js fails built-ins/Object/prototype/valueOf/S15.2.4.4_A14.js fails -built-ins/Object/values/exception-during-enumeration.js fails -built-ins/Object/values/function-length.js fails -built-ins/Object/values/function-name.js fails -built-ins/Object/values/function-property-descriptor.js fails built-ins/Object/values/getter-adding-key.js fails -built-ins/Object/values/getter-making-future-key-nonenumerable.js fails -built-ins/Object/values/getter-removing-future-key.js fails -built-ins/Object/values/inherited-properties-omitted.js fails built-ins/Object/values/observable-operations.js fails -built-ins/Object/values/primitive-booleans.js fails -built-ins/Object/values/primitive-numbers.js fails -built-ins/Object/values/primitive-strings.js fails -built-ins/Object/values/primitive-symbols.js fails -built-ins/Object/values/symbols-omitted.js fails -built-ins/Object/values/tamper-with-global-object.js fails -built-ins/Object/values/tamper-with-object-keys.js fails built-ins/Promise/S25.4.3.1_A1.1_T1.js fails built-ins/Promise/S25.4.3.1_A2.1_T1.js fails built-ins/Promise/S25.4.3.1_A2.2_T1.js fails |