mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
WebPage: Disable writing JavaScript warnings on stderr
Can be enabled with QUPZILLA_ENABLE_JS_OUTPUT environment variable.
This commit is contained in:
parent
ad3780e8df
commit
642d835d55
@ -48,6 +48,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWebChannel>
|
#include <QWebChannel>
|
||||||
@ -63,6 +65,8 @@ QString WebPage::s_lastUploadLocation = QDir::homePath();
|
|||||||
QUrl WebPage::s_lastUnsupportedUrl;
|
QUrl WebPage::s_lastUnsupportedUrl;
|
||||||
QTime WebPage::s_lastUnsupportedUrlTime;
|
QTime WebPage::s_lastUnsupportedUrlTime;
|
||||||
|
|
||||||
|
static const bool kEnableJsOutput = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_OUTPUT");
|
||||||
|
|
||||||
WebPage::WebPage(QObject* parent)
|
WebPage::WebPage(QObject* parent)
|
||||||
: QWebEnginePage(mApp->webProfile(), parent)
|
: QWebEnginePage(mApp->webProfile(), parent)
|
||||||
, m_fileWatcher(0)
|
, m_fileWatcher(0)
|
||||||
@ -562,6 +566,29 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
|
||||||
|
{
|
||||||
|
if (!kEnableJsOutput) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (level) {
|
||||||
|
case InfoMessageLevel:
|
||||||
|
std::cout << "[I] ";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WarningMessageLevel:
|
||||||
|
std::cout << "[W] ";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ErrorMessageLevel:
|
||||||
|
std::cout << "[E] ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << qPrintable(sourceID) << ":" << lineNumber << " " << qPrintable(message);
|
||||||
|
}
|
||||||
|
|
||||||
void WebPage::setJavaScriptEnabled(bool enabled)
|
void WebPage::setJavaScriptEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, enabled);
|
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, enabled);
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) Q_DECL_OVERRIDE;
|
bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) Q_DECL_OVERRIDE;
|
||||||
bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
||||||
void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
||||||
|
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override;
|
||||||
|
|
||||||
void setJavaScriptEnabled(bool enabled);
|
void setJavaScriptEnabled(bool enabled);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user