diff options
Diffstat (limited to 'tests/auto')
4 files changed, 28 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml new file mode 100644 index 0000000000..f490848caf --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + Component.onCompleted: v8function() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 9213b61a3c..721c719911 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -101,6 +101,12 @@ public: void setWidth(int) { } }; +void MyQmlObject::v8function(QDeclarativeV8Function *args) +{ + const char *error = "Exception thrown from within QObject slot"; + v8::ThrowException(v8::Exception::Error(v8::String::New(error))); +} + static QJSValue script_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 9fbbd5052b..12563d6588 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -59,6 +59,7 @@ #include <private/qv8gccallback_p.h> #include <private/qdeclarativeengine_p.h> +#include <private/qv8engine_p.h> class MyQmlAttachedObject : public QObject { @@ -184,6 +185,7 @@ public slots: void setString(const QString &s) { m_string = s; } void myinvokable(MyQmlObject *o) { myinvokableObject = o; } void variantMethod(const QVariant &v) { m_variant = v; } + void v8function(QDeclarativeV8Function*); private: friend class tst_qdeclarativeecmascript; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 57e4fe1a46..0a44c3eec7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -222,7 +222,7 @@ private slots: void callQtInvokables(); void invokableObjectArg(); void invokableObjectRet(); - + void qtbug_20344(); void revisionErrors(); void revision(); @@ -4910,6 +4910,19 @@ void tst_qdeclarativeecmascript::aliasToCompositeElement() delete object; } +void tst_qdeclarativeecmascript::qtbug_20344() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_20344.qml")); + + QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + void tst_qdeclarativeecmascript::revisionErrors() { { |