diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-26 14:37:36 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-06-26 15:48:00 +0200 |
commit | 5eceb1801ec881947f80f70f32ea46e00926194f (patch) | |
tree | f73d8eb6e7194935aa81427d245dde6361b07994 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | abfa03d7021aabe22f46a04d2b9d9f6adff2478a (diff) |
Fix thisObject when calling scope and context properties through lookups
Just like resolving the lookup initially, we need to set the base also
when hitting the cached lookup code path. The base is then used as this
object.
Fixes: QTBUG-76656
Change-Id: I6f6be05bc9875ddccc6e112e91176a0fa24a8fa1
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c24c495b13..18ff10b6f4 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -370,6 +370,7 @@ private slots: void undefinedPropertiesInObjectWrapper(); void hugeRegexpQuantifiers(); void singletonTypeWrapperLookup(); + void getThisObject(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -9029,6 +9030,17 @@ void tst_qqmlecmascript::singletonTypeWrapperLookup() QCOMPARE(test->property("secondLookup").toInt(), singleton2->testVar); } +void tst_qqmlecmascript::getThisObject() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("getThis.qml")); + QVERIFY(component.isReady()); + QScopedPointer<QObject> test(component.create()); + QVERIFY(!test.isNull()); + + QTRY_COMPARE(qvariant_cast<QObject *>(test->property("self")), test.data()); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |