aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp40
-rw-r--r--src/qml/jsruntime/qv4objectproto_p.h1
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations13
3 files changed, 41 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index dbbd59abc9..53113debb2 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -104,6 +104,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ctor->defineDefaultProperty(QStringLiteral("create"), method_create, 2);
ctor->defineDefaultProperty(QStringLiteral("defineProperty"), method_defineProperty, 3);
ctor->defineDefaultProperty(QStringLiteral("defineProperties"), method_defineProperties, 2);
+ ctor->defineDefaultProperty(QStringLiteral("entries"), method_entries, 1);
ctor->defineDefaultProperty(QStringLiteral("seal"), method_seal, 1);
ctor->defineDefaultProperty(QStringLiteral("freeze"), method_freeze, 1);
ctor->defineDefaultProperty(QStringLiteral("preventExtensions"), method_preventExtensions, 1);
@@ -338,6 +339,45 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b,
return O.asReturnedValue();
}
+ReturnedValue ObjectPrototype::method_entries(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();
+
+ ScopedArrayObject a(scope, scope.engine->newArrayObject());
+
+ ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
+ ScopedString name(scope);
+ ScopedArrayObject entry(scope);
+ while (1) {
+ name = it.nextPropertyNameAsString();
+ if (!name)
+ break;
+ entry = scope.engine->newArrayObject();
+ entry->push_back(name);
+ a->push_back(entry);
+ }
+
+ // now add values, do this after the loop above as reading out the values can have side effects
+ uint len = a->getLength();
+ ScopedValue value(scope);
+ for (uint i = 0; i < len; ++i) {
+ entry = a->get(PropertyKey::fromArrayIndex(i));
+ name = entry->get(PropertyKey::fromArrayIndex(0));
+ value = o->get(name->toPropertyKey());
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ entry->push_back(value);
+ }
+
+ return a.asReturnedValue();
+}
+
ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
const Value a = argc ? argv[0] : Primitive::undefinedValue();
diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h
index 0314c05766..51f0e32a2c 100644
--- a/src/qml/jsruntime/qv4objectproto_p.h
+++ b/src/qml/jsruntime/qv4objectproto_p.h
@@ -82,6 +82,7 @@ struct ObjectPrototype: Object
static ReturnedValue method_create(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_defineProperties(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ 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_getOwnPropertyNames(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 80efe69686..bab0e9cdd0 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -462,22 +462,9 @@ built-ins/Number/string-octal-literal.js fails
built-ins/Object/assign/source-own-prop-desc-missing.js fails
built-ins/Object/create/15.2.3.5-4-14.js strictFails
built-ins/Object/create/15.2.3.5-4-37.js strictFails
-built-ins/Object/entries/exception-during-enumeration.js fails
-built-ins/Object/entries/function-length.js fails
-built-ins/Object/entries/function-name.js fails
-built-ins/Object/entries/function-property-descriptor.js fails
-built-ins/Object/entries/getter-adding-key.js fails
built-ins/Object/entries/getter-making-future-key-nonenumerable.js fails
built-ins/Object/entries/getter-removing-future-key.js fails
-built-ins/Object/entries/inherited-properties-omitted.js fails
built-ins/Object/entries/observable-operations.js fails
-built-ins/Object/entries/primitive-booleans.js fails
-built-ins/Object/entries/primitive-numbers.js fails
-built-ins/Object/entries/primitive-strings.js fails
-built-ins/Object/entries/primitive-symbols.js fails
-built-ins/Object/entries/symbols-omitted.js fails
-built-ins/Object/entries/tamper-with-global-object.js fails
-built-ins/Object/entries/tamper-with-object-keys.js fails
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