summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-02-03 11:28:27 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2011-02-03 12:37:48 (GMT)
commit147df10403ba280b3f04c1e3d6c4b1cf386abe5d (patch)
tree4a7c906928fa514a245891920fca98c097c59b1c /tests
parent940d30e9cd76e9b98dd04c2e25a27b6a90bb34b9 (diff)
downloadQt-147df10403ba280b3f04c1e3d6c4b1cf386abe5d.zip
Qt-147df10403ba280b3f04c1e3d6c4b1cf386abe5d.tar.gz
Qt-147df10403ba280b3f04c1e3d6c4b1cf386abe5d.tar.bz2
Don't crash when creating backtrace for built-in JS function
When the JIT is enabled, NativeFunctionWrapper (used for built-in functions such as Array.prototype.forEach) inherits JSFunction, so we must check whether the function is actually a JS (script) function before we start accessing script-specific properties. Task-number: QTBUG-17137 Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 1a1576b..dd21555 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -860,6 +860,21 @@ void tst_QScriptContext::backtrace_data()
QTest::newRow("js recursive") << source << expected;
}
+
+ {
+ QString source = QString::fromLatin1(
+ "[0].forEach(\n"
+ " function() {\n"
+ " result = bt();\n"
+ "}); result");
+
+ QStringList expected;
+ expected << "<native>() at -1"
+ << "<anonymous>(0, 0, 0) at testfile:3"
+ << "forEach(0) at -1"
+ << "<global>() at testfile:4";
+ QTest::newRow("js callback from built-in") << source << expected;
+ }
}