aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp16
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp39
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index b75f069fab..94494df4c0 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -1759,6 +1759,22 @@ void tst_QJSEngine::stacktrace()
QJSValue result2 = eng.evaluate(script2, fileName);
QVERIFY(!result2.isError());
QVERIFY(result2.isString());
+
+ {
+ QString script3 = QString::fromLatin1(
+ "'use strict'\n"
+ "function throwUp() { throw new Error('up') }\n"
+ "function indirectlyThrow() { return throwUp() }\n"
+ "indirectlyThrow()\n"
+ );
+ QJSValue result3 = eng.evaluate(script3);
+ QVERIFY(result3.isError());
+ QJSValue stack = result3.property("stack");
+ QVERIFY(stack.isString());
+ QString stackTrace = stack.toString();
+ QVERIFY(!stackTrace.contains(QStringLiteral("indirectlyThrow")));
+ QVERIFY(stackTrace.contains(QStringLiteral("elide")));
+ }
}
void tst_QJSEngine::numberParsing_data()
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index e83dac48fb..7139a1c952 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -35,6 +35,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlpropertyvalueinterceptor_p.h>
+#include <private/qqmlengine_p.h>
#include <private/qhashedstring_p.h>
#include "../../shared/util.h"
@@ -64,6 +65,7 @@ private slots:
void unregisterCustomSingletonType();
void normalizeUrls();
+ void unregisterAttachedProperties();
};
class TestType : public QObject
@@ -533,6 +535,43 @@ void tst_qqmlmetatype::normalizeUrls()
QVERIFY(!QQmlMetaType::qmlType(url, /*includeNonFileImports=*/true).isValid());
}
+void tst_qqmlmetatype::unregisterAttachedProperties()
+{
+ qmlClearTypeRegistrations();
+
+ const QUrl dummy("qrc:///doesnotexist.qml");
+ {
+ QQmlEngine e;
+ QQmlComponent c(&e);
+ c.setData("import QtQuick 2.2\n Item { }", dummy);
+
+ const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation", 2, 2);
+ QCOMPARE(attachedType.attachedPropertiesId(QQmlEnginePrivate::get(&e)),
+ attachedType.index());
+
+ QVERIFY(c.create());
+ }
+
+ qmlClearTypeRegistrations();
+ {
+ QQmlEngine e;
+ QQmlComponent c(&e);
+
+ // The extra import shuffles the type IDs around, so that we
+ // get a different ID for the attached properties. If the attached
+ // properties aren't properly cleared, this will crash.
+ c.setData("import QtQml.StateMachine 1.0 \n"
+ "import QtQuick 2.2 \n"
+ "Item { KeyNavigation.up: null }", dummy);
+
+ const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation", 2, 2);
+ QCOMPARE(attachedType.attachedPropertiesId(QQmlEnginePrivate::get(&e)),
+ attachedType.index());
+
+ QVERIFY(c.create());
+ }
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"