aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp31
-rw-r--r--src/qml/jsruntime/qv4objectproto_p.h18
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations24
3 files changed, 41 insertions, 32 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 0752c992f3..ebf1c713fb 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -97,6 +97,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1);
+ ctor->defineDefaultProperty(QStringLiteral("getOwnPropertySymbols"), method_getOwnPropertySymbols, 1);
ctor->defineDefaultProperty(QStringLiteral("assign"), method_assign, 2);
ctor->defineDefaultProperty(QStringLiteral("create"), method_create, 2);
ctor->defineDefaultProperty(QStringLiteral("defineProperty"), method_defineProperty, 3);
@@ -104,6 +105,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ctor->defineDefaultProperty(QStringLiteral("seal"), method_seal, 1);
ctor->defineDefaultProperty(QStringLiteral("freeze"), method_freeze, 1);
ctor->defineDefaultProperty(QStringLiteral("preventExtensions"), method_preventExtensions, 1);
+ ctor->defineDefaultProperty(QStringLiteral("is"), method_is, 2);
ctor->defineDefaultProperty(QStringLiteral("isSealed"), method_isSealed, 1);
ctor->defineDefaultProperty(QStringLiteral("isFrozen"), method_isFrozen, 1);
ctor->defineDefaultProperty(QStringLiteral("isExtensible"), method_isExtensible, 1);
@@ -137,6 +139,15 @@ ReturnedValue ObjectPrototype::method_getPrototypeOf(const FunctionObject *b, co
return (!!p ? p->asReturnedValue() : Encode::null());
}
+ReturnedValue ObjectPrototype::method_is(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ if (!argc)
+ return Encode(true);
+ if (argc == 1)
+ return Encode((argv[0].isUndefined() ? true : false));
+ return Encode(argv[0].sameValue(argv[1]));
+}
+
ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
Scope scope(b);
@@ -174,6 +185,26 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject *
return Encode(getOwnPropertyNames(scope.engine, argv[0]));
}
+ReturnedValue ObjectPrototype::method_getOwnPropertySymbols(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));
+ Heap::InternalClass *ic = O->d()->internalClass;
+ ScopedValue n(scope);
+ ScopedArrayObject array(scope, scope.engine->newArrayObject());
+ for (uint i = 0; i < ic->size; ++i) {
+ Identifier id = ic->nameMap.at(i);
+ n = id.asHeapObject();
+ if (!n || !n->isSymbol())
+ continue;
+ array->push_back(n);
+ }
+ return array->asReturnedValue();
+}
+
// 19.1.2.1
ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h
index 57aff87643..1a93685093 100644
--- a/src/qml/jsruntime/qv4objectproto_p.h
+++ b/src/qml/jsruntime/qv4objectproto_p.h
@@ -78,20 +78,22 @@ struct ObjectPrototype: Object
{
void init(ExecutionEngine *engine, Object *ctor);
- static ReturnedValue method_getPrototypeOf(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);
static ReturnedValue method_assign(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_create(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_defineProperties(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_defineProperty(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_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_isSealed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_isFrozen(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);
+ 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);
+ static ReturnedValue method_is(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_isExtensible(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isFrozen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isSealed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ 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_toString(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 e60754a103..626b1a39a4 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -942,10 +942,6 @@ 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/getOwnPropertySymbols/length.js fails
-built-ins/Object/getOwnPropertySymbols/name.js fails
-built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js fails
-built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js fails
built-ins/Object/getPrototypeOf/15.2.3.2-2-12.js fails
built-ins/Object/getPrototypeOf/15.2.3.2-2-13.js fails
built-ins/Object/getPrototypeOf/15.2.3.2-2-14.js fails
@@ -956,26 +952,6 @@ built-ins/Object/internals/DefineOwnProperty/consistent-value-function-arguments
built-ins/Object/internals/DefineOwnProperty/consistent-value-function-caller.js fails
built-ins/Object/internals/DefineOwnProperty/consistent-value-regexp-$1.js fails
built-ins/Object/internals/DefineOwnProperty/consistent-writable-regexp-$1.js fails
-built-ins/Object/is/length.js fails
-built-ins/Object/is/name.js fails
-built-ins/Object/is/not-same-value-x-y-boolean.js fails
-built-ins/Object/is/not-same-value-x-y-null.js fails
-built-ins/Object/is/not-same-value-x-y-number.js fails
-built-ins/Object/is/not-same-value-x-y-object.js fails
-built-ins/Object/is/not-same-value-x-y-string.js fails
-built-ins/Object/is/not-same-value-x-y-symbol.js fails
-built-ins/Object/is/not-same-value-x-y-type.js fails
-built-ins/Object/is/not-same-value-x-y-undefined.js fails
-built-ins/Object/is/object-is.js fails
-built-ins/Object/is/same-value-x-y-boolean.js fails
-built-ins/Object/is/same-value-x-y-empty.js fails
-built-ins/Object/is/same-value-x-y-null.js fails
-built-ins/Object/is/same-value-x-y-number.js fails
-built-ins/Object/is/same-value-x-y-object.js fails
-built-ins/Object/is/same-value-x-y-string.js fails
-built-ins/Object/is/same-value-x-y-symbol.js fails
-built-ins/Object/is/same-value-x-y-undefined.js fails
-built-ins/Object/is/symbol-object-is-same-value.js fails
built-ins/Object/isExtensible/15.2.3.13-1-1.js fails
built-ins/Object/isExtensible/15.2.3.13-1-2.js fails
built-ins/Object/isFrozen/15.2.3.12-1-1.js fails