Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge in webkit-server changes.

  • Loading branch information...
commit 7335cc83e6d83d17987750e34d4dd230d1f9c92f 1 parent 6d66d5e
@tristandunn authored
View
26 vendor/webkit-server/README.markdown
@@ -4,31 +4,7 @@ A standalone version of the WebKit server in [capybara-webkit](https://github.co
## Dependencies
-webkit-server depends on a WebKit implementation from Qt, a cross-platform development toolkit. You'll need to download the Qt libraries to build the binary.
-
-**OS X 10.7:**
-
- brew install qt
-
-**OS X < 10.7:**
-
-[Download the non-debug Cocoa package](http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x).
-
-**Ubuntu:**
-
- apt-get install libqt4-dev
-
-**Fedora:**
-
- yum install qt-webkit-devel
-
-**Gentoo Linux:**
-
- emerge x11-libs/qt-webkit
-
-**Other Linux distributions:**
-
-[Download this package](http://qt.nokia.com/downloads/linux-x11-cpp).
+webkit-server depends on a WebKit implementation from Qt, a cross-platform development toolkit. You'll need to download the Qt libraries to build the binary. See [Installing QT](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT) for how to install it on your system.
## Building
View
2  vendor/webkit-server/src/CommandFactory.cpp
@@ -18,6 +18,8 @@
#include "ClearCookies.h"
#include "GetCookies.h"
#include "SetProxy.h"
+#include "ConsoleMessages.h"
+#include "RequestedUrl.h"
CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) {
m_page = page;
View
11 vendor/webkit-server/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 vendor/webkit-server/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  vendor/webkit-server/src/Find.cpp
@@ -6,7 +6,6 @@ Find::Find(WebPage *page, QObject *parent) : Command(page, parent) {
}
void Find::start(QStringList &arguments) {
- QString message;
QVariant result = page()->invokeWebKitServerFunction("find", arguments);
if (result.isValid()) {
View
15 vendor/webkit-server/src/RequestedUrl.cpp
@@ -0,0 +1,15 @@
+#include "RequestedUrl.h"
+#include "WebPage.h"
+
+RequestedUrl::RequestedUrl(WebPage *page, QObject *parent) : Command(page, parent) {
+}
+
+void RequestedUrl::start(QStringList &arguments) {
+ Q_UNUSED(arguments);
+
+ QUrl humanUrl = page()->currentFrame()->requestedUrl();
+ QByteArray encodedBytes = humanUrl.toEncoded();
+ QString urlString = QString(encodedBytes);
+ emit finished(new Response(true, urlString));
+}
+
View
12 vendor/webkit-server/src/RequestedUrl.h
@@ -0,0 +1,12 @@
+#include "Command.h"
+
+class WebPage;
+
+class RequestedUrl : public Command {
+ Q_OBJECT
+
+ public:
+ RequestedUrl(WebPage *page, QObject *parent = 0);
+ virtual void start(QStringList &arguments);
+};
+
View
1  vendor/webkit-server/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
2  vendor/webkit-server/src/Visit.cpp
@@ -7,7 +7,7 @@ Visit::Visit(WebPage *page, QObject *parent) : Command(page, parent) {
}
void Visit::start(QStringList &arguments) {
- QUrl requestedUrl = QUrl(arguments[0]);
+ QUrl requestedUrl = QUrl::fromEncoded(arguments[0].toUtf8(), QUrl::StrictMode);
page()->currentFrame()->load(QUrl(requestedUrl));
}
View
14 vendor/webkit-server/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  vendor/webkit-server/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
2  vendor/webkit-server/src/find_command.h
@@ -22,3 +22,5 @@ CHECK_COMMAND(ClearCookies)
CHECK_COMMAND(GetCookies)
CHECK_COMMAND(Headers)
CHECK_COMMAND(SetProxy)
+CHECK_COMMAND(ConsoleMessages)
+CHECK_COMMAND(RequestedUrl)
View
9 vendor/webkit-server/src/webkit_server.js
@@ -102,9 +102,10 @@ window.WebKitServer = {
set: function(index, value) {
var node = this.nodes[index],
- type = (node.type || node.tagName).toLowerCase();
+ type = (node.type || node.tagName).toLowerCase(),
+ textTypes = ["email", "number", "password", "search", "tel", "text", "textarea", "url"];
- if (type == "text" || type == "textarea" || type == "password") {
+ if (textTypes.indexOf(type) !== -1) {
this.trigger(index, "focus");
node.value = "";
@@ -126,12 +127,12 @@ window.WebKitServer = {
this.trigger(index, "change");
this.trigger(index, "blur");
- } else if(type == "checkbox" || type == "radio") {
+ } else if (type === "checkbox" || type === "radio") {
node.checked = (value == "true");
this.trigger(index, "click");
this.trigger(index, "change");
- } else if(type == "file") {
+ } else if (type === "file") {
this.lastAttachedFile = value;
this.trigger(index, "click");
} else {
View
5 vendor/webkit-server/src/webkit_server.pro
@@ -2,6 +2,8 @@ TEMPLATE = app
TARGET = webkit_server
DESTDIR = .
HEADERS = \
+ RequestedUrl.h \
+ ConsoleMessages.h \
WebPage.h \
Server.h \
Connection.h \
@@ -33,6 +35,8 @@ HEADERS = \
SetProxy.h \
SOURCES = \
+ RequestedUrl.cpp \
+ ConsoleMessages.cpp \
main.cpp \
WebPage.cpp \
Server.cpp \
@@ -68,3 +72,4 @@ RESOURCES = webkit_server.qrc
QT += network webkit
CONFIG += console
CONFIG -= app_bundle
+
Please sign in to comment.
Something went wrong with that request. Please try again.