capybara-webkit 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/GOALS +9 -0
- data/Gemfile.lock +15 -12
- data/LICENSE +1 -1
- data/NEWS.md +18 -0
- data/README.md +81 -2
- data/capybara-webkit.gemspec +1 -1
- data/lib/capybara/webkit.rb +11 -6
- data/lib/capybara/{driver/webkit → webkit}/browser.rb +90 -4
- data/lib/capybara/{driver/webkit → webkit}/connection.rb +48 -47
- data/lib/capybara/{driver/webkit → webkit}/cookie_jar.rb +1 -1
- data/lib/capybara/webkit/driver.rb +186 -0
- data/lib/capybara/webkit/errors.rb +10 -0
- data/lib/capybara/{driver/webkit → webkit}/node.rb +12 -4
- data/lib/capybara/{driver/webkit → webkit}/socket_debugger.rb +4 -1
- data/lib/capybara/{driver/webkit → webkit}/version.rb +1 -1
- data/lib/capybara_webkit_builder.rb +17 -3
- data/spec/browser_spec.rb +95 -7
- data/spec/connection_spec.rb +16 -5
- data/spec/cookie_jar_spec.rb +3 -3
- data/spec/driver_rendering_spec.rb +19 -26
- data/spec/driver_resize_window_spec.rb +3 -3
- data/spec/driver_spec.rb +1200 -822
- data/spec/integration/driver_spec.rb +4 -3
- data/spec/selenium_compatibility_spec.rb +49 -0
- data/spec/spec_helper.rb +14 -6
- data/spec/support/app_runner.rb +94 -0
- data/src/Authenticate.cpp +18 -0
- data/src/Authenticate.h +12 -0
- data/src/Body.h +3 -5
- data/src/ClearCookies.cpp +3 -5
- data/src/ClearCookies.h +3 -5
- data/src/ClearPromptText.cpp +11 -0
- data/src/ClearPromptText.h +9 -0
- data/src/Command.cpp +4 -15
- data/src/Command.h +3 -14
- data/src/CommandFactory.cpp +20 -6
- data/src/CommandFactory.h +3 -2
- data/src/CommandParser.cpp +1 -1
- data/src/Connection.cpp +22 -21
- data/src/Connection.h +5 -6
- data/src/ConsoleMessages.cpp +2 -1
- data/src/ConsoleMessages.h +3 -5
- data/src/CurrentUrl.cpp +9 -48
- data/src/CurrentUrl.h +8 -8
- data/src/EnableLogging.cpp +10 -0
- data/src/EnableLogging.h +12 -0
- data/src/Evaluate.cpp +2 -1
- data/src/Evaluate.h +3 -5
- data/src/Execute.cpp +2 -1
- data/src/Execute.h +3 -5
- data/src/Find.cpp +3 -2
- data/src/Find.h +3 -5
- data/src/FrameFocus.cpp +3 -2
- data/src/FrameFocus.h +3 -4
- data/src/GetCookies.cpp +3 -4
- data/src/GetCookies.h +3 -5
- data/src/GetTimeout.cpp +9 -0
- data/src/GetTimeout.h +11 -0
- data/src/GetWindowHandle.cpp +11 -0
- data/src/GetWindowHandle.h +10 -0
- data/src/GetWindowHandles.cpp +20 -0
- data/src/GetWindowHandles.h +10 -0
- data/src/Header.cpp +2 -1
- data/src/Header.h +3 -5
- data/src/Headers.cpp +8 -2
- data/src/Headers.h +3 -5
- data/src/IgnoreSslErrors.cpp +4 -3
- data/src/IgnoreSslErrors.h +3 -5
- data/src/JavascriptAlertMessages.cpp +10 -0
- data/src/JavascriptAlertMessages.h +9 -0
- data/src/JavascriptConfirmMessages.cpp +10 -0
- data/src/JavascriptConfirmMessages.h +9 -0
- data/src/JavascriptInvocation.cpp +1 -1
- data/src/JavascriptInvocation.h +1 -1
- data/src/JavascriptPromptMessages.cpp +10 -0
- data/src/JavascriptPromptMessages.h +9 -0
- data/src/NetworkAccessManager.cpp +38 -5
- data/src/NetworkAccessManager.h +20 -0
- data/src/Node.cpp +6 -1
- data/src/Node.h +4 -5
- data/src/NullCommand.cpp +5 -2
- data/src/NullCommand.h +4 -3
- data/src/PageLoadingCommand.cpp +12 -7
- data/src/PageLoadingCommand.h +6 -9
- data/src/Render.cpp +2 -1
- data/src/Render.h +3 -5
- data/src/RequestedUrl.cpp +2 -1
- data/src/RequestedUrl.h +3 -5
- data/src/Reset.cpp +3 -17
- data/src/Reset.h +3 -8
- data/src/ResizeWindow.cpp +2 -1
- data/src/ResizeWindow.h +3 -5
- data/src/Response.cpp +4 -0
- data/src/Response.h +1 -0
- data/src/Server.cpp +2 -3
- data/src/Server.h +0 -2
- data/src/SetConfirmAction.cpp +11 -0
- data/src/SetConfirmAction.h +9 -0
- data/src/SetCookie.cpp +3 -4
- data/src/SetCookie.h +3 -5
- data/src/SetPromptAction.cpp +11 -0
- data/src/SetPromptAction.h +9 -0
- data/src/SetPromptText.cpp +11 -0
- data/src/SetPromptText.h +9 -0
- data/src/SetProxy.cpp +2 -1
- data/src/SetProxy.h +3 -5
- data/src/SetSkipImageLoading.cpp +12 -0
- data/src/SetSkipImageLoading.h +9 -0
- data/src/SetTimeout.cpp +19 -0
- data/src/SetTimeout.h +9 -0
- data/src/SocketCommand.cpp +21 -0
- data/src/SocketCommand.h +29 -0
- data/src/Source.cpp +3 -2
- data/src/Source.h +3 -4
- data/src/Status.cpp +2 -1
- data/src/Status.h +3 -5
- data/src/TimeoutCommand.cpp +69 -0
- data/src/TimeoutCommand.h +41 -0
- data/src/UnsupportedContentHandler.cpp +11 -17
- data/src/UnsupportedContentHandler.h +5 -3
- data/src/Url.cpp +2 -1
- data/src/Url.h +3 -5
- data/src/Visit.cpp +3 -2
- data/src/Visit.h +3 -5
- data/src/WebPage.cpp +129 -44
- data/src/WebPage.h +37 -11
- data/src/WebPageManager.cpp +127 -0
- data/src/WebPageManager.h +59 -0
- data/src/WindowFocus.cpp +32 -0
- data/src/WindowFocus.h +15 -0
- data/src/body.cpp +2 -1
- data/src/capybara.js +38 -10
- data/src/find_command.h +17 -2
- data/src/main.cpp +0 -2
- data/src/webkit_server.pro +36 -0
- data/templates/Command.cpp +2 -4
- data/templates/Command.h +3 -3
- metadata +106 -27
- data/ChangeLog +0 -70
- data/lib/capybara/driver/webkit.rb +0 -136
data/src/RequestedUrl.cpp
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#include "RequestedUrl.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
|
4
|
-
RequestedUrl::RequestedUrl(
|
5
|
+
RequestedUrl::RequestedUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
5
6
|
}
|
6
7
|
|
7
8
|
void RequestedUrl::start() {
|
data/src/RequestedUrl.h
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class RequestedUrl : public Command {
|
3
|
+
class RequestedUrl : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
RequestedUrl(
|
7
|
+
RequestedUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
12
10
|
|
data/src/Reset.cpp
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
#include "Reset.h"
|
2
2
|
#include "WebPage.h"
|
3
|
-
#include "
|
4
|
-
#include "NetworkCookieJar.h"
|
3
|
+
#include "WebPageManager.h"
|
5
4
|
|
6
|
-
Reset::Reset(
|
5
|
+
Reset::Reset(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
7
6
|
}
|
8
7
|
|
9
8
|
void Reset::start() {
|
10
9
|
page()->triggerAction(QWebPage::Stop);
|
11
10
|
|
12
|
-
|
13
|
-
networkAccessManager->setCookieJar(new NetworkCookieJar());
|
14
|
-
networkAccessManager->resetHeaders();
|
11
|
+
manager()->reset();
|
15
12
|
|
16
|
-
page()->setUserAgent(NULL);
|
17
|
-
page()->resetResponseHeaders();
|
18
|
-
page()->resetConsoleMessages();
|
19
|
-
page()->resetWindowSize();
|
20
|
-
resetHistory();
|
21
13
|
emit finished(new Response(true));
|
22
14
|
}
|
23
15
|
|
24
|
-
void Reset::resetHistory() {
|
25
|
-
// Clearing the history preserves the current history item, so set it to blank first.
|
26
|
-
page()->currentFrame()->setUrl(QUrl("about:blank"));
|
27
|
-
page()->history()->clear();
|
28
|
-
}
|
29
|
-
|
data/src/Reset.h
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class Reset : public Command {
|
3
|
+
class Reset : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
Reset(
|
7
|
+
Reset(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
|
-
|
12
|
-
private:
|
13
|
-
void resetHistory();
|
14
9
|
};
|
15
10
|
|
data/src/ResizeWindow.cpp
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#include "ResizeWindow.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
|
4
|
-
ResizeWindow::ResizeWindow(
|
5
|
+
ResizeWindow::ResizeWindow(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
5
6
|
}
|
6
7
|
|
7
8
|
void ResizeWindow::start() {
|
data/src/ResizeWindow.h
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class ResizeWindow : public Command {
|
3
|
+
class ResizeWindow : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
ResizeWindow(
|
7
|
+
ResizeWindow(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
12
10
|
|
data/src/Response.cpp
CHANGED
data/src/Response.h
CHANGED
data/src/Server.cpp
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#include "Server.h"
|
2
|
-
#include "WebPage.h"
|
3
2
|
#include "Connection.h"
|
3
|
+
#include "WebPageManager.h"
|
4
4
|
|
5
5
|
#include <QTcpServer>
|
6
6
|
|
7
7
|
Server::Server(QObject *parent) : QObject(parent) {
|
8
8
|
m_tcp_server = new QTcpServer(this);
|
9
|
-
m_page = new WebPage(this);
|
10
9
|
}
|
11
10
|
|
12
11
|
bool Server::start() {
|
@@ -20,5 +19,5 @@ quint16 Server::server_port() const {
|
|
20
19
|
|
21
20
|
void Server::handleConnection() {
|
22
21
|
QTcpSocket *socket = m_tcp_server->nextPendingConnection();
|
23
|
-
new Connection(socket,
|
22
|
+
new Connection(socket, new WebPageManager(this), this);
|
24
23
|
}
|
data/src/Server.h
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "SetConfirmAction.h"
|
2
|
+
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
|
5
|
+
SetConfirmAction::SetConfirmAction(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
6
|
+
|
7
|
+
void SetConfirmAction::start()
|
8
|
+
{
|
9
|
+
page()->setConfirmAction(arguments()[0]);
|
10
|
+
emit finished(new Response(true));
|
11
|
+
}
|
data/src/SetCookie.cpp
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
#include "SetCookie.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
#include "NetworkCookieJar.h"
|
4
5
|
#include <QNetworkCookie>
|
5
6
|
|
6
|
-
SetCookie::SetCookie(
|
7
|
+
SetCookie::SetCookie(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
7
8
|
|
8
9
|
void SetCookie::start()
|
9
10
|
{
|
10
11
|
QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments()[0].toAscii());
|
11
|
-
NetworkCookieJar *jar =
|
12
|
-
->networkAccessManager()
|
13
|
-
->cookieJar());
|
12
|
+
NetworkCookieJar *jar = manager()->cookieJar();
|
14
13
|
jar->overwriteCookies(cookies);
|
15
14
|
emit finished(new Response(true));
|
16
15
|
}
|
data/src/SetCookie.h
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class SetCookie : public Command {
|
3
|
+
class SetCookie : public SocketCommand {
|
6
4
|
Q_OBJECT;
|
7
5
|
|
8
6
|
public:
|
9
|
-
SetCookie(
|
7
|
+
SetCookie(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "SetPromptAction.h"
|
2
|
+
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
|
5
|
+
SetPromptAction::SetPromptAction(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
6
|
+
|
7
|
+
void SetPromptAction::start()
|
8
|
+
{
|
9
|
+
page()->setPromptAction(arguments()[0]);
|
10
|
+
emit finished(new Response(true));
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "SetPromptText.h"
|
2
|
+
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
|
5
|
+
SetPromptText::SetPromptText(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
6
|
+
|
7
|
+
void SetPromptText::start()
|
8
|
+
{
|
9
|
+
page()->setPromptText(arguments()[0]);
|
10
|
+
emit finished(new Response(true));
|
11
|
+
}
|
data/src/SetPromptText.h
ADDED
data/src/SetProxy.cpp
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#include "SetProxy.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
#include <QNetworkAccessManager>
|
4
5
|
#include <QNetworkProxy>
|
5
6
|
|
6
|
-
SetProxy::SetProxy(
|
7
|
+
SetProxy::SetProxy(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
7
8
|
|
8
9
|
void SetProxy::start()
|
9
10
|
{
|
data/src/SetProxy.h
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class SetProxy : public Command {
|
3
|
+
class SetProxy : public SocketCommand {
|
6
4
|
Q_OBJECT;
|
7
5
|
|
8
6
|
public:
|
9
|
-
SetProxy(
|
7
|
+
SetProxy(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#include "SetSkipImageLoading.h"
|
2
|
+
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
|
5
|
+
SetSkipImageLoading::SetSkipImageLoading(WebPageManager *manager, QStringList &arguments, QObject *parent) :
|
6
|
+
SocketCommand(manager, arguments, parent) {
|
7
|
+
}
|
8
|
+
|
9
|
+
void SetSkipImageLoading::start() {
|
10
|
+
page()->setSkipImageLoading(arguments().contains("true"));
|
11
|
+
emit finished(new Response(true));
|
12
|
+
}
|
data/src/SetTimeout.cpp
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#include "SetTimeout.h"
|
2
|
+
#include "WebPageManager.h"
|
3
|
+
|
4
|
+
SetTimeout::SetTimeout(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
5
|
+
}
|
6
|
+
|
7
|
+
void SetTimeout::start() {
|
8
|
+
QString timeoutString = arguments()[0];
|
9
|
+
bool ok;
|
10
|
+
int timeout = timeoutString.toInt(&ok);
|
11
|
+
|
12
|
+
if (ok) {
|
13
|
+
manager()->setTimeout(timeout);
|
14
|
+
emit finished(new Response(true));
|
15
|
+
} else {
|
16
|
+
emit finished(new Response(false, QString("Invalid value for timeout")));
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
data/src/SetTimeout.h
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#include "SocketCommand.h"
|
2
|
+
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
|
5
|
+
SocketCommand::SocketCommand(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(parent) {
|
6
|
+
m_manager = manager;
|
7
|
+
m_arguments = arguments;
|
8
|
+
}
|
9
|
+
|
10
|
+
WebPage *SocketCommand::page() const {
|
11
|
+
return m_manager->currentPage();
|
12
|
+
}
|
13
|
+
|
14
|
+
const QStringList &SocketCommand::arguments() const {
|
15
|
+
return m_arguments;
|
16
|
+
}
|
17
|
+
|
18
|
+
WebPageManager *SocketCommand::manager() const {
|
19
|
+
return m_manager;
|
20
|
+
}
|
21
|
+
|
data/src/SocketCommand.h
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#ifndef SOCKET_COMMAND_H
|
2
|
+
#define SOCKET_COMMAND_H
|
3
|
+
|
4
|
+
#include <QObject>
|
5
|
+
#include <QStringList>
|
6
|
+
#include "Command.h"
|
7
|
+
|
8
|
+
class WebPage;
|
9
|
+
class WebPageManager;
|
10
|
+
class Response;
|
11
|
+
|
12
|
+
class SocketCommand : public Command {
|
13
|
+
Q_OBJECT
|
14
|
+
|
15
|
+
public:
|
16
|
+
SocketCommand(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
17
|
+
|
18
|
+
protected:
|
19
|
+
WebPage *page() const;
|
20
|
+
const QStringList &arguments() const;
|
21
|
+
WebPageManager *manager() const;
|
22
|
+
|
23
|
+
private:
|
24
|
+
QStringList m_arguments;
|
25
|
+
WebPageManager *m_manager;
|
26
|
+
|
27
|
+
};
|
28
|
+
|
29
|
+
#endif
|
data/src/Source.cpp
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
#include "Source.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
|
4
|
-
Source::Source(
|
5
|
+
Source::Source(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
5
6
|
}
|
6
7
|
|
7
8
|
void Source::start() {
|
8
9
|
QNetworkAccessManager* accessManager = page()->networkAccessManager();
|
9
|
-
QNetworkRequest request(page()->currentFrame()->
|
10
|
+
QNetworkRequest request(page()->currentFrame()->requestedUrl());
|
10
11
|
reply = accessManager->get(request);
|
11
12
|
|
12
13
|
connect(reply, SIGNAL(finished()), this, SLOT(sourceLoaded()));
|
data/src/Source.h
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class WebPage;
|
4
3
|
class QNetworkReply;
|
5
4
|
|
6
|
-
class Source : public
|
5
|
+
class Source : public SocketCommand {
|
7
6
|
Q_OBJECT
|
8
7
|
|
9
8
|
public:
|
10
|
-
Source(
|
9
|
+
Source(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
11
10
|
virtual void start();
|
12
11
|
|
13
12
|
public slots:
|
data/src/Status.cpp
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
#include "Status.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
#include <sstream>
|
4
5
|
|
5
|
-
Status::Status(
|
6
|
+
Status::Status(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
6
7
|
}
|
7
8
|
|
8
9
|
void Status::start() {
|