aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-09-11 09:53:39 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-09-11 11:41:47 +0200
commit4be5278c1e871b48ab66fc0c27443798e97220b6 (patch)
tree364d8ece4399c0ceffd2f7954e93807bb559e93b /tests
parent1c6633ff127c59075a53732cb64a3aa9e7b0e1cf (diff)
parent38fe461e2cc4bf3aebcb98d25c643bfe6653120a (diff)
Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp19
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.js7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceSort.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp11
5 files changed, 48 insertions, 1 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 87549d2019..741fa9f04d 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -127,6 +127,7 @@ private slots:
void reentrancy_objectCreation();
void jsIncDecNonObjectProperty();
void JSONparse();
+ void arraySort();
void qRegExpInport_data();
void qRegExpInport();
@@ -2742,6 +2743,24 @@ void tst_QJSEngine::JSONparse()
QVERIFY(ret.isObject());
}
+void tst_QJSEngine::arraySort()
+{
+ // tests that calling Array.sort with a bad sort function doesn't cause issues
+ // Using std::sort is e.g. not safe when used with a bad sort function and causes
+ // crashes
+ QJSEngine eng;
+ eng.evaluate("function crashMe() {"
+ " var data = [];"
+ " for (var i = 0; i < 50; i++) {"
+ " data[i] = 'whatever';"
+ " }"
+ " data.sort(function(a, b) {"
+ " return -1;"
+ " });"
+ "}"
+ "crashMe();");
+}
+
static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; }
void tst_QJSEngine::qRegExpInport_data()
diff --git a/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.js b/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.js
new file mode 100644
index 0000000000..aabcc9f3b8
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.js
@@ -0,0 +1,7 @@
+.pragma library
+
+var as = undefined
+function isLegal() {
+ var as = true;
+ return as;
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.qml b/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.qml
new file mode 100644
index 0000000000..17d12199d7
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/importScriptsWithoutQmlMode.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+import "importScriptsWithoutQmlMode.js" as Export
+
+Rectangle {
+ id: root
+ property bool success: false
+
+ Component.onCompleted: success = Export.isLegal()
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
index 5e2892a31d..b130408c18 100644
--- a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
@@ -23,7 +23,7 @@ Item {
}
function compareStrings(a, b) {
- return (a < b) ? 1 : -1;
+ return (a == b) ? 0 : ((a < b) ? 1 : -1);
}
function compareNumbers(a, b) {
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 7273cfbe5d..06d061a9fa 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -315,6 +315,7 @@ private slots:
void lazyBindingEvaluation();
void varPropertyAccessOnObjectWithInvalidContext();
void importedScriptsAccessOnObjectWithInvalidContext();
+ void importedScriptsWithoutQmlMode();
void contextObjectOnLazyBindings();
void garbageCollectionDuringCreation();
void qtbug_39520();
@@ -7636,6 +7637,16 @@ void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext()
QTRY_VERIFY(obj->property("success") == true);
}
+void tst_qqmlecmascript::importedScriptsWithoutQmlMode()
+{
+ QQmlComponent component(&engine, testFileUrl("importScriptsWithoutQmlMode.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
+ qDebug() << component.errors().first().toString();
+ QVERIFY(!obj.isNull());
+ QTRY_VERIFY(obj->property("success") == true);
+}
+
void tst_qqmlecmascript::contextObjectOnLazyBindings()
{
QQmlComponent component(&engine, testFileUrl("contextObjectOnLazyBindings.qml"));