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/qqmllanguage | |
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/qqmllanguage')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/MyBaseComponent.qml | 24 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/scopedProperties.qml | 24 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 11 |
3 files changed, 59 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/MyBaseComponent.qml b/tests/auto/qml/qqmllanguage/data/MyBaseComponent.qml new file mode 100644 index 0000000000..dda4c486b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyBaseComponent.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +QtObject { + id: base + + property bool baseSuccess: false + + property string baseProperty: 'foo' + property string boundProperty: baseProperty + property alias aliasProperty: base.baseProperty + + function basePropertiesTest(expected) { + return (baseProperty == expected && + boundProperty == expected && + aliasProperty == expected); + } + + Component.onCompleted: { + if (basePropertiesTest('foo')) { + baseProperty = 'bar'; + baseSuccess = basePropertiesTest('bar'); + } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/scopedProperties.qml b/tests/auto/qml/qqmllanguage/data/scopedProperties.qml new file mode 100644 index 0000000000..6e3a46d754 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scopedProperties.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +MyBaseComponent { + id: extended + + property bool success: false + + property int baseProperty: 666 + property int boundProperty: baseProperty + property alias aliasProperty: extended.baseProperty + + function extendedPropertiesTest(expected) { + return (baseProperty == expected && + boundProperty == expected && + aliasProperty == expected); + } + + Component.onCompleted: { + if (basePropertiesTest('bar') && extendedPropertiesTest(666)) { + baseProperty = 999; + success = extendedPropertiesTest(999) && baseSuccess; + } + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 50e93ca3c2..2a09ef2848 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -186,6 +186,8 @@ private slots: void objectDeletionNotify_data(); void objectDeletionNotify(); + void scopedProperties(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -3111,6 +3113,15 @@ void tst_qqmllanguage::objectDeletionNotify() delete object; } +void tst_qqmllanguage::scopedProperties() +{ + QQmlComponent component(&engine, testFile("scopedProperties.qml")); + + QScopedPointer<QObject> o(component.create()); + QVERIFY(o != 0); + QVERIFY(o->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |