diff options
-rw-r--r-- | Source/WebCore/bridge/qt/qt_runtime.cpp | 7 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp | 28 |
2 files changed, 34 insertions, 1 deletions
diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 58259ff3e..cc1c19cf9 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -1577,7 +1577,12 @@ void QtConnectionObject::execute(void** argv) args[i] = convertQVariantToValue(m_context, m_rootObject, QVariant(argType, argv[i+1]), ignoredException); } - JSObjectCallAsFunction(m_context, m_receiverFunction, m_receiver, argc, args.data(), 0); + JSValueRef call_exception = 0; + ExecState* exec = toJS(m_context); + JSObjectCallAsFunction(m_context, m_receiverFunction, m_receiver, argc, args.data(), &call_exception); + if (call_exception) { + WebCore::reportException(exec, toJS(exec, call_exception)); + } } bool QtConnectionObject::match(JSContextRef context, QObject* sender, int signalIndex, JSObjectRef receiver, JSObjectRef receiverFunction) diff --git a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp index 52e6422b1..18d82625c 100644 --- a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp +++ b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp @@ -642,6 +642,7 @@ private Q_SLOTS: void introspectQtMethods_data(); void introspectQtMethods(); void scriptablePlugin(); + void exceptionInSlot(); private: QString evalJS(const QString& s) @@ -2234,5 +2235,32 @@ void tst_QObjectBridge::scriptablePlugin() QCOMPARE(result.toString(), QLatin1String("42")); } +class WebPageWithConsoleCapture : public QWebPage +{ +public: + void javaScriptConsoleMessage(const QString &message, int, const QString &) + { + consoleMessages << message; + } + + QStringList consoleMessages; +}; + +void tst_QObjectBridge::exceptionInSlot() +{ + WebPageWithConsoleCapture page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("myObject", m_myObject); + frame->evaluateJavaScript( + "myHandler = function() { window.gotSignal = true; throw 'exception in slot'; };" + "myObject.mySignal.connect(myHandler);" + "gotSignal = false;" + "myObject.mySignal();" + ); + QString ret = frame->evaluateJavaScript("gotSignal").toString(); + QCOMPARE(ret, sTrue); + QCOMPARE(page.consoleMessages, QStringList() << "exception in slot"); +} + QTEST_MAIN(tst_QObjectBridge) #include "tst_qobjectbridge.moc" |