aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-04-18 10:18:48 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-05-02 15:46:26 +0000
commitd258c904a6027007d00526ab38b8cc5ba2aed3bf (patch)
tree5adcfee69c31dc6ab1c8bbe5950415b7d7370e23 /tests/auto
parent02fec0dbd7b9774d17690e378b814ff075ac6299 (diff)
Throw type errors when attempting to mutate read-only sequence properties
Calling for example Qt.application.arguments.push("...") should throw an exception. Task-number: QTBUG-67774 Change-Id: Ifd5cd3357dde510cca77b9b32c9f55f8f72837ff Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml16
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp10
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml
new file mode 100644
index 0000000000..3f838fe8f2
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml
@@ -0,0 +1,16 @@
+import QtQml 2.0
+QtObject {
+ function tryWritingReadOnlySequence() {
+ try {
+ Qt.application.arguments.push("hello")
+ } catch (e) {
+
+ try {
+ Qt.application.arguments.sort()
+ } catch (e) {
+ return true
+ }
+ }
+ return false
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 5a7ef01eea..b6f753b313 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -5784,6 +5784,16 @@ void tst_qqmlecmascript::assignSequenceTypes()
QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
delete object;
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.8.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != nullptr);
+ QVariant result;
+ QMetaObject::invokeMethod(object.data(), "tryWritingReadOnlySequence", Q_RETURN_ARG(QVariant, result));
+ QVERIFY(result.type() == QVariant::Bool);
+ QVERIFY(result.toBool());
+ }
}
// Test that assigning a null object works