aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-15 11:55:29 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-15 18:55:41 +0000
commit7f59171d00d185828b32d5d3e1cc9bcd34e7b003 (patch)
treef9624098ecf03e06fba7b2f66c992ffd6f592d1b
parent6747b6f3d68ad79c249d18e31eed0f3579848d12 (diff)
Fix Reflect.ownKeys
This function should not only return the names but also keys (symbols). Change-Id: I431e4aa8fa31ac6c16a415f00fb9f98405632562 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp24
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations2
2 files changed, 22 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 20ea39d4e5..90c39f7c37 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -211,12 +211,32 @@ ReturnedValue Reflect::method_isExtensible(const FunctionObject *f, const Value
}
-ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
if (!argc || !argv[0].isObject())
return f->engine()->throwTypeError();
- return ObjectPrototype::method_getOwnPropertyNames(f, thisObject, argv, argc);
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject O(scope, argv[0].toObject(scope.engine));
+ if (!O)
+ return Encode::undefined();
+
+ ScopedArrayObject keys(scope, ObjectPrototype::getOwnPropertyNames(scope.engine, O));
+
+ Heap::InternalClass *ic = O->d()->internalClass;
+ ScopedValue n(scope);
+ for (uint i = 0; i < ic->size; ++i) {
+ PropertyKey id = ic->nameMap.at(i);
+ n = id.asStringOrSymbol();
+ if (!n || !n->isSymbol())
+ continue;
+ keys->push_back(n);
+ }
+ return keys->asReturnedValue();
+
}
ReturnedValue Reflect::method_preventExtensions(const FunctionObject *f, const Value *, const Value *argv, int argc)
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index 57b0c365c9..c183fdb542 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -692,7 +692,6 @@ built-ins/Proxy/set/trap-is-undefined-receiver.js fails
built-ins/Proxy/setPrototypeOf/trap-is-not-callable-realm.js fails
built-ins/Reflect/construct/newtarget-is-not-constructor-throws.js fails
built-ins/Reflect/construct/return-with-newtarget-argument.js fails
-built-ins/Reflect/ownKeys/return-on-corresponding-order.js fails
built-ins/Reflect/set/creates-a-data-descriptor.js fails
built-ins/Reflect/set/different-property-descriptors.js fails
built-ins/Reflect/set/receiver-is-not-object.js fails
@@ -1320,7 +1319,6 @@ built-ins/TypedArrays/internals/HasProperty/key-is-not-integer.js fails
built-ins/TypedArrays/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js fails
built-ins/TypedArrays/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js fails
built-ins/TypedArrays/internals/OwnPropertyKeys/integer-indexes.js fails
-built-ins/TypedArrays/internals/OwnPropertyKeys/not-enumerable-keys.js fails
built-ins/TypedArrays/internals/Set/detached-buffer-key-is-not-numeric-index.js fails
built-ins/TypedArrays/internals/Set/detached-buffer-key-is-symbol.js fails
built-ins/TypedArrays/internals/Set/detached-buffer-realm.js fails