Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge in upstream changes that adds command for retrieving console me…

…ssages.
  • Loading branch information...
commit 5177140ef5879a782a69d0f8b230053de96e9b13 1 parent f2eaa3e
@tristandunn authored
View
1  src/CommandFactory.cpp
@@ -18,6 +18,7 @@
#include "ClearCookies.h"
#include "GetCookies.h"
#include "SetProxy.h"
+#include "ConsoleMessages.h"
CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) {
m_page = page;
View
11 src/ConsoleMessages.cpp
@@ -0,0 +1,11 @@
+#include "ConsoleMessages.h"
+#include "WebPage.h"
+
+ConsoleMessages::ConsoleMessages(WebPage *page, QObject *parent) : Command(page, parent) {
+}
+
+void ConsoleMessages::start(QStringList &arguments) {
+ Q_UNUSED(arguments);
+ emit finished(new Response(true, page()->consoleMessages()));
+}
+
View
12 src/ConsoleMessages.h
@@ -0,0 +1,12 @@
+#include "Command.h"
+
+class WebPage;
+
+class ConsoleMessages : public Command {
+ Q_OBJECT
+
+ public:
+ ConsoleMessages(WebPage *page, QObject *parent = 0);
+ virtual void start(QStringList &arguments);
+};
+
View
1  src/Reset.cpp
@@ -15,6 +15,7 @@ void Reset::start(QStringList &arguments) {
page()->setCustomNetworkAccessManager();
page()->setUserAgent(NULL);
page()->resetResponseHeaders();
+ page()->resetConsoleMessages();
emit finished(new Response(true));
}
View
14 src/WebPage.cpp
@@ -58,6 +58,10 @@ QString WebPage::userAgentForUrl(const QUrl &url ) const {
}
}
+QString WebPage::consoleMessages() {
+ return m_consoleMessages.join("\n");
+}
+
void WebPage::setUserAgent(QString userAgent) {
m_userAgent = userAgent;
}
@@ -90,9 +94,11 @@ QVariant WebPage::invokeWebKitServerFunction(QString &name, QStringList &argumen
}
void WebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) {
+ QString fullMessage = QString::number(lineNumber) + "|" + message;
if (!sourceID.isEmpty())
- std::cout << qPrintable(sourceID) << ":" << lineNumber << " ";
- std::cout << qPrintable(message) << std::endl;
+ fullMessage = sourceID + "|" + fullMessage;
+ m_consoleMessages.append(fullMessage);
+ std::cout << qPrintable(fullMessage) << std::endl;
}
void WebPage::javaScriptAlert(QWebFrame *frame, const QString &message) {
@@ -217,6 +223,10 @@ void WebPage::resetResponseHeaders() {
m_pageHeaders = QString();
}
+void WebPage::resetConsoleMessages() {
+ m_consoleMessages.clear();
+}
+
QString WebPage::pageHeaders() {
return m_pageHeaders;
}
View
3  src/WebPage.h
@@ -17,6 +17,8 @@ class WebPage : public QWebPage {
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
void setIgnoreSslErrors(bool ignore);
bool ignoreSslErrors();
+ QString consoleMessages();
+ void resetConsoleMessages();
public slots:
bool shouldInterruptJavaScript();
@@ -50,5 +52,6 @@ class WebPage : public QWebPage {
int m_lastStatus;
QString m_pageHeaders;
bool m_ignoreSslErrors;
+ QStringList m_consoleMessages;
};
View
1  src/find_command.h
@@ -22,3 +22,4 @@ CHECK_COMMAND(ClearCookies)
CHECK_COMMAND(GetCookies)
CHECK_COMMAND(Headers)
CHECK_COMMAND(SetProxy)
+CHECK_COMMAND(ConsoleMessages)
View
2  src/webkit_server.pro
@@ -2,6 +2,7 @@ TEMPLATE = app
TARGET = webkit_server
DESTDIR = .
HEADERS = \
+ ConsoleMessages.h \
WebPage.h \
Server.h \
Connection.h \
@@ -33,6 +34,7 @@ HEADERS = \
SetProxy.h \
SOURCES = \
+ ConsoleMessages.cpp \
main.cpp \
WebPage.cpp \
Server.cpp \
Please sign in to comment.
Something went wrong with that request. Please try again.