summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/script/api/qscriptvalue.cpp8
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp4
2 files changed, 8 insertions, 4 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 79c769a..b23ac2c 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -1237,6 +1237,14 @@ QString QScriptValue::toString() const
JSC::JSValue savedException;
QScriptValuePrivate::saveException(exec, &savedException);
JSC::UString str = d->jscValue.toString(exec);
+ if (exec && exec->hadException()) {
+ JSC::JSValue savedException2;
+ QScriptValuePrivate::saveException(exec, &savedException2);
+ if (!str.size())
+ str = savedException2.toString(exec);
+ if (!eng_p->uncaughtException)
+ eng_p->uncaughtException = savedException2;
+ }
QScriptValuePrivate::restoreException(exec, savedException);
return QString(reinterpret_cast<const QChar*>(str.data()), str.size());
}
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index ddd846a..2ed6d6f 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -392,11 +392,8 @@ void tst_QScriptValue::toString()
" o.toString = function() { throw new Error('toString'); };"
" return o;"
"})()");
- QEXPECT_FAIL("", "Should produce an error message (or should it?)", Continue);
QCOMPARE(objectObject.toString(), QLatin1String("Error: toString"));
- QEXPECT_FAIL("", "hasUncaughtException() should return true", Continue);
QVERIFY(eng.hasUncaughtException());
- QEXPECT_FAIL("", "Should produce an error message (or should it?)", Continue);
QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: toString"));
}
{
@@ -411,7 +408,6 @@ void tst_QScriptValue::toString()
QVERIFY(objectObject.isObject());
QEXPECT_FAIL("", "Should return an error string", Continue);
QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Function.prototype.toString called on incompatible object"));
- QEXPECT_FAIL("", "hasUncaughtException() should return true", Continue);
QVERIFY(eng.hasUncaughtException());
eng.clearExceptions();
}