summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-11-18 10:03:19 (GMT)
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-11-22 08:03:00 (GMT)
commit718dc1e87de2cb991e4000e480ea61bf5d559e62 (patch)
treef38adf481d6c03c4fd3eeb0edc41d92dfadcc7ac /tests/auto/qscriptvalue/tst_qscriptvalue.cpp
parent3e1d5bee79b4e8dcb5b6f18497bbacf9d6b6a291 (diff)
downloadQt-718dc1e87de2cb991e4000e480ea61bf5d559e62.zip
Qt-718dc1e87de2cb991e4000e480ea61bf5d559e62.tar.gz
Qt-718dc1e87de2cb991e4000e480ea61bf5d559e62.tar.bz2
Fix QScriptValue::construct.
It is not allowed to mix values that were created in different QScriptEngine instances. Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 3fde1a9..97bbf26 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -3068,6 +3068,18 @@ void tst_QScriptValue::construct()
QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array"));
}
+void tst_QScriptValue::construct_twoEngines()
+{
+ QScriptEngine engine;
+ QScriptEngine otherEngine;
+ QScriptValue ctor = engine.evaluate("(function (a, b) { this.foo = 123; })");
+ QScriptValue arg(&otherEngine, 124567);
+ QTest::ignoreMessage(QtWarningMsg, "QScriptValue::construct() failed: cannot construct function with argument created in a different engine");
+ QVERIFY(!ctor.construct(arg).isValid());
+ QTest::ignoreMessage(QtWarningMsg, "QScriptValue::construct() failed: cannot construct function with argument created in a different engine");
+ QVERIFY(!ctor.construct(QScriptValueList() << arg << otherEngine.newObject()).isValid());
+}
+
void tst_QScriptValue::construct_constructorThrowsPrimitive()
{
QScriptEngine eng;