capybara-webkit 0.14.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +21 -0
- data/Appraisals +4 -4
- data/CONTRIBUTING.md +14 -3
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -19
- data/NEWS.md +15 -0
- data/README.md +126 -76
- data/Vagrantfile +7 -0
- data/capybara-webkit.gemspec +3 -0
- data/gemfiles/2.0.gemfile +7 -0
- data/gemfiles/2.0.gemfile.lock +72 -0
- data/gemfiles/2.1.gemfile +7 -0
- data/gemfiles/2.1.gemfile.lock +71 -0
- data/lib/capybara/webkit/browser.rb +22 -22
- data/lib/capybara/webkit/connection.rb +9 -6
- data/lib/capybara/webkit/driver.rb +22 -6
- data/lib/capybara/webkit/errors.rb +25 -0
- data/lib/capybara/webkit/node.rb +36 -10
- data/lib/capybara/webkit/version.rb +1 -1
- data/spec/browser_spec.rb +16 -1
- data/spec/capybara_webkit_builder_spec.rb +9 -3
- data/spec/connection_spec.rb +19 -3
- data/spec/driver_spec.rb +324 -144
- data/spec/errors_spec.rb +11 -0
- data/spec/integration/session_spec.rb +244 -0
- data/spec/selenium_compatibility_spec.rb +3 -1
- data/spec/spec_helper.rb +1 -9
- data/src/Authenticate.cpp +3 -2
- data/src/ClearCookies.cpp +1 -1
- data/src/ClearPromptText.cpp +1 -1
- data/src/Command.cpp +8 -4
- data/src/Command.h +7 -4
- data/src/CommandFactory.cpp +4 -2
- data/src/CommandParser.cpp +1 -1
- data/src/Connection.cpp +4 -4
- data/src/ConsoleMessages.cpp +1 -1
- data/src/CurrentUrl.cpp +2 -2
- data/src/EnableLogging.cpp +1 -1
- data/src/ErrorMessage.cpp +26 -0
- data/src/ErrorMessage.h +21 -0
- data/src/Evaluate.cpp +1 -1
- data/src/Execute.cpp +3 -2
- data/src/FindCss.cpp +13 -0
- data/src/FindCss.h +11 -0
- data/src/FindXpath.cpp +13 -0
- data/src/FindXpath.h +11 -0
- data/src/FrameFocus.cpp +4 -3
- data/src/GetCookies.cpp +1 -1
- data/src/GetTimeout.cpp +1 -1
- data/src/GetWindowHandle.cpp +1 -1
- data/src/GetWindowHandles.cpp +1 -1
- data/src/Header.cpp +2 -2
- data/src/Headers.cpp +1 -6
- data/src/IgnoreSslErrors.cpp +1 -1
- data/src/InvocationResult.cpp +29 -0
- data/src/InvocationResult.h +16 -0
- data/src/JavascriptAlertMessages.cpp +1 -1
- data/src/JavascriptCommand.cpp +15 -0
- data/src/JavascriptCommand.h +20 -0
- data/src/JavascriptConfirmMessages.cpp +1 -1
- data/src/JavascriptInvocation.cpp +128 -1
- data/src/JavascriptInvocation.h +22 -1
- data/src/JavascriptPromptMessages.cpp +1 -1
- data/src/NetworkAccessManager.cpp +8 -16
- data/src/NetworkAccessManager.h +5 -11
- data/src/NetworkReplyProxy.cpp +91 -0
- data/src/NetworkReplyProxy.h +65 -0
- data/src/Node.cpp +4 -4
- data/src/Node.h +2 -2
- data/src/NullCommand.cpp +2 -1
- data/src/PageLoadingCommand.cpp +2 -1
- data/src/Render.cpp +1 -1
- data/src/Reset.cpp +1 -1
- data/src/ResizeWindow.cpp +1 -1
- data/src/Response.cpp +7 -0
- data/src/Response.h +8 -3
- data/src/SetConfirmAction.cpp +1 -1
- data/src/SetCookie.cpp +2 -2
- data/src/SetPromptAction.cpp +1 -1
- data/src/SetPromptText.cpp +1 -1
- data/src/SetProxy.cpp +2 -2
- data/src/SetSkipImageLoading.cpp +1 -1
- data/src/SetTimeout.cpp +3 -2
- data/src/SetUrlBlacklist.cpp +2 -2
- data/src/Status.cpp +1 -1
- data/src/TimeoutCommand.cpp +4 -2
- data/src/Title.cpp +11 -0
- data/src/Title.h +9 -0
- data/src/Version.cpp +13 -0
- data/src/Version.h +10 -0
- data/src/Visit.cpp +1 -1
- data/src/WebPage.cpp +49 -27
- data/src/WebPage.h +14 -7
- data/src/WebPageManager.cpp +10 -1
- data/src/WebPageManager.h +4 -1
- data/src/WindowFocus.cpp +3 -2
- data/src/body.cpp +3 -6
- data/src/capybara.js +103 -101
- data/src/find_command.h +4 -2
- data/src/main.cpp +1 -1
- data/src/stable.h +39 -0
- data/src/webkit_server.pro +26 -6
- data/vagrant_setup.sh +58 -0
- metadata +51 -78
- data/gemfiles/1.0.gemfile +0 -7
- data/gemfiles/1.0.gemfile.lock +0 -70
- data/gemfiles/1.1.gemfile +0 -7
- data/gemfiles/1.1.gemfile.lock +0 -70
- data/src/Find.cpp +0 -20
- data/src/Find.h +0 -11
data/src/JavascriptInvocation.h
CHANGED
@@ -1,19 +1,40 @@
|
|
1
1
|
#include <QObject>
|
2
2
|
#include <QString>
|
3
3
|
#include <QStringList>
|
4
|
+
#include <QEvent>
|
5
|
+
#include <QWebElement>
|
6
|
+
|
7
|
+
class WebPage;
|
8
|
+
class InvocationResult;
|
4
9
|
|
5
10
|
class JavascriptInvocation : public QObject {
|
6
11
|
Q_OBJECT
|
7
12
|
Q_PROPERTY(QString functionName READ functionName)
|
8
13
|
Q_PROPERTY(QStringList arguments READ arguments)
|
14
|
+
Q_PROPERTY(QVariant error READ getError WRITE setError)
|
9
15
|
|
10
16
|
public:
|
11
|
-
JavascriptInvocation(const QString &functionName, const QStringList &arguments, QObject *parent = 0);
|
17
|
+
JavascriptInvocation(const QString &functionName, const QStringList &arguments, WebPage *page, QObject *parent = 0);
|
12
18
|
QString &functionName();
|
13
19
|
QStringList &arguments();
|
20
|
+
Q_INVOKABLE void leftClick(int x, int y);
|
21
|
+
Q_INVOKABLE void rightClick(int x, int y);
|
22
|
+
Q_INVOKABLE void doubleClick(int x, int y);
|
23
|
+
Q_INVOKABLE bool clickTest(QWebElement element, int absoluteX, int absoluteY);
|
24
|
+
Q_INVOKABLE QVariantMap clickPosition(QWebElement element, int left, int top, int width, int height);
|
25
|
+
Q_INVOKABLE void hover(int absoluteX, int absoluteY);
|
26
|
+
Q_INVOKABLE void keypress(QChar);
|
27
|
+
QVariant getError();
|
28
|
+
void setError(QVariant error);
|
29
|
+
InvocationResult invoke(QWebFrame *);
|
14
30
|
|
15
31
|
private:
|
16
32
|
QString m_functionName;
|
17
33
|
QStringList m_arguments;
|
34
|
+
WebPage *m_page;
|
35
|
+
QVariant m_error;
|
36
|
+
void mouseEvent(QEvent::Type type, const QPoint & position, Qt::MouseButton button);
|
37
|
+
void hover(const QPoint &);
|
38
|
+
int keyCodeFor(const QChar &);
|
18
39
|
};
|
19
40
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include <iostream>
|
4
4
|
#include <fstream>
|
5
5
|
#include "NoOpReply.h"
|
6
|
+
#include "NetworkReplyProxy.h"
|
6
7
|
|
7
8
|
NetworkAccessManager::NetworkAccessManager(QObject *parent):QNetworkAccessManager(parent) {
|
8
9
|
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
|
@@ -13,7 +14,7 @@ QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operat
|
|
13
14
|
QNetworkRequest new_request(request);
|
14
15
|
QByteArray url = new_request.url().toEncoded();
|
15
16
|
if (this->isBlacklisted(new_request.url())) {
|
16
|
-
return new NoOpReply(new_request, this);
|
17
|
+
return new NetworkReplyProxy(new NoOpReply(new_request), this);
|
17
18
|
} else {
|
18
19
|
if (operation != QNetworkAccessManager::PostOperation && operation != QNetworkAccessManager::PutOperation) {
|
19
20
|
new_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant());
|
@@ -21,9 +22,9 @@ QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operat
|
|
21
22
|
QHashIterator<QString, QString> item(m_headers);
|
22
23
|
while (item.hasNext()) {
|
23
24
|
item.next();
|
24
|
-
new_request.setRawHeader(item.key().
|
25
|
+
new_request.setRawHeader(item.key().toLatin1(), item.value().toLatin1());
|
25
26
|
}
|
26
|
-
QNetworkReply *reply = QNetworkAccessManager::createRequest(operation, new_request, outgoingData);
|
27
|
+
QNetworkReply *reply = new NetworkReplyProxy(QNetworkAccessManager::createRequest(operation, new_request, outgoingData), this);
|
27
28
|
emit requestCreated(url, reply);
|
28
29
|
return reply;
|
29
30
|
}
|
@@ -37,10 +38,7 @@ void NetworkAccessManager::finished(QNetworkReply *reply) {
|
|
37
38
|
QUrl requestedUrl = reply->url();
|
38
39
|
while (m_redirectMappings.contains(requestedUrl))
|
39
40
|
requestedUrl = m_redirectMappings.take(requestedUrl);
|
40
|
-
|
41
|
-
response.statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
42
|
-
response.headers = reply->rawHeaderPairs();
|
43
|
-
m_responses[requestedUrl] = response;
|
41
|
+
emit finished(requestedUrl, reply);
|
44
42
|
}
|
45
43
|
}
|
46
44
|
|
@@ -48,8 +46,10 @@ void NetworkAccessManager::addHeader(QString key, QString value) {
|
|
48
46
|
m_headers.insert(key, value);
|
49
47
|
}
|
50
48
|
|
51
|
-
void NetworkAccessManager::
|
49
|
+
void NetworkAccessManager::reset() {
|
52
50
|
m_headers.clear();
|
51
|
+
m_userName = QString();
|
52
|
+
m_password = QString();
|
53
53
|
}
|
54
54
|
|
55
55
|
void NetworkAccessManager::setUserName(const QString &userName) {
|
@@ -68,14 +68,6 @@ void NetworkAccessManager::provideAuthentication(QNetworkReply *reply, QAuthenti
|
|
68
68
|
authenticator->setPassword(m_password);
|
69
69
|
}
|
70
70
|
|
71
|
-
int NetworkAccessManager::statusFor(QUrl url) {
|
72
|
-
return m_responses[url].statusCode;
|
73
|
-
}
|
74
|
-
|
75
|
-
const QList<QNetworkReply::RawHeaderPair> &NetworkAccessManager::headersFor(QUrl url) {
|
76
|
-
return m_responses[url].headers;
|
77
|
-
}
|
78
|
-
|
79
71
|
void NetworkAccessManager::setUrlBlacklist(QStringList urlBlacklist) {
|
80
72
|
m_urlBlacklist.clear();
|
81
73
|
|
data/src/NetworkAccessManager.h
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#ifndef __NETWORKACCESSMANAGER_H
|
2
|
+
#define __NETWORKACCESSMANAGER_H
|
1
3
|
#include <QtNetwork/QNetworkAccessManager>
|
2
4
|
#include <QtNetwork/QNetworkRequest>
|
3
5
|
#include <QtNetwork/QNetworkReply>
|
@@ -7,20 +9,12 @@ class NetworkAccessManager : public QNetworkAccessManager {
|
|
7
9
|
|
8
10
|
Q_OBJECT
|
9
11
|
|
10
|
-
struct NetworkResponse {
|
11
|
-
int statusCode;
|
12
|
-
QList<QNetworkReply::RawHeaderPair> headers;
|
13
|
-
NetworkResponse() : statusCode(0) { }
|
14
|
-
};
|
15
|
-
|
16
12
|
public:
|
17
13
|
NetworkAccessManager(QObject *parent = 0);
|
18
14
|
void addHeader(QString key, QString value);
|
19
|
-
void
|
15
|
+
void reset();
|
20
16
|
void setUserName(const QString &userName);
|
21
17
|
void setPassword(const QString &password);
|
22
|
-
int statusFor(QUrl url);
|
23
|
-
const QList<QNetworkReply::RawHeaderPair> &headersFor(QUrl url);
|
24
18
|
void setUrlBlacklist(QStringList urlBlacklist);
|
25
19
|
|
26
20
|
protected:
|
@@ -29,10 +23,8 @@ class NetworkAccessManager : public QNetworkAccessManager {
|
|
29
23
|
QString m_password;
|
30
24
|
QList<QUrl> m_urlBlacklist;
|
31
25
|
|
32
|
-
|
33
26
|
private:
|
34
27
|
QHash<QString, QString> m_headers;
|
35
|
-
QHash<QUrl, NetworkResponse> m_responses;
|
36
28
|
bool isBlacklisted(QUrl url);
|
37
29
|
QHash<QUrl, QUrl> m_redirectMappings;
|
38
30
|
|
@@ -42,4 +34,6 @@ class NetworkAccessManager : public QNetworkAccessManager {
|
|
42
34
|
|
43
35
|
signals:
|
44
36
|
void requestCreated(QByteArray &url, QNetworkReply *reply);
|
37
|
+
void finished(QUrl &, QNetworkReply *);
|
45
38
|
};
|
39
|
+
#endif
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#include "NetworkReplyProxy.h"
|
2
|
+
|
3
|
+
NetworkReplyProxy::NetworkReplyProxy(QNetworkReply* reply, QObject* parent)
|
4
|
+
: QNetworkReply(parent)
|
5
|
+
, m_reply(reply)
|
6
|
+
{
|
7
|
+
m_reply->setParent(this);
|
8
|
+
|
9
|
+
setOperation(m_reply->operation());
|
10
|
+
setRequest(m_reply->request());
|
11
|
+
setUrl(m_reply->url());
|
12
|
+
|
13
|
+
if (m_reply->isFinished()) {
|
14
|
+
readInternal();
|
15
|
+
setFinished(true);
|
16
|
+
}
|
17
|
+
|
18
|
+
applyMetaData();
|
19
|
+
|
20
|
+
connect(m_reply, SIGNAL(metaDataChanged()), SLOT(applyMetaData()));
|
21
|
+
connect(m_reply, SIGNAL(readyRead()), SLOT(handleReadyRead()));
|
22
|
+
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(errorInternal(QNetworkReply::NetworkError)));
|
23
|
+
connect(m_reply, SIGNAL(finished()), SLOT(handleFinished()));
|
24
|
+
|
25
|
+
connect(m_reply, SIGNAL(uploadProgress(qint64,qint64)), SIGNAL(uploadProgress(qint64,qint64)));
|
26
|
+
connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64)));
|
27
|
+
connect(m_reply, SIGNAL(sslErrors(const QList<QSslError> &)), SIGNAL(sslErrors(const QList<QSslError> &)));
|
28
|
+
|
29
|
+
setOpenMode(ReadOnly);
|
30
|
+
}
|
31
|
+
|
32
|
+
void NetworkReplyProxy::abort() { m_reply->abort(); }
|
33
|
+
void NetworkReplyProxy::close() { m_reply->close(); }
|
34
|
+
bool NetworkReplyProxy::isSequential() const { return m_reply->isSequential(); }
|
35
|
+
|
36
|
+
void NetworkReplyProxy::handleFinished() {
|
37
|
+
setFinished(true);
|
38
|
+
emit finished();
|
39
|
+
}
|
40
|
+
|
41
|
+
qint64 NetworkReplyProxy::bytesAvailable() const
|
42
|
+
{
|
43
|
+
return m_buffer.size() + QIODevice::bytesAvailable();
|
44
|
+
}
|
45
|
+
|
46
|
+
qint64 NetworkReplyProxy::readData(char* data, qint64 maxlen)
|
47
|
+
{
|
48
|
+
qint64 size = qMin(maxlen, qint64(m_buffer.size()));
|
49
|
+
memcpy(data, m_buffer.constData(), size);
|
50
|
+
m_buffer.remove(0, size);
|
51
|
+
return size;
|
52
|
+
}
|
53
|
+
|
54
|
+
void NetworkReplyProxy::ignoreSslErrors() { m_reply->ignoreSslErrors(); }
|
55
|
+
void NetworkReplyProxy::applyMetaData() {
|
56
|
+
foreach(QNetworkReply::RawHeaderPair header, m_reply->rawHeaderPairs())
|
57
|
+
setRawHeader(header.first, header.second);
|
58
|
+
|
59
|
+
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute));
|
60
|
+
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute));
|
61
|
+
setAttribute(QNetworkRequest::RedirectionTargetAttribute, m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute));
|
62
|
+
setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, m_reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute));
|
63
|
+
setAttribute(QNetworkRequest::CacheLoadControlAttribute, m_reply->attribute(QNetworkRequest::CacheLoadControlAttribute));
|
64
|
+
setAttribute(QNetworkRequest::CacheSaveControlAttribute, m_reply->attribute(QNetworkRequest::CacheSaveControlAttribute));
|
65
|
+
setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, m_reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute));
|
66
|
+
setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, m_reply->attribute(QNetworkRequest::DoNotBufferUploadDataAttribute));
|
67
|
+
emit metaDataChanged();
|
68
|
+
}
|
69
|
+
|
70
|
+
void NetworkReplyProxy::errorInternal(QNetworkReply::NetworkError _error)
|
71
|
+
{
|
72
|
+
setError(_error, errorString());
|
73
|
+
emit error(_error);
|
74
|
+
}
|
75
|
+
|
76
|
+
void NetworkReplyProxy::readInternal() {
|
77
|
+
QByteArray data = m_reply->readAll();
|
78
|
+
m_data += data;
|
79
|
+
m_buffer += data;
|
80
|
+
}
|
81
|
+
|
82
|
+
void NetworkReplyProxy::handleReadyRead()
|
83
|
+
{
|
84
|
+
readInternal();
|
85
|
+
emit readyRead();
|
86
|
+
}
|
87
|
+
|
88
|
+
QByteArray NetworkReplyProxy::data() {
|
89
|
+
return m_data;
|
90
|
+
}
|
91
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#ifndef _NETWORKREPLYPROXY_H
|
2
|
+
#define _NETWORKREPLYPROXY_H
|
3
|
+
/*
|
4
|
+
* Copyright (C) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies)
|
5
|
+
* Copyright (C) 2009, 2010 Holger Hans Peter Freyther
|
6
|
+
*
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Redistribution and use in source and binary forms, with or without
|
10
|
+
* modification, are permitted provided that the following conditions
|
11
|
+
* are met:
|
12
|
+
* 1. Redistributions of source code must retain the above copyright
|
13
|
+
* notice, this list of conditions and the following disclaimer.
|
14
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
* notice, this list of conditions and the following disclaimer in the
|
16
|
+
* documentation and/or other materials provided with the distribution.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
19
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
|
22
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
26
|
+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#include <QObject>
|
32
|
+
#include <QtNetwork/QNetworkReply>
|
33
|
+
|
34
|
+
class NetworkReplyProxy : public QNetworkReply {
|
35
|
+
Q_OBJECT
|
36
|
+
|
37
|
+
public:
|
38
|
+
NetworkReplyProxy(QNetworkReply* reply, QObject* parent);
|
39
|
+
|
40
|
+
virtual void abort();
|
41
|
+
virtual void close();
|
42
|
+
virtual bool isSequential() const;
|
43
|
+
|
44
|
+
virtual qint64 bytesAvailable() const;
|
45
|
+
|
46
|
+
virtual qint64 readData(char* data, qint64 maxlen);
|
47
|
+
|
48
|
+
QByteArray data();
|
49
|
+
|
50
|
+
public slots:
|
51
|
+
void ignoreSslErrors();
|
52
|
+
void applyMetaData();
|
53
|
+
void errorInternal(QNetworkReply::NetworkError _error);
|
54
|
+
void handleReadyRead();
|
55
|
+
void handleFinished();
|
56
|
+
|
57
|
+
private:
|
58
|
+
void readInternal();
|
59
|
+
|
60
|
+
QNetworkReply* m_reply;
|
61
|
+
QByteArray m_data;
|
62
|
+
QByteArray m_buffer;
|
63
|
+
};
|
64
|
+
|
65
|
+
#endif
|
data/src/Node.cpp
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#include "Node.h"
|
2
2
|
#include "WebPage.h"
|
3
3
|
#include "WebPageManager.h"
|
4
|
+
#include "InvocationResult.h"
|
4
5
|
|
5
|
-
Node::Node(WebPageManager *manager, QStringList &arguments, QObject *parent) :
|
6
|
+
Node::Node(WebPageManager *manager, QStringList &arguments, QObject *parent) : JavascriptCommand(manager, arguments, parent) {
|
6
7
|
}
|
7
8
|
|
8
9
|
void Node::start() {
|
9
10
|
QStringList functionArguments(arguments());
|
10
11
|
QString functionName = functionArguments.takeFirst();
|
11
|
-
|
12
|
-
|
13
|
-
emitFinished(true, attributeValue);
|
12
|
+
InvocationResult result = page()->invokeCapybaraFunction(functionName, functionArguments);
|
13
|
+
finish(&result);
|
14
14
|
}
|
15
15
|
|
16
16
|
QString Node::toString() const {
|
data/src/Node.h
CHANGED
data/src/NullCommand.cpp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "NullCommand.h"
|
2
2
|
#include "WebPage.h"
|
3
3
|
#include "WebPageManager.h"
|
4
|
+
#include "ErrorMessage.h"
|
4
5
|
|
5
6
|
NullCommand::NullCommand(QString name, QObject *parent) : Command(parent) {
|
6
7
|
m_name = name;
|
@@ -8,6 +9,6 @@ NullCommand::NullCommand(QString name, QObject *parent) : Command(parent) {
|
|
8
9
|
|
9
10
|
void NullCommand::start() {
|
10
11
|
QString failure = QString("[Capybara WebKit] Unknown command: ") + m_name + "\n";
|
11
|
-
|
12
|
+
finish(false, new ErrorMessage(failure));
|
12
13
|
}
|
13
14
|
|
data/src/PageLoadingCommand.cpp
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
#include "SocketCommand.h"
|
3
3
|
#include "WebPage.h"
|
4
4
|
#include "WebPageManager.h"
|
5
|
+
#include "ErrorMessage.h"
|
5
6
|
|
6
7
|
PageLoadingCommand::PageLoadingCommand(Command *command, WebPageManager *manager, QObject *parent) : Command(parent) {
|
7
8
|
m_manager = manager;
|
@@ -30,7 +31,7 @@ void PageLoadingCommand::pendingLoadFinished(bool success) {
|
|
30
31
|
emit finished(m_pendingResponse);
|
31
32
|
} else {
|
32
33
|
QString message = m_manager->currentPage()->failureString();
|
33
|
-
|
34
|
+
finish(false, new ErrorMessage(message));
|
34
35
|
}
|
35
36
|
}
|
36
37
|
}
|
data/src/Render.cpp
CHANGED
data/src/Reset.cpp
CHANGED
data/src/ResizeWindow.cpp
CHANGED
data/src/Response.cpp
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "Response.h"
|
2
|
+
#include "ErrorMessage.h"
|
2
3
|
#include <iostream>
|
3
4
|
|
4
5
|
Response::Response(bool success, QString message, QObject *parent) : QObject(parent) {
|
@@ -11,6 +12,12 @@ Response::Response(bool success, QByteArray message, QObject *parent) : QObject(
|
|
11
12
|
m_message = message;
|
12
13
|
}
|
13
14
|
|
15
|
+
Response::Response(bool success, ErrorMessage *message, QObject *parent) : QObject(parent) {
|
16
|
+
m_success = success;
|
17
|
+
m_message = message->toString();
|
18
|
+
message->deleteLater();
|
19
|
+
}
|
20
|
+
|
14
21
|
Response::Response(bool success, QObject *parent) : QObject(parent) {
|
15
22
|
m_success = success;
|
16
23
|
}
|
data/src/Response.h
CHANGED
@@ -5,20 +5,25 @@
|
|
5
5
|
#include <QString>
|
6
6
|
#include <QByteArray>
|
7
7
|
|
8
|
+
class ErrorMessage;
|
9
|
+
|
8
10
|
class Response : public QObject {
|
9
11
|
Q_OBJECT
|
10
12
|
|
11
13
|
public:
|
12
|
-
Response(bool success, QString message, QObject *parent);
|
13
|
-
Response(bool success, QByteArray message, QObject *parent);
|
14
|
+
Response(bool success, QString message, QObject *parent = 0);
|
15
|
+
Response(bool success, QByteArray message, QObject *parent = 0);
|
16
|
+
Response(bool success, ErrorMessage *message, QObject *parent = 0);
|
14
17
|
Response(bool success, QObject *parent);
|
15
18
|
bool isSuccess() const;
|
16
19
|
QByteArray message() const;
|
17
20
|
QString toString() const;
|
18
21
|
|
22
|
+
protected:
|
23
|
+
QByteArray m_message;
|
24
|
+
|
19
25
|
private:
|
20
26
|
bool m_success;
|
21
|
-
QByteArray m_message;
|
22
27
|
};
|
23
28
|
|
24
29
|
#endif
|