aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-04 02:48:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-05 23:47:27 +0100
commit3a61da32e485621c9afbd453d22cbe1f6c25479e (patch)
tree7c7b145758c0370b23b0287f33d1124ae1d49660 /tests/auto
parent22b83ec28a7dfebe9d47ff5c98fddfdb492e4304 (diff)
Ensure the this object is set correctly to the scope object in binding expressions
This is a regression from 5.1 Change-Id: I61ad372a02d937c195dad74bd9fcb8fd4410d97a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/thisObject.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp10
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/thisObject.qml b/tests/auto/qml/qqmlecmascript/data/thisObject.qml
new file mode 100644
index 0000000000..c93d0302cf
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/thisObject.qml
@@ -0,0 +1,10 @@
+import QtQml 2.0
+QtObject {
+ property int value: 1
+ property QtObject subObject: QtObject {
+ property int value: 2
+ property int test: {
+ return this.value;
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index b1cf8c905f..f4641145ab 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -307,6 +307,7 @@ private slots:
void numberParsing();
void stringParsing();
void qtbug_32801();
+ void thisObject();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -7311,6 +7312,15 @@ void tst_qqmlecmascript::qtbug_32801()
QVERIFY(QMetaObject::invokeMethod(obj.data(), "emitTestSignal"));
}
+void tst_qqmlecmascript::thisObject()
+{
+ QQmlComponent component(&engine, testFileUrl("thisObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object);
+ QCOMPARE(qvariant_cast<QObject*>(object->property("subObject"))->property("test").toInt(), 2);
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"