otherinbox-capybara-webkit 0.12.0 → 0.12.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/GOALS +9 -0
- data/README.md +1 -1
- data/capybara-webkit.gemspec +1 -1
- data/lib/capybara/webkit.rb +11 -4
- data/lib/capybara/{driver/webkit → webkit}/browser.rb +27 -3
- data/lib/capybara/{driver/webkit → webkit}/connection.rb +45 -47
- data/lib/capybara/{driver/webkit → webkit}/cookie_jar.rb +1 -1
- data/lib/capybara/webkit/driver.rb +150 -0
- data/lib/capybara/webkit/errors.rb +10 -0
- data/lib/capybara/{driver/webkit → webkit}/node.rb +2 -2
- data/lib/capybara/{driver/webkit → webkit}/socket_debugger.rb +1 -1
- data/lib/capybara/{driver/webkit → webkit}/version.rb +1 -1
- data/lib/capybara_webkit_builder.rb +17 -3
- data/spec/browser_spec.rb +38 -25
- data/spec/connection_spec.rb +5 -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 +907 -829
- data/spec/integration/driver_spec.rb +4 -3
- data/spec/spec_helper.rb +14 -6
- data/spec/support/app_runner.rb +91 -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/Command.cpp +4 -15
- data/src/Command.h +3 -14
- data/src/CommandFactory.cpp +10 -6
- data/src/CommandFactory.h +3 -2
- data/src/CommandParser.cpp +1 -1
- data/src/Connection.cpp +22 -11
- data/src/Connection.h +4 -2
- data/src/ConsoleMessages.cpp +2 -1
- data/src/ConsoleMessages.h +3 -5
- data/src/CurrentUrl.cpp +2 -1
- data/src/CurrentUrl.h +3 -5
- 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/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 +2 -1
- data/src/Headers.h +3 -5
- data/src/IgnoreSslErrors.cpp +4 -3
- data/src/IgnoreSslErrors.h +3 -5
- data/src/JavascriptInvocation.cpp +1 -1
- data/src/JavascriptInvocation.h +1 -1
- data/src/NetworkAccessManager.cpp +19 -1
- data/src/NetworkAccessManager.h +10 -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/Server.cpp +2 -3
- data/src/Server.h +0 -2
- data/src/SetCookie.cpp +3 -4
- data/src/SetCookie.h +3 -5
- data/src/SetProxy.cpp +2 -1
- data/src/SetProxy.h +3 -5
- data/src/SetSkipImageLoading.cpp +3 -2
- data/src/SetSkipImageLoading.h +3 -5
- data/src/SocketCommand.cpp +21 -0
- data/src/SocketCommand.h +29 -0
- data/src/Source.cpp +2 -1
- data/src/Source.h +3 -4
- data/src/Status.cpp +2 -1
- data/src/Status.h +3 -5
- data/src/UnsupportedContentHandler.cpp +1 -1
- 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 +86 -39
- data/src/WebPage.h +22 -8
- data/src/WebPageManager.cpp +117 -0
- data/src/WebPageManager.h +56 -0
- data/src/WindowFocus.cpp +32 -0
- data/src/WindowFocus.h +15 -0
- data/src/body.cpp +2 -1
- data/src/find_command.h +6 -2
- data/src/webkit_server.pro +14 -0
- data/templates/Command.cpp +2 -4
- data/templates/Command.h +3 -3
- metadata +29 -10
- data/lib/capybara/driver/webkit.rb +0 -135
@@ -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,7 +1,8 @@
|
|
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() {
|
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() {
|
data/src/Status.h
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class Status : public Command {
|
3
|
+
class Status : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
Status(
|
7
|
+
Status(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
12
10
|
|
@@ -27,6 +27,6 @@ void UnsupportedContentHandler::loadUnsupportedContent() {
|
|
27
27
|
|
28
28
|
void UnsupportedContentHandler::finish(bool success) {
|
29
29
|
connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
|
30
|
-
m_page->
|
30
|
+
m_page->networkAccessManagerFinishedReply(m_reply);
|
31
31
|
m_page->loadFinished(success);
|
32
32
|
}
|
data/src/Url.cpp
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#include "Url.h"
|
2
2
|
#include "WebPage.h"
|
3
|
+
#include "WebPageManager.h"
|
3
4
|
|
4
|
-
Url::Url(
|
5
|
+
Url::Url(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
5
6
|
}
|
6
7
|
|
7
8
|
void Url::start() {
|
data/src/Url.h
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class Url : public Command {
|
3
|
+
class Url : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
Url(
|
7
|
+
Url(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
12
10
|
|
data/src/Visit.cpp
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
#include "Visit.h"
|
2
|
-
#include "
|
2
|
+
#include "SocketCommand.h"
|
3
3
|
#include "WebPage.h"
|
4
|
+
#include "WebPageManager.h"
|
4
5
|
|
5
|
-
Visit::Visit(
|
6
|
+
Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
6
7
|
}
|
7
8
|
|
8
9
|
void Visit::start() {
|
data/src/Visit.h
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
#include "
|
1
|
+
#include "SocketCommand.h"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
class Visit : public Command {
|
3
|
+
class Visit : public SocketCommand {
|
6
4
|
Q_OBJECT
|
7
5
|
|
8
6
|
public:
|
9
|
-
Visit(
|
7
|
+
Visit(WebPageManager *manager, QStringList &arguments, QObject *parent = 0);
|
10
8
|
virtual void start();
|
11
9
|
};
|
12
10
|
|
data/src/WebPage.cpp
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "WebPage.h"
|
2
|
+
#include "WebPageManager.h"
|
2
3
|
#include "JavascriptInvocation.h"
|
3
4
|
#include "NetworkAccessManager.h"
|
4
5
|
#include "NetworkCookieJar.h"
|
@@ -6,14 +7,18 @@
|
|
6
7
|
#include <QResource>
|
7
8
|
#include <iostream>
|
8
9
|
#include <QWebSettings>
|
10
|
+
#include <QUuid>
|
11
|
+
|
12
|
+
WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) {
|
13
|
+
m_loading = false;
|
14
|
+
m_manager = manager;
|
15
|
+
m_uuid = QUuid::createUuid().toString();
|
16
|
+
m_lastStatus = 0;
|
9
17
|
|
10
|
-
WebPage::WebPage(QObject *parent) : QWebPage(parent) {
|
11
18
|
setForwardUnsupportedContent(true);
|
12
19
|
loadJavascript();
|
13
20
|
setUserStylesheet();
|
14
21
|
|
15
|
-
m_loading = false;
|
16
|
-
m_ignoreSslErrors = false;
|
17
22
|
this->setCustomNetworkAccessManager();
|
18
23
|
|
19
24
|
this->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
|
@@ -25,6 +30,8 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) {
|
|
25
30
|
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)),
|
26
31
|
this, SLOT(handleUnsupportedContent(QNetworkReply*)));
|
27
32
|
resetWindowSize();
|
33
|
+
|
34
|
+
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
|
28
35
|
}
|
29
36
|
|
30
37
|
void WebPage::resetWindowSize() {
|
@@ -33,12 +40,33 @@ void WebPage::resetWindowSize() {
|
|
33
40
|
}
|
34
41
|
|
35
42
|
void WebPage::setCustomNetworkAccessManager() {
|
36
|
-
NetworkAccessManager *manager = new NetworkAccessManager();
|
37
|
-
manager->setCookieJar(
|
43
|
+
NetworkAccessManager *manager = new NetworkAccessManager(this);
|
44
|
+
manager->setCookieJar(m_manager->cookieJar());
|
38
45
|
this->setNetworkAccessManager(manager);
|
39
|
-
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(
|
46
|
+
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkAccessManagerFinishedReply(QNetworkReply *)));
|
40
47
|
connect(manager, SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
|
41
48
|
this, SLOT(handleSslErrorsForReply(QNetworkReply *, QList<QSslError>)));
|
49
|
+
connect(manager, SIGNAL(requestCreated(QNetworkReply *)), this, SLOT(networkAccessManagerCreatedRequest(QNetworkReply *)));
|
50
|
+
}
|
51
|
+
|
52
|
+
void WebPage::networkAccessManagerCreatedRequest(QNetworkReply *reply) {
|
53
|
+
emit requestCreated(reply);
|
54
|
+
}
|
55
|
+
|
56
|
+
void WebPage::networkAccessManagerFinishedReply(QNetworkReply *reply) {
|
57
|
+
if (reply->url() == this->currentFrame()->url()) {
|
58
|
+
QStringList headers;
|
59
|
+
m_lastStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
60
|
+
QList<QByteArray> list = reply->rawHeaderList();
|
61
|
+
|
62
|
+
int length = list.size();
|
63
|
+
for(int i = 0; i < length; i++) {
|
64
|
+
headers << list.at(i)+": "+reply->rawHeader(list.at(i));
|
65
|
+
}
|
66
|
+
|
67
|
+
m_pageHeaders = headers.join("\n");
|
68
|
+
}
|
69
|
+
emit replyFinished(reply);
|
42
70
|
}
|
43
71
|
|
44
72
|
void WebPage::loadJavascript() {
|
@@ -90,7 +118,7 @@ bool WebPage::shouldInterruptJavaScript() {
|
|
90
118
|
return false;
|
91
119
|
}
|
92
120
|
|
93
|
-
QVariant WebPage::invokeCapybaraFunction(const char *name, QStringList &arguments) {
|
121
|
+
QVariant WebPage::invokeCapybaraFunction(const char *name, const QStringList &arguments) {
|
94
122
|
QString qname(name);
|
95
123
|
QString objectName("CapybaraInvocation");
|
96
124
|
JavascriptInvocation invocation(qname, arguments);
|
@@ -99,7 +127,7 @@ QVariant WebPage::invokeCapybaraFunction(const char *name, QStringList &argument
|
|
99
127
|
return currentFrame()->evaluateJavaScript(javascript);
|
100
128
|
}
|
101
129
|
|
102
|
-
QVariant WebPage::invokeCapybaraFunction(QString &name, QStringList &arguments) {
|
130
|
+
QVariant WebPage::invokeCapybaraFunction(QString &name, const QStringList &arguments) {
|
103
131
|
return invokeCapybaraFunction(name.toAscii().data(), arguments);
|
104
132
|
}
|
105
133
|
|
@@ -132,6 +160,7 @@ bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &message, const Q
|
|
132
160
|
|
133
161
|
void WebPage::loadStarted() {
|
134
162
|
m_loading = true;
|
163
|
+
m_errorPageMessage = QString();
|
135
164
|
}
|
136
165
|
|
137
166
|
void WebPage::loadFinished(bool success) {
|
@@ -144,7 +173,11 @@ bool WebPage::isLoading() const {
|
|
144
173
|
}
|
145
174
|
|
146
175
|
QString WebPage::failureString() {
|
147
|
-
|
176
|
+
QString message = QString("Unable to load URL: ") + currentFrame()->requestedUrl().toString();
|
177
|
+
if (m_errorPageMessage.isEmpty())
|
178
|
+
return message;
|
179
|
+
else
|
180
|
+
return message + m_errorPageMessage;
|
148
181
|
}
|
149
182
|
|
150
183
|
bool WebPage::render(const QString &fileName) {
|
@@ -182,12 +215,16 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile
|
|
182
215
|
}
|
183
216
|
|
184
217
|
bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) {
|
185
|
-
Q_UNUSED(option);
|
186
218
|
if (extension == ChooseMultipleFilesExtension) {
|
187
219
|
QStringList names = QStringList() << getLastAttachedFileName();
|
188
220
|
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
|
189
221
|
return true;
|
190
222
|
}
|
223
|
+
else if (extension == QWebPage::ErrorPageExtension) {
|
224
|
+
ErrorPageExtensionOption *errorOption = (ErrorPageExtensionOption*) option;
|
225
|
+
m_errorPageMessage = " because of error loading " + errorOption->url.toString() + ": " + errorOption->errorString;
|
226
|
+
return false;
|
227
|
+
}
|
191
228
|
return false;
|
192
229
|
}
|
193
230
|
|
@@ -195,30 +232,11 @@ QString WebPage::getLastAttachedFileName() {
|
|
195
232
|
return currentFrame()->evaluateJavaScript(QString("Capybara.lastAttachedFile")).toString();
|
196
233
|
}
|
197
234
|
|
198
|
-
void WebPage::replyFinished(QNetworkReply *reply) {
|
199
|
-
if (reply->url() == this->currentFrame()->url()) {
|
200
|
-
QStringList headers;
|
201
|
-
m_lastStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
202
|
-
QList<QByteArray> list = reply->rawHeaderList();
|
203
|
-
|
204
|
-
int length = list.size();
|
205
|
-
for(int i = 0; i < length; i++) {
|
206
|
-
headers << list.at(i)+": "+reply->rawHeader(list.at(i));
|
207
|
-
}
|
208
|
-
|
209
|
-
m_pageHeaders = headers.join("\n");
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
235
|
void WebPage::handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &errors) {
|
214
|
-
if (
|
236
|
+
if (m_manager->ignoreSslErrors())
|
215
237
|
reply->ignoreSslErrors(errors);
|
216
238
|
}
|
217
239
|
|
218
|
-
void WebPage::ignoreSslErrors() {
|
219
|
-
m_ignoreSslErrors = true;
|
220
|
-
}
|
221
|
-
|
222
240
|
void WebPage::setSkipImageLoading(bool skip) {
|
223
241
|
settings()->setAttribute(QWebSettings::AutoLoadImages, !skip);
|
224
242
|
}
|
@@ -227,15 +245,6 @@ int WebPage::getLastStatus() {
|
|
227
245
|
return m_lastStatus;
|
228
246
|
}
|
229
247
|
|
230
|
-
void WebPage::resetResponseHeaders() {
|
231
|
-
m_lastStatus = 0;
|
232
|
-
m_pageHeaders = QString();
|
233
|
-
}
|
234
|
-
|
235
|
-
void WebPage::resetConsoleMessages() {
|
236
|
-
m_consoleMessages.clear();
|
237
|
-
}
|
238
|
-
|
239
248
|
QString WebPage::pageHeaders() {
|
240
249
|
return m_pageHeaders;
|
241
250
|
}
|
@@ -244,3 +253,41 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
|
|
244
253
|
UnsupportedContentHandler *handler = new UnsupportedContentHandler(this, reply);
|
245
254
|
Q_UNUSED(handler);
|
246
255
|
}
|
256
|
+
|
257
|
+
bool WebPage::supportsExtension(Extension extension) const {
|
258
|
+
if (extension == ErrorPageExtension)
|
259
|
+
return true;
|
260
|
+
else if (extension == ChooseMultipleFilesExtension)
|
261
|
+
return true;
|
262
|
+
else
|
263
|
+
return false;
|
264
|
+
}
|
265
|
+
|
266
|
+
QWebPage *WebPage::createWindow(WebWindowType type) {
|
267
|
+
Q_UNUSED(type);
|
268
|
+
return m_manager->createPage(this);
|
269
|
+
}
|
270
|
+
|
271
|
+
QString WebPage::uuid() {
|
272
|
+
return m_uuid;
|
273
|
+
}
|
274
|
+
|
275
|
+
QString WebPage::getWindowName() {
|
276
|
+
QVariant windowName = mainFrame()->evaluateJavaScript("window.name");
|
277
|
+
|
278
|
+
if (windowName.isValid())
|
279
|
+
return windowName.toString();
|
280
|
+
else
|
281
|
+
return "";
|
282
|
+
}
|
283
|
+
|
284
|
+
bool WebPage::matchesWindowSelector(QString selector) {
|
285
|
+
return (selector == getWindowName() ||
|
286
|
+
selector == mainFrame()->title() ||
|
287
|
+
selector == mainFrame()->url().toString() ||
|
288
|
+
selector == uuid());
|
289
|
+
}
|
290
|
+
|
291
|
+
void WebPage::setFocus() {
|
292
|
+
m_manager->setCurrentPage(this);
|
293
|
+
}
|
data/src/WebPage.h
CHANGED
@@ -1,25 +1,31 @@
|
|
1
|
+
#ifndef _WEBPAGE_H
|
2
|
+
#define _WEBPAGE_H
|
1
3
|
#include <QtWebKit>
|
2
4
|
|
5
|
+
class WebPageManager;
|
6
|
+
|
3
7
|
class WebPage : public QWebPage {
|
4
8
|
Q_OBJECT
|
5
9
|
|
6
10
|
public:
|
7
|
-
WebPage(QObject *parent = 0);
|
8
|
-
QVariant invokeCapybaraFunction(const char *name, QStringList &arguments);
|
9
|
-
QVariant invokeCapybaraFunction(QString &name, QStringList &arguments);
|
11
|
+
WebPage(WebPageManager *, QObject *parent = 0);
|
12
|
+
QVariant invokeCapybaraFunction(const char *name, const QStringList &arguments);
|
13
|
+
QVariant invokeCapybaraFunction(QString &name, const QStringList &arguments);
|
10
14
|
QString failureString();
|
11
15
|
QString userAgentForUrl(const QUrl &url ) const;
|
12
16
|
void setUserAgent(QString userAgent);
|
13
17
|
int getLastStatus();
|
14
|
-
void resetResponseHeaders();
|
15
18
|
void setCustomNetworkAccessManager();
|
16
19
|
bool render(const QString &fileName);
|
17
20
|
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
|
18
|
-
void ignoreSslErrors();
|
19
21
|
void setSkipImageLoading(bool skip);
|
20
22
|
QString consoleMessages();
|
21
|
-
void resetConsoleMessages();
|
22
23
|
void resetWindowSize();
|
24
|
+
QWebPage *createWindow(WebWindowType type);
|
25
|
+
QString uuid();
|
26
|
+
QString getWindowName();
|
27
|
+
bool matchesWindowSelector(QString);
|
28
|
+
void setFocus();
|
23
29
|
|
24
30
|
public slots:
|
25
31
|
bool shouldInterruptJavaScript();
|
@@ -29,12 +35,15 @@ class WebPage : public QWebPage {
|
|
29
35
|
bool isLoading() const;
|
30
36
|
QString pageHeaders();
|
31
37
|
void frameCreated(QWebFrame *);
|
32
|
-
void replyFinished(QNetworkReply *reply);
|
33
38
|
void handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &);
|
34
39
|
void handleUnsupportedContent(QNetworkReply *reply);
|
40
|
+
void networkAccessManagerCreatedRequest(QNetworkReply *reply);
|
41
|
+
void networkAccessManagerFinishedReply(QNetworkReply *reply);
|
35
42
|
|
36
43
|
signals:
|
37
44
|
void pageFinished(bool);
|
45
|
+
void requestCreated(QNetworkReply *reply);
|
46
|
+
void replyFinished(QNetworkReply *reply);
|
38
47
|
|
39
48
|
protected:
|
40
49
|
virtual void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID);
|
@@ -42,6 +51,7 @@ class WebPage : public QWebPage {
|
|
42
51
|
virtual bool javaScriptConfirm(QWebFrame *frame, const QString &message);
|
43
52
|
virtual bool javaScriptPrompt(QWebFrame *frame, const QString &message, const QString &defaultValue, QString *result);
|
44
53
|
virtual QString chooseFile(QWebFrame * parentFrame, const QString &suggestedFile);
|
54
|
+
virtual bool supportsExtension(Extension extension) const;
|
45
55
|
|
46
56
|
private:
|
47
57
|
QString m_capybaraJavascript;
|
@@ -52,7 +62,11 @@ class WebPage : public QWebPage {
|
|
52
62
|
void setUserStylesheet();
|
53
63
|
int m_lastStatus;
|
54
64
|
QString m_pageHeaders;
|
55
|
-
bool m_ignoreSslErrors;
|
56
65
|
QStringList m_consoleMessages;
|
66
|
+
QString m_uuid;
|
67
|
+
WebPageManager *m_manager;
|
68
|
+
QString m_errorPageMessage;
|
57
69
|
};
|
58
70
|
|
71
|
+
#endif //_WEBPAGE_H
|
72
|
+
|