capybara-webkit 0.13.2 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/Gemfile.lock +20 -18
- data/NEWS.md +20 -1
- data/README.md +12 -10
- data/capybara-webkit.gemspec +3 -2
- data/lib/capybara/webkit/browser.rb +10 -19
- data/lib/capybara/webkit/connection.rb +13 -34
- data/lib/capybara/webkit/driver.rb +5 -22
- data/lib/capybara/webkit/node.rb +10 -2
- data/lib/capybara/webkit/version.rb +1 -1
- data/lib/capybara_webkit_builder.rb +10 -1
- data/spec/browser_spec.rb +1 -1
- data/spec/connection_spec.rb +4 -2
- data/spec/driver_rendering_spec.rb +2 -2
- data/spec/driver_resize_window_spec.rb +29 -40
- data/spec/driver_spec.rb +368 -125
- data/spec/integration/session_spec.rb +100 -6
- data/spec/spec_helper.rb +6 -9
- data/spec/support/app_runner.rb +2 -12
- data/src/Authenticate.cpp +2 -2
- data/src/ClearCookies.cpp +1 -1
- data/src/ClearPromptText.cpp +1 -1
- data/src/Command.cpp +13 -0
- data/src/Command.h +6 -0
- data/src/CommandFactory.cpp +1 -3
- data/src/Connection.cpp +4 -3
- data/src/ConsoleMessages.cpp +4 -1
- data/src/CurrentUrl.cpp +1 -16
- data/src/CurrentUrl.h +0 -6
- data/src/EnableLogging.cpp +1 -1
- data/src/Evaluate.cpp +3 -74
- data/src/Evaluate.h +0 -8
- data/src/Execute.cpp +2 -2
- data/src/Find.cpp +2 -2
- data/src/FrameFocus.cpp +3 -3
- data/src/GetCookies.cpp +1 -1
- data/src/GetTimeout.cpp +1 -1
- data/src/GetWindowHandle.cpp +1 -1
- data/src/GetWindowHandles.cpp +6 -5
- data/src/Header.cpp +2 -2
- data/src/Headers.cpp +1 -1
- data/src/IgnoreSslErrors.cpp +1 -1
- data/src/JavascriptAlertMessages.cpp +4 -1
- data/src/JavascriptConfirmMessages.cpp +4 -1
- data/src/JavascriptPromptMessages.cpp +4 -1
- data/src/JsonSerializer.cpp +116 -0
- data/src/JsonSerializer.h +20 -0
- data/src/NetworkAccessManager.cpp +58 -17
- data/src/NetworkAccessManager.h +6 -0
- data/src/NoOpReply.cpp +32 -0
- data/src/NoOpReply.h +18 -0
- data/src/Node.cpp +1 -1
- data/src/NullCommand.cpp +1 -1
- data/src/PageLoadingCommand.cpp +5 -4
- data/src/Render.cpp +1 -1
- data/src/Reset.cpp +1 -1
- data/src/ResizeWindow.cpp +1 -1
- data/src/Response.cpp +3 -3
- data/src/Response.h +13 -4
- data/src/SetConfirmAction.cpp +1 -1
- data/src/SetCookie.cpp +1 -1
- 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 +2 -2
- data/src/SetUrlBlacklist.cpp +15 -0
- data/src/SetUrlBlacklist.h +11 -0
- data/src/Status.cpp +1 -1
- data/src/TimeoutCommand.cpp +6 -6
- data/src/TimeoutCommand.h +0 -3
- data/src/UnsupportedContentHandler.cpp +1 -4
- data/src/Visit.cpp +1 -1
- data/src/WebPage.cpp +41 -31
- data/src/WebPage.h +14 -12
- data/src/WebPageManager.cpp +13 -8
- data/src/WebPageManager.h +3 -2
- data/src/WindowFocus.cpp +2 -2
- data/src/body.cpp +7 -2
- data/src/capybara.js +10 -2
- data/src/find_command.h +1 -3
- data/src/webkit_server.pro +7 -7
- metadata +47 -82
- checksums.yaml +0 -7
- data/spec/integration/driver_spec.rb +0 -21
- data/src/RequestedUrl.cpp +0 -13
- data/src/RequestedUrl.h +0 -10
- data/src/Source.cpp +0 -19
- data/src/Source.h +0 -18
- data/src/Url.cpp +0 -13
- data/src/Url.h +0 -10
data/src/NoOpReply.cpp
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <QTimer>
|
2
|
+
#include "NoOpReply.h"
|
3
|
+
|
4
|
+
NoOpReply::NoOpReply(QNetworkRequest &request, QObject *parent) : QNetworkReply(parent) {
|
5
|
+
open(ReadOnly | Unbuffered);
|
6
|
+
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
|
7
|
+
setHeader(QNetworkRequest::ContentLengthHeader, QVariant(0));
|
8
|
+
setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QString("text/plain")));
|
9
|
+
setUrl(request.url());
|
10
|
+
|
11
|
+
QTimer::singleShot( 0, this, SIGNAL(readyRead()) );
|
12
|
+
QTimer::singleShot( 0, this, SIGNAL(finished()) );
|
13
|
+
}
|
14
|
+
|
15
|
+
void NoOpReply::abort() {
|
16
|
+
// NO-OP
|
17
|
+
}
|
18
|
+
|
19
|
+
qint64 NoOpReply::bytesAvailable() const {
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
bool NoOpReply::isSequential() const {
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
|
27
|
+
qint64 NoOpReply::readData(char *data, qint64 maxSize) {
|
28
|
+
Q_UNUSED(data);
|
29
|
+
Q_UNUSED(maxSize);
|
30
|
+
return 0;
|
31
|
+
}
|
32
|
+
|
data/src/NoOpReply.h
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#include <QNetworkReply>
|
2
|
+
#include <QNetworkRequest>
|
3
|
+
|
4
|
+
class NoOpReply : public QNetworkReply {
|
5
|
+
Q_OBJECT
|
6
|
+
|
7
|
+
public:
|
8
|
+
NoOpReply(QNetworkRequest &request, QObject *parent = 0);
|
9
|
+
|
10
|
+
void abort();
|
11
|
+
qint64 bytesAvailable() const;
|
12
|
+
bool isSequential() const;
|
13
|
+
|
14
|
+
protected:
|
15
|
+
qint64 readData(char *data, qint64 maxSize);
|
16
|
+
|
17
|
+
};
|
18
|
+
|
data/src/Node.cpp
CHANGED
@@ -10,7 +10,7 @@ void Node::start() {
|
|
10
10
|
QString functionName = functionArguments.takeFirst();
|
11
11
|
QVariant result = page()->invokeCapybaraFunction(functionName, functionArguments);
|
12
12
|
QString attributeValue = result.toString();
|
13
|
-
|
13
|
+
emitFinished(true, attributeValue);
|
14
14
|
}
|
15
15
|
|
16
16
|
QString Node::toString() const {
|
data/src/NullCommand.cpp
CHANGED
@@ -8,6 +8,6 @@ NullCommand::NullCommand(QString name, QObject *parent) : Command(parent) {
|
|
8
8
|
|
9
9
|
void NullCommand::start() {
|
10
10
|
QString failure = QString("[Capybara WebKit] Unknown command: ") + m_name + "\n";
|
11
|
-
|
11
|
+
emitFinished(false, failure);
|
12
12
|
}
|
13
13
|
|
data/src/PageLoadingCommand.cpp
CHANGED
@@ -9,13 +9,14 @@ PageLoadingCommand::PageLoadingCommand(Command *command, WebPageManager *manager
|
|
9
9
|
m_pageLoadingFromCommand = false;
|
10
10
|
m_pageSuccess = true;
|
11
11
|
m_pendingResponse = NULL;
|
12
|
-
|
13
|
-
connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
12
|
+
m_command->setParent(this);
|
14
13
|
}
|
15
14
|
|
16
15
|
void PageLoadingCommand::start() {
|
17
16
|
m_manager->logger() << "Started" << m_command->toString();
|
18
17
|
connect(m_command, SIGNAL(finished(Response *)), this, SLOT(commandFinished(Response *)));
|
18
|
+
connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
|
19
|
+
connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
19
20
|
m_command->start();
|
20
21
|
};
|
21
22
|
|
@@ -29,7 +30,7 @@ void PageLoadingCommand::pendingLoadFinished(bool success) {
|
|
29
30
|
emit finished(m_pendingResponse);
|
30
31
|
} else {
|
31
32
|
QString message = m_manager->currentPage()->failureString();
|
32
|
-
|
33
|
+
emitFinished(false, message);
|
33
34
|
}
|
34
35
|
}
|
35
36
|
}
|
@@ -43,7 +44,7 @@ void PageLoadingCommand::pageLoadingFromCommand() {
|
|
43
44
|
void PageLoadingCommand::commandFinished(Response *response) {
|
44
45
|
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
|
45
46
|
m_manager->logger() << "Finished" << m_command->toString() << "with response" << response->toString();
|
46
|
-
|
47
|
+
|
47
48
|
if (m_pageLoadingFromCommand)
|
48
49
|
m_pendingResponse = response;
|
49
50
|
else
|
data/src/Render.cpp
CHANGED
data/src/Reset.cpp
CHANGED
data/src/ResizeWindow.cpp
CHANGED
data/src/Response.cpp
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
#include "Response.h"
|
2
2
|
#include <iostream>
|
3
3
|
|
4
|
-
Response::Response(bool success, QString message) {
|
4
|
+
Response::Response(bool success, QString message, QObject *parent) : QObject(parent) {
|
5
5
|
m_success = success;
|
6
6
|
m_message = message.toUtf8();
|
7
7
|
}
|
8
8
|
|
9
|
-
Response::Response(bool success, QByteArray message) {
|
9
|
+
Response::Response(bool success, QByteArray message, QObject *parent) : QObject(parent) {
|
10
10
|
m_success = success;
|
11
11
|
m_message = message;
|
12
12
|
}
|
13
13
|
|
14
|
-
Response::Response(bool success) {
|
14
|
+
Response::Response(bool success, QObject *parent) : QObject(parent) {
|
15
15
|
m_success = success;
|
16
16
|
}
|
17
17
|
|
data/src/Response.h
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
+
#ifndef RESPONSE_H
|
2
|
+
#define RESPONSE_H
|
3
|
+
|
4
|
+
#include <QObject>
|
1
5
|
#include <QString>
|
2
6
|
#include <QByteArray>
|
3
7
|
|
4
|
-
class Response {
|
8
|
+
class Response : public QObject {
|
9
|
+
Q_OBJECT
|
10
|
+
|
5
11
|
public:
|
6
|
-
Response(bool success, QString message);
|
7
|
-
Response(bool success, QByteArray message);
|
8
|
-
Response(bool success);
|
12
|
+
Response(bool success, QString message, QObject *parent);
|
13
|
+
Response(bool success, QByteArray message, QObject *parent);
|
14
|
+
Response(bool success, QObject *parent);
|
9
15
|
bool isSuccess() const;
|
10
16
|
QByteArray message() const;
|
11
17
|
QString toString() const;
|
@@ -14,3 +20,6 @@ class Response {
|
|
14
20
|
bool m_success;
|
15
21
|
QByteArray m_message;
|
16
22
|
};
|
23
|
+
|
24
|
+
#endif
|
25
|
+
|
data/src/SetConfirmAction.cpp
CHANGED
data/src/SetCookie.cpp
CHANGED
@@ -11,5 +11,5 @@ void SetCookie::start()
|
|
11
11
|
QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments()[0].toAscii());
|
12
12
|
NetworkCookieJar *jar = manager()->cookieJar();
|
13
13
|
jar->overwriteCookies(cookies);
|
14
|
-
|
14
|
+
emitFinished(true);
|
15
15
|
}
|
data/src/SetPromptAction.cpp
CHANGED
data/src/SetPromptText.cpp
CHANGED
data/src/SetProxy.cpp
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#include "SetProxy.h"
|
2
2
|
#include "WebPage.h"
|
3
3
|
#include "WebPageManager.h"
|
4
|
-
#include
|
4
|
+
#include "NetworkAccessManager.h"
|
5
5
|
#include <QNetworkProxy>
|
6
6
|
|
7
7
|
SetProxy::SetProxy(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
@@ -19,5 +19,5 @@ void SetProxy::start()
|
|
19
19
|
arguments()[3]);
|
20
20
|
|
21
21
|
page()->networkAccessManager()->setProxy(proxy);
|
22
|
-
|
22
|
+
emitFinished(true);
|
23
23
|
}
|
data/src/SetSkipImageLoading.cpp
CHANGED
data/src/SetTimeout.cpp
CHANGED
@@ -11,9 +11,9 @@ void SetTimeout::start() {
|
|
11
11
|
|
12
12
|
if (ok) {
|
13
13
|
manager()->setTimeout(timeout);
|
14
|
-
|
14
|
+
emitFinished(true);
|
15
15
|
} else {
|
16
|
-
|
16
|
+
emitFinished(false, QString("Invalid value for timeout"));
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
#include "SetUrlBlacklist.h"
|
3
|
+
#include "WebPageManager.h"
|
4
|
+
#include "WebPage.h"
|
5
|
+
#include "NetworkAccessManager.h"
|
6
|
+
|
7
|
+
SetUrlBlacklist::SetUrlBlacklist(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
8
|
+
}
|
9
|
+
|
10
|
+
void SetUrlBlacklist::start() {
|
11
|
+
NetworkAccessManager* networkAccessManager = page()->networkAccessManager();
|
12
|
+
networkAccessManager->setUrlBlacklist(arguments());
|
13
|
+
emitFinished(true);
|
14
|
+
}
|
15
|
+
|
data/src/Status.cpp
CHANGED
@@ -8,6 +8,6 @@ Status::Status(WebPageManager *manager, QStringList &arguments, QObject *parent)
|
|
8
8
|
|
9
9
|
void Status::start() {
|
10
10
|
int status = page()->getLastStatus();
|
11
|
-
|
11
|
+
emitFinished(true, QString::number(status));
|
12
12
|
}
|
13
13
|
|
data/src/TimeoutCommand.cpp
CHANGED
@@ -3,17 +3,20 @@
|
|
3
3
|
#include "WebPageManager.h"
|
4
4
|
#include "WebPage.h"
|
5
5
|
#include <QTimer>
|
6
|
+
#include <QApplication>
|
6
7
|
|
7
8
|
TimeoutCommand::TimeoutCommand(Command *command, WebPageManager *manager, QObject *parent) : Command(parent) {
|
8
9
|
m_command = command;
|
9
10
|
m_manager = manager;
|
10
11
|
m_timer = new QTimer(this);
|
11
12
|
m_timer->setSingleShot(true);
|
13
|
+
m_command->setParent(this);
|
12
14
|
connect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
|
13
15
|
connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
|
14
16
|
}
|
15
17
|
|
16
18
|
void TimeoutCommand::start() {
|
19
|
+
QApplication::processEvents();
|
17
20
|
if (m_manager->isLoading()) {
|
18
21
|
m_manager->logger() << this->toString() << "waiting for load to finish";
|
19
22
|
connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
@@ -36,13 +39,13 @@ void TimeoutCommand::startTimeout() {
|
|
36
39
|
}
|
37
40
|
|
38
41
|
void TimeoutCommand::pendingLoadFinished(bool success) {
|
42
|
+
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
39
43
|
if (success) {
|
40
44
|
startCommand();
|
41
45
|
} else {
|
42
46
|
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
|
43
47
|
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
|
44
|
-
|
45
|
-
emit finished(new Response(false, m_manager->currentPage()->failureString()));
|
48
|
+
emitFinished(false, m_manager->currentPage()->failureString());
|
46
49
|
}
|
47
50
|
}
|
48
51
|
|
@@ -55,15 +58,12 @@ void TimeoutCommand::commandTimeout() {
|
|
55
58
|
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
56
59
|
disconnect(m_command, SIGNAL(finished(Response *)), this, SLOT(commandFinished(Response *)));
|
57
60
|
m_manager->currentPage()->triggerAction(QWebPage::Stop);
|
58
|
-
|
59
|
-
emit finished(new Response(false, QString("timeout")));
|
61
|
+
emit finished(new Response(false, QString("timeout"), this));
|
60
62
|
}
|
61
63
|
|
62
64
|
void TimeoutCommand::commandFinished(Response *response) {
|
63
65
|
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
|
64
66
|
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
|
65
|
-
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
66
|
-
m_command->deleteLater();
|
67
67
|
emit finished(response);
|
68
68
|
}
|
69
69
|
|
data/src/TimeoutCommand.h
CHANGED
@@ -10,17 +10,14 @@ UnsupportedContentHandler::UnsupportedContentHandler(WebPage *page, QNetworkRepl
|
|
10
10
|
void UnsupportedContentHandler::renderNonHtmlContent() {
|
11
11
|
QByteArray text = m_reply->readAll();
|
12
12
|
m_page->mainFrame()->setContent(text, QString("text/plain"), m_reply->url());
|
13
|
-
m_page->
|
14
|
-
m_page->loadFinished(true);
|
13
|
+
m_page->unsupportedContentFinishedReply(m_reply);
|
15
14
|
this->deleteLater();
|
16
15
|
}
|
17
16
|
|
18
17
|
void UnsupportedContentHandler::waitForReplyToFinish() {
|
19
18
|
connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
|
20
|
-
disconnect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
|
21
19
|
}
|
22
20
|
|
23
21
|
void UnsupportedContentHandler::replyFinished() {
|
24
22
|
renderNonHtmlContent();
|
25
|
-
connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
|
26
23
|
}
|
data/src/Visit.cpp
CHANGED
@@ -9,5 +9,5 @@ Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) :
|
|
9
9
|
void Visit::start() {
|
10
10
|
QUrl requestedUrl = QUrl::fromEncoded(arguments()[0].toUtf8(), QUrl::StrictMode);
|
11
11
|
page()->currentFrame()->load(QUrl(requestedUrl));
|
12
|
-
|
12
|
+
emitFinished(true);
|
13
13
|
}
|
data/src/WebPage.cpp
CHANGED
@@ -14,6 +14,7 @@ WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) {
|
|
14
14
|
m_failed = false;
|
15
15
|
m_manager = manager;
|
16
16
|
m_uuid = QUuid::createUuid().toString();
|
17
|
+
m_unsupportedContentLoaded = false;
|
17
18
|
|
18
19
|
setForwardUnsupportedContent(true);
|
19
20
|
loadJavascript();
|
@@ -33,7 +34,6 @@ WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) {
|
|
33
34
|
resetWindowSize();
|
34
35
|
|
35
36
|
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
|
36
|
-
currentFrame()->setUrl(QUrl("about:blank"));
|
37
37
|
}
|
38
38
|
|
39
39
|
void WebPage::resetWindowSize() {
|
@@ -45,18 +45,15 @@ void WebPage::setCustomNetworkAccessManager() {
|
|
45
45
|
NetworkAccessManager *manager = new NetworkAccessManager(this);
|
46
46
|
manager->setCookieJar(m_manager->cookieJar());
|
47
47
|
this->setNetworkAccessManager(manager);
|
48
|
-
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkAccessManagerFinishedReply(QNetworkReply *)));
|
49
48
|
connect(manager, SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
|
50
49
|
this, SLOT(handleSslErrorsForReply(QNetworkReply *, QList<QSslError>)));
|
51
|
-
connect(manager, SIGNAL(requestCreated(QByteArray &, QNetworkReply *)),
|
50
|
+
connect(manager, SIGNAL(requestCreated(QByteArray &, QNetworkReply *)),
|
51
|
+
SIGNAL(requestCreated(QByteArray &, QNetworkReply *)));
|
52
52
|
}
|
53
53
|
|
54
|
-
void WebPage::
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
void WebPage::networkAccessManagerFinishedReply(QNetworkReply *reply) {
|
59
|
-
emit replyFinished(reply);
|
54
|
+
void WebPage::unsupportedContentFinishedReply(QNetworkReply *reply) {
|
55
|
+
m_unsupportedContentLoaded = true;
|
56
|
+
m_manager->replyFinished(reply);
|
60
57
|
}
|
61
58
|
|
62
59
|
void WebPage::loadJavascript() {
|
@@ -73,7 +70,7 @@ void WebPage::loadJavascript() {
|
|
73
70
|
}
|
74
71
|
|
75
72
|
void WebPage::setUserStylesheet() {
|
76
|
-
QString data = QString("
|
73
|
+
QString data = QString("*, :first-line, :first-letter, :before, :after { font-family: 'Arial' ! important; }").toUtf8().toBase64();
|
77
74
|
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
|
78
75
|
settings()->setUserStyleSheetUrl(url);
|
79
76
|
}
|
@@ -86,20 +83,20 @@ QString WebPage::userAgentForUrl(const QUrl &url ) const {
|
|
86
83
|
}
|
87
84
|
}
|
88
85
|
|
89
|
-
|
90
|
-
return m_consoleMessages
|
86
|
+
QVariantList WebPage::consoleMessages() {
|
87
|
+
return m_consoleMessages;
|
91
88
|
}
|
92
89
|
|
93
|
-
|
94
|
-
return m_alertMessages
|
90
|
+
QVariantList WebPage::alertMessages() {
|
91
|
+
return m_alertMessages;
|
95
92
|
}
|
96
93
|
|
97
|
-
|
98
|
-
return m_confirmMessages
|
94
|
+
QVariantList WebPage::confirmMessages() {
|
95
|
+
return m_confirmMessages;
|
99
96
|
}
|
100
97
|
|
101
|
-
|
102
|
-
return m_promptMessages
|
98
|
+
QVariantList WebPage::promptMessages() {
|
99
|
+
return m_promptMessages;
|
103
100
|
}
|
104
101
|
|
105
102
|
void WebPage::setUserAgent(QString userAgent) {
|
@@ -134,17 +131,22 @@ QVariant WebPage::invokeCapybaraFunction(QString &name, const QStringList &argum
|
|
134
131
|
}
|
135
132
|
|
136
133
|
void WebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
134
|
+
QVariantMap m;
|
135
|
+
m["message"] = message;
|
136
|
+
QString fullMessage = QString(message);
|
137
|
+
if (!sourceID.isEmpty()) {
|
138
|
+
fullMessage = sourceID + "|" + QString::number(lineNumber) + "|" + fullMessage;
|
139
|
+
m["source"] = sourceID;
|
140
|
+
m["line_number"] = lineNumber;
|
141
|
+
}
|
142
|
+
m_consoleMessages.append(m);
|
143
|
+
m_manager->logger() << qPrintable(fullMessage);
|
142
144
|
}
|
143
145
|
|
144
146
|
void WebPage::javaScriptAlert(QWebFrame *frame, const QString &message) {
|
145
147
|
Q_UNUSED(frame);
|
146
148
|
m_alertMessages.append(message);
|
147
|
-
|
149
|
+
m_manager->logger() << "ALERT:" << qPrintable(message);
|
148
150
|
}
|
149
151
|
|
150
152
|
bool WebPage::javaScriptConfirm(QWebFrame *frame, const QString &message) {
|
@@ -169,6 +171,7 @@ bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &message, const Q
|
|
169
171
|
void WebPage::loadStarted() {
|
170
172
|
m_loading = true;
|
171
173
|
m_errorPageMessage = QString();
|
174
|
+
m_unsupportedContentLoaded = false;
|
172
175
|
}
|
173
176
|
|
174
177
|
void WebPage::loadFinished(bool success) {
|
@@ -221,13 +224,12 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile
|
|
221
224
|
Q_UNUSED(parentFrame);
|
222
225
|
Q_UNUSED(suggestedFile);
|
223
226
|
|
224
|
-
return
|
227
|
+
return getAttachedFileNames().first();
|
225
228
|
}
|
226
229
|
|
227
230
|
bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) {
|
228
231
|
if (extension == ChooseMultipleFilesExtension) {
|
229
|
-
|
230
|
-
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
|
232
|
+
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = getAttachedFileNames();
|
231
233
|
return true;
|
232
234
|
}
|
233
235
|
else if (extension == QWebPage::ErrorPageExtension) {
|
@@ -239,8 +241,8 @@ bool WebPage::extension(Extension extension, const ExtensionOption *option, Exte
|
|
239
241
|
return false;
|
240
242
|
}
|
241
243
|
|
242
|
-
|
243
|
-
return currentFrame()->evaluateJavaScript(QString("Capybara.
|
244
|
+
QStringList WebPage::getAttachedFileNames() {
|
245
|
+
return currentFrame()->evaluateJavaScript(QString("Capybara.attachedFiles")).toStringList();
|
244
246
|
}
|
245
247
|
|
246
248
|
void WebPage::handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &errors) {
|
@@ -253,11 +255,15 @@ void WebPage::setSkipImageLoading(bool skip) {
|
|
253
255
|
}
|
254
256
|
|
255
257
|
int WebPage::getLastStatus() {
|
256
|
-
return
|
258
|
+
return networkAccessManager()->statusFor(currentFrame()->requestedUrl());
|
257
259
|
}
|
258
260
|
|
259
261
|
const QList<QNetworkReply::RawHeaderPair> &WebPage::pageHeaders() {
|
260
|
-
return
|
262
|
+
return networkAccessManager()->headersFor(currentFrame()->requestedUrl());
|
263
|
+
}
|
264
|
+
|
265
|
+
NetworkAccessManager *WebPage::networkAccessManager() {
|
266
|
+
return qobject_cast<NetworkAccessManager *>(QWebPage::networkAccessManager());
|
261
267
|
}
|
262
268
|
|
263
269
|
void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
|
@@ -272,6 +278,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
|
|
272
278
|
}
|
273
279
|
}
|
274
280
|
|
281
|
+
bool WebPage::unsupportedContentLoaded() {
|
282
|
+
return m_unsupportedContentLoaded;
|
283
|
+
}
|
284
|
+
|
275
285
|
bool WebPage::supportsExtension(Extension extension) const {
|
276
286
|
if (extension == ErrorPageExtension)
|
277
287
|
return true;
|