summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-10-09 09:32:55 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-11-06 10:00:07 +0000
commitbe8c12a814cbed3f1fcb7097f6980fae6112cbc3 (patch)
treeaf713aee9739d9f994e5a9404d7995f7f2d1011b /examples
parentfce0c120e4e67496e4a8d76398a8c105a76c42c4 (diff)
Print JS console messages by default
Change the behavior of QWebEnginePage/WebEngineView to print JavaScript console.warn and console.error messages by default in a 'js' logging category. This matches also the behavior for QtQml, where console messages end up in a 'qml' logging category by default. So far access to the JavaScript console required either use of the remote debugging functionality, subclassing of QWebEnginePage, or implementing a custom handler. Anyhow, even then writing a seamless forwarding of the data and metadata to the Qt message handler is difficult. This patches implements this forwarding by default. The behavior can be changed by either setting up rules for the 'js' category, e.g. setFilterRules("js.*=false"); or by implementing onJavaScriptConsoleMessage(), or overriding QWebEnginePage::javaScriptConsoleMessage. [ChangeLog] Unhandled JS console messages are now forwarded to to the Qt message handler inside a 'js' category. Change-Id: I5480383a80dcf7a122496f9b7915264ef9036db3 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginewidgets/demobrowser/webview.cpp17
-rw-r--r--examples/webenginewidgets/demobrowser/webview.h1
2 files changed, 0 insertions, 18 deletions
diff --git a/examples/webenginewidgets/demobrowser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp
index c12f3db3..79a6cf34 100644
--- a/examples/webenginewidgets/demobrowser/webview.cpp
+++ b/examples/webenginewidgets/demobrowser/webview.cpp
@@ -315,23 +315,6 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
}
}
-void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int /*lineNumber*/, const QString& sourceID)
-{
- QUrl url;
- url.setUrl(sourceID);
- switch (level) {
- case InfoMessageLevel:
- // Ignore these, they can still be found in the inspector.
- break;
- case WarningMessageLevel:
- qInfo() << "JavaScript WARNING:" << url.host() << message;
- break;
- case ErrorMessageLevel:
- qInfo() << "JavaScript ERROR:" << url.host() << message;
- break;
- }
-}
-
WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
, m_progress(0)
diff --git a/examples/webenginewidgets/demobrowser/webview.h b/examples/webenginewidgets/demobrowser/webview.h
index a798a15e..34188a25 100644
--- a/examples/webenginewidgets/demobrowser/webview.h
+++ b/examples/webenginewidgets/demobrowser/webview.h
@@ -71,7 +71,6 @@ protected:
QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
#endif
virtual bool certificateError(const QWebEngineCertificateError &error) Q_DECL_OVERRIDE;
- virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
private slots:
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)