diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-23 14:16:43 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-27 05:17:13 +0200 |
commit | 965588737321d10fd1fbca3f89b4c6257b7b5d47 (patch) | |
tree | 95d069b6ce910c4f8bf8f71d50bebc4fe35a6b1f /tests/auto/qml/qqmlpropertycache | |
parent | 4a161cfa0cf9167b575bdf7ff5685b9bf17c6960 (diff) |
Restrict v8 property lookup to the execution context
When resolving property names, only properties known to the current
context of execution should be available. If a property name has
been overriden by a component extension, code executing in the
context of the base component should resolve the property name to
the property available inside the base component or its bases.
Task-number: QTBUG-24891
Change-Id: I9687cc28e108226d5a939627a901c8254344b598
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache')
-rw-r--r-- | tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index de3c0412fb..a0b1b99f21 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -102,6 +102,11 @@ Q_SIGNALS: void signalB(); }; +QQmlPropertyData *cacheProperty(QQmlPropertyCache *cache, const char *name) +{ + return cache->property(QLatin1String(name), 0, 0); +} + void tst_qqmlpropertycache::properties() { QQmlEngine engine; @@ -111,16 +116,16 @@ void tst_qqmlpropertycache::properties() QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("propertyA"))); + QVERIFY(data = cacheProperty(cache, "propertyA")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); - QVERIFY(data = cache->property(QLatin1String("propertyB"))); + QVERIFY(data = cacheProperty(cache, "propertyB")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); - QVERIFY(data = cache->property(QLatin1String("propertyC"))); + QVERIFY(data = cacheProperty(cache, "propertyC")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); - QVERIFY(data = cache->property(QLatin1String("propertyD"))); + QVERIFY(data = cacheProperty(cache, "propertyD")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); } @@ -134,16 +139,16 @@ void tst_qqmlpropertycache::propertiesDerived() QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(&engine, object.metaObject())); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("propertyA"))); + QVERIFY(data = cacheProperty(cache, "propertyA")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); - QVERIFY(data = cache->property(QLatin1String("propertyB"))); + QVERIFY(data = cacheProperty(cache, "propertyB")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); - QVERIFY(data = cache->property(QLatin1String("propertyC"))); + QVERIFY(data = cacheProperty(cache, "propertyC")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); - QVERIFY(data = cache->property(QLatin1String("propertyD"))); + QVERIFY(data = cacheProperty(cache, "propertyD")); QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); } @@ -156,28 +161,28 @@ void tst_qqmlpropertycache::methods() QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("slotA"))); + QVERIFY(data = cacheProperty(cache, "slotA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); - QVERIFY(data = cache->property(QLatin1String("slotB"))); + QVERIFY(data = cacheProperty(cache, "slotB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); - QVERIFY(data = cache->property(QLatin1String("signalA"))); + QVERIFY(data = cacheProperty(cache, "signalA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); - QVERIFY(data = cache->property(QLatin1String("signalB"))); + QVERIFY(data = cacheProperty(cache, "signalB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); - QVERIFY(data = cache->property(QLatin1String("propertyAChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyAChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyBChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyBChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyCChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyCChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyDChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyDChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); } @@ -191,28 +196,28 @@ void tst_qqmlpropertycache::methodsDerived() QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(&engine, object.metaObject())); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("slotA"))); + QVERIFY(data = cacheProperty(cache, "slotA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); - QVERIFY(data = cache->property(QLatin1String("slotB"))); + QVERIFY(data = cacheProperty(cache, "slotB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); - QVERIFY(data = cache->property(QLatin1String("signalA"))); + QVERIFY(data = cacheProperty(cache, "signalA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); - QVERIFY(data = cache->property(QLatin1String("signalB"))); + QVERIFY(data = cacheProperty(cache, "signalB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); - QVERIFY(data = cache->property(QLatin1String("propertyAChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyAChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyBChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyBChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyCChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyCChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); - QVERIFY(data = cache->property(QLatin1String("propertyDChanged"))); + QVERIFY(data = cacheProperty(cache, "propertyDChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); } @@ -225,22 +230,22 @@ void tst_qqmlpropertycache::signalHandlers() QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("onSignalA"))); + QVERIFY(data = cacheProperty(cache, "onSignalA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); - QVERIFY(data = cache->property(QLatin1String("onSignalB"))); + QVERIFY(data = cacheProperty(cache, "onSignalB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyAChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyBChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyCChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyDChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); } @@ -254,22 +259,22 @@ void tst_qqmlpropertycache::signalHandlersDerived() QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(&engine, object.metaObject())); QQmlPropertyData *data; - QVERIFY(data = cache->property(QLatin1String("onSignalA"))); + QVERIFY(data = cacheProperty(cache, "onSignalA")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); - QVERIFY(data = cache->property(QLatin1String("onSignalB"))); + QVERIFY(data = cacheProperty(cache, "onSignalB")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyAChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyBChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyCChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); - QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged"))); + QVERIFY(data = cacheProperty(cache, "onPropertyDChanged")); QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); } |