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.
Files changed (111) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +21 -0
  3. data/Appraisals +4 -4
  4. data/CONTRIBUTING.md +14 -3
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +27 -19
  7. data/NEWS.md +15 -0
  8. data/README.md +126 -76
  9. data/Vagrantfile +7 -0
  10. data/capybara-webkit.gemspec +3 -0
  11. data/gemfiles/2.0.gemfile +7 -0
  12. data/gemfiles/2.0.gemfile.lock +72 -0
  13. data/gemfiles/2.1.gemfile +7 -0
  14. data/gemfiles/2.1.gemfile.lock +71 -0
  15. data/lib/capybara/webkit/browser.rb +22 -22
  16. data/lib/capybara/webkit/connection.rb +9 -6
  17. data/lib/capybara/webkit/driver.rb +22 -6
  18. data/lib/capybara/webkit/errors.rb +25 -0
  19. data/lib/capybara/webkit/node.rb +36 -10
  20. data/lib/capybara/webkit/version.rb +1 -1
  21. data/spec/browser_spec.rb +16 -1
  22. data/spec/capybara_webkit_builder_spec.rb +9 -3
  23. data/spec/connection_spec.rb +19 -3
  24. data/spec/driver_spec.rb +324 -144
  25. data/spec/errors_spec.rb +11 -0
  26. data/spec/integration/session_spec.rb +244 -0
  27. data/spec/selenium_compatibility_spec.rb +3 -1
  28. data/spec/spec_helper.rb +1 -9
  29. data/src/Authenticate.cpp +3 -2
  30. data/src/ClearCookies.cpp +1 -1
  31. data/src/ClearPromptText.cpp +1 -1
  32. data/src/Command.cpp +8 -4
  33. data/src/Command.h +7 -4
  34. data/src/CommandFactory.cpp +4 -2
  35. data/src/CommandParser.cpp +1 -1
  36. data/src/Connection.cpp +4 -4
  37. data/src/ConsoleMessages.cpp +1 -1
  38. data/src/CurrentUrl.cpp +2 -2
  39. data/src/EnableLogging.cpp +1 -1
  40. data/src/ErrorMessage.cpp +26 -0
  41. data/src/ErrorMessage.h +21 -0
  42. data/src/Evaluate.cpp +1 -1
  43. data/src/Execute.cpp +3 -2
  44. data/src/FindCss.cpp +13 -0
  45. data/src/FindCss.h +11 -0
  46. data/src/FindXpath.cpp +13 -0
  47. data/src/FindXpath.h +11 -0
  48. data/src/FrameFocus.cpp +4 -3
  49. data/src/GetCookies.cpp +1 -1
  50. data/src/GetTimeout.cpp +1 -1
  51. data/src/GetWindowHandle.cpp +1 -1
  52. data/src/GetWindowHandles.cpp +1 -1
  53. data/src/Header.cpp +2 -2
  54. data/src/Headers.cpp +1 -6
  55. data/src/IgnoreSslErrors.cpp +1 -1
  56. data/src/InvocationResult.cpp +29 -0
  57. data/src/InvocationResult.h +16 -0
  58. data/src/JavascriptAlertMessages.cpp +1 -1
  59. data/src/JavascriptCommand.cpp +15 -0
  60. data/src/JavascriptCommand.h +20 -0
  61. data/src/JavascriptConfirmMessages.cpp +1 -1
  62. data/src/JavascriptInvocation.cpp +128 -1
  63. data/src/JavascriptInvocation.h +22 -1
  64. data/src/JavascriptPromptMessages.cpp +1 -1
  65. data/src/NetworkAccessManager.cpp +8 -16
  66. data/src/NetworkAccessManager.h +5 -11
  67. data/src/NetworkReplyProxy.cpp +91 -0
  68. data/src/NetworkReplyProxy.h +65 -0
  69. data/src/Node.cpp +4 -4
  70. data/src/Node.h +2 -2
  71. data/src/NullCommand.cpp +2 -1
  72. data/src/PageLoadingCommand.cpp +2 -1
  73. data/src/Render.cpp +1 -1
  74. data/src/Reset.cpp +1 -1
  75. data/src/ResizeWindow.cpp +1 -1
  76. data/src/Response.cpp +7 -0
  77. data/src/Response.h +8 -3
  78. data/src/SetConfirmAction.cpp +1 -1
  79. data/src/SetCookie.cpp +2 -2
  80. data/src/SetPromptAction.cpp +1 -1
  81. data/src/SetPromptText.cpp +1 -1
  82. data/src/SetProxy.cpp +2 -2
  83. data/src/SetSkipImageLoading.cpp +1 -1
  84. data/src/SetTimeout.cpp +3 -2
  85. data/src/SetUrlBlacklist.cpp +2 -2
  86. data/src/Status.cpp +1 -1
  87. data/src/TimeoutCommand.cpp +4 -2
  88. data/src/Title.cpp +11 -0
  89. data/src/Title.h +9 -0
  90. data/src/Version.cpp +13 -0
  91. data/src/Version.h +10 -0
  92. data/src/Visit.cpp +1 -1
  93. data/src/WebPage.cpp +49 -27
  94. data/src/WebPage.h +14 -7
  95. data/src/WebPageManager.cpp +10 -1
  96. data/src/WebPageManager.h +4 -1
  97. data/src/WindowFocus.cpp +3 -2
  98. data/src/body.cpp +3 -6
  99. data/src/capybara.js +103 -101
  100. data/src/find_command.h +4 -2
  101. data/src/main.cpp +1 -1
  102. data/src/stable.h +39 -0
  103. data/src/webkit_server.pro +26 -6
  104. data/vagrant_setup.sh +58 -0
  105. metadata +51 -78
  106. data/gemfiles/1.0.gemfile +0 -7
  107. data/gemfiles/1.0.gemfile.lock +0 -70
  108. data/gemfiles/1.1.gemfile +0 -7
  109. data/gemfiles/1.1.gemfile.lock +0 -70
  110. data/src/Find.cpp +0 -20
  111. data/src/Find.h +0 -11
@@ -7,5 +7,5 @@ SetConfirmAction::SetConfirmAction(WebPageManager *manager, QStringList &argumen
7
7
  void SetConfirmAction::start()
8
8
  {
9
9
  page()->setConfirmAction(arguments()[0]);
10
- emitFinished(true);
10
+ finish(true);
11
11
  }
data/src/SetCookie.cpp CHANGED
@@ -8,8 +8,8 @@ SetCookie::SetCookie(WebPageManager *manager, QStringList &arguments, QObject *p
8
8
 
9
9
  void SetCookie::start()
10
10
  {
11
- QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments()[0].toAscii());
11
+ QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(arguments()[0].toLatin1());
12
12
  NetworkCookieJar *jar = manager()->cookieJar();
13
13
  jar->overwriteCookies(cookies);
14
- emitFinished(true);
14
+ finish(true);
15
15
  }
@@ -7,5 +7,5 @@ SetPromptAction::SetPromptAction(WebPageManager *manager, QStringList &arguments
7
7
  void SetPromptAction::start()
8
8
  {
9
9
  page()->setPromptAction(arguments()[0]);
10
- emitFinished(true);
10
+ finish(true);
11
11
  }
@@ -7,5 +7,5 @@ SetPromptText::SetPromptText(WebPageManager *manager, QStringList &arguments, QO
7
7
  void SetPromptText::start()
8
8
  {
9
9
  page()->setPromptText(arguments()[0]);
10
- emitFinished(true);
10
+ finish(true);
11
11
  }
data/src/SetProxy.cpp CHANGED
@@ -18,6 +18,6 @@ void SetProxy::start()
18
18
  arguments()[2],
19
19
  arguments()[3]);
20
20
 
21
- page()->networkAccessManager()->setProxy(proxy);
22
- emitFinished(true);
21
+ manager()->networkAccessManager()->setProxy(proxy);
22
+ finish(true);
23
23
  }
@@ -8,5 +8,5 @@ SetSkipImageLoading::SetSkipImageLoading(WebPageManager *manager, QStringList &a
8
8
 
9
9
  void SetSkipImageLoading::start() {
10
10
  page()->setSkipImageLoading(arguments().contains("true"));
11
- emitFinished(true);
11
+ finish(true);
12
12
  }
data/src/SetTimeout.cpp CHANGED
@@ -1,5 +1,6 @@
1
1
  #include "SetTimeout.h"
2
2
  #include "WebPageManager.h"
3
+ #include "ErrorMessage.h"
3
4
 
4
5
  SetTimeout::SetTimeout(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
5
6
  }
@@ -11,9 +12,9 @@ void SetTimeout::start() {
11
12
 
12
13
  if (ok) {
13
14
  manager()->setTimeout(timeout);
14
- emitFinished(true);
15
+ finish(true);
15
16
  } else {
16
- emitFinished(false, QString("Invalid value for timeout"));
17
+ finish(false, new ErrorMessage("Invalid value for timeout"));
17
18
  }
18
19
  }
19
20
 
@@ -8,8 +8,8 @@ SetUrlBlacklist::SetUrlBlacklist(WebPageManager *manager, QStringList &arguments
8
8
  }
9
9
 
10
10
  void SetUrlBlacklist::start() {
11
- NetworkAccessManager* networkAccessManager = page()->networkAccessManager();
11
+ NetworkAccessManager* networkAccessManager = manager()->networkAccessManager();
12
12
  networkAccessManager->setUrlBlacklist(arguments());
13
- emitFinished(true);
13
+ finish(true);
14
14
  }
15
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
- emitFinished(true, QString::number(status));
11
+ finish(true, QString::number(status));
12
12
  }
13
13
 
@@ -2,6 +2,7 @@
2
2
  #include "Command.h"
3
3
  #include "WebPageManager.h"
4
4
  #include "WebPage.h"
5
+ #include "ErrorMessage.h"
5
6
  #include <QTimer>
6
7
  #include <QApplication>
7
8
 
@@ -45,7 +46,7 @@ void TimeoutCommand::pendingLoadFinished(bool success) {
45
46
  } else {
46
47
  disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
47
48
  disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
48
- emitFinished(false, m_manager->currentPage()->failureString());
49
+ finish(false, new ErrorMessage(m_manager->currentPage()->failureString()));
49
50
  }
50
51
  }
51
52
 
@@ -58,7 +59,8 @@ void TimeoutCommand::commandTimeout() {
58
59
  disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
59
60
  disconnect(m_command, SIGNAL(finished(Response *)), this, SLOT(commandFinished(Response *)));
60
61
  m_manager->currentPage()->triggerAction(QWebPage::Stop);
61
- emit finished(new Response(false, QString("timeout"), this));
62
+ QString message = QString("Request timed out after %1 second(s)").arg(m_manager->getTimeout());
63
+ finish(false, new ErrorMessage("TimeoutError", message));
62
64
  }
63
65
 
64
66
  void TimeoutCommand::commandFinished(Response *response) {
data/src/Title.cpp ADDED
@@ -0,0 +1,11 @@
1
+ #include "Title.h"
2
+ #include "WebPage.h"
3
+ #include "WebPageManager.h"
4
+ #include "NetworkAccessManager.h"
5
+
6
+ Title::Title(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
7
+ }
8
+
9
+ void Title::start() {
10
+ finish(true, page()->currentFrame()->title());
11
+ }
data/src/Title.h ADDED
@@ -0,0 +1,9 @@
1
+ #include "SocketCommand.h"
2
+
3
+ class Title : public SocketCommand {
4
+ Q_OBJECT
5
+
6
+ public:
7
+ Title(WebPageManager *, QStringList &arguments, QObject *parent = 0);
8
+ virtual void start();
9
+ };
data/src/Version.cpp ADDED
@@ -0,0 +1,13 @@
1
+ #include "Version.h"
2
+ #include "WebPage.h"
3
+
4
+ Version::Version(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
5
+ }
6
+
7
+ void Version::start() {
8
+ QString result =
9
+ QString("Qt: ") + QT_VERSION_STR +
10
+ QString("\nWebKit: ") + qWebKitVersion() +
11
+ QString("\nQtWebKit: ") + QTWEBKIT_VERSION_STR;
12
+ finish(true, result);
13
+ }
data/src/Version.h ADDED
@@ -0,0 +1,10 @@
1
+ #include "SocketCommand.h"
2
+
3
+ class Version : public SocketCommand {
4
+ Q_OBJECT
5
+
6
+ public:
7
+ Version(WebPageManager *, QStringList &arguments, QObject *parent = 0);
8
+ virtual void start();
9
+ };
10
+
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
- emitFinished(true);
12
+ finish(true);
13
13
  }
data/src/WebPage.cpp CHANGED
@@ -4,6 +4,8 @@
4
4
  #include "NetworkAccessManager.h"
5
5
  #include "NetworkCookieJar.h"
6
6
  #include "UnsupportedContentHandler.h"
7
+ #include "InvocationResult.h"
8
+ #include "NetworkReplyProxy.h"
7
9
  #include <QResource>
8
10
  #include <iostream>
9
11
  #include <QWebSettings>
@@ -14,7 +16,6 @@ WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) {
14
16
  m_failed = false;
15
17
  m_manager = manager;
16
18
  m_uuid = QUuid::createUuid().toString();
17
- m_unsupportedContentLoaded = false;
18
19
 
19
20
  setForwardUnsupportedContent(true);
20
21
  loadJavascript();
@@ -41,18 +42,42 @@ void WebPage::resetWindowSize() {
41
42
  this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
42
43
  }
43
44
 
45
+ void WebPage::resetLocalStorage() {
46
+ this->currentFrame()->evaluateJavaScript("localStorage.clear()");
47
+ }
48
+
44
49
  void WebPage::setCustomNetworkAccessManager() {
45
- NetworkAccessManager *manager = new NetworkAccessManager(this);
46
- manager->setCookieJar(m_manager->cookieJar());
47
- this->setNetworkAccessManager(manager);
48
- connect(manager, SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
49
- this, SLOT(handleSslErrorsForReply(QNetworkReply *, QList<QSslError>)));
50
- connect(manager, SIGNAL(requestCreated(QByteArray &, QNetworkReply *)),
50
+ setNetworkAccessManager(m_manager->networkAccessManager());
51
+ connect(networkAccessManager(), SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
52
+ SLOT(handleSslErrorsForReply(QNetworkReply *, QList<QSslError>)));
53
+ connect(networkAccessManager(), SIGNAL(requestCreated(QByteArray &, QNetworkReply *)),
51
54
  SIGNAL(requestCreated(QByteArray &, QNetworkReply *)));
55
+ connect(networkAccessManager(), SIGNAL(finished(QUrl &, QNetworkReply *)),
56
+ SLOT(replyFinished(QUrl &, QNetworkReply *)));
57
+ }
58
+
59
+ void WebPage::replyFinished(QUrl &requestedUrl, QNetworkReply *reply) {
60
+ NetworkReplyProxy *proxy = qobject_cast<NetworkReplyProxy *>(reply);
61
+ setFrameProperties(mainFrame(), requestedUrl, proxy);
62
+ foreach(QWebFrame *frame, mainFrame()->childFrames())
63
+ setFrameProperties(frame, requestedUrl, proxy);
64
+ }
65
+
66
+ void WebPage::setFrameProperties(QWebFrame *frame, QUrl &requestedUrl, NetworkReplyProxy *reply) {
67
+ if (frame->requestedUrl() == requestedUrl) {
68
+ int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
69
+ frame->setProperty("statusCode", statusCode);
70
+ QStringList headers;
71
+ foreach(QNetworkReply::RawHeaderPair header, reply->rawHeaderPairs())
72
+ headers << header.first+": "+header.second;
73
+ frame->setProperty("headers", headers);
74
+ frame->setProperty("body", reply->data());
75
+ QVariant contentMimeType = reply->header(QNetworkRequest::ContentTypeHeader);
76
+ frame->setProperty("contentType", contentMimeType);
77
+ }
52
78
  }
53
79
 
54
80
  void WebPage::unsupportedContentFinishedReply(QNetworkReply *reply) {
55
- m_unsupportedContentLoaded = true;
56
81
  m_manager->replyFinished(reply);
57
82
  }
58
83
 
@@ -117,17 +142,14 @@ bool WebPage::shouldInterruptJavaScript() {
117
142
  return false;
118
143
  }
119
144
 
120
- QVariant WebPage::invokeCapybaraFunction(const char *name, const QStringList &arguments) {
145
+ InvocationResult WebPage::invokeCapybaraFunction(const char *name, const QStringList &arguments) {
121
146
  QString qname(name);
122
- QString objectName("CapybaraInvocation");
123
- JavascriptInvocation invocation(qname, arguments);
124
- currentFrame()->addToJavaScriptWindowObject(objectName, &invocation);
125
- QString javascript = QString("Capybara.invoke()");
126
- return currentFrame()->evaluateJavaScript(javascript);
147
+ JavascriptInvocation invocation(qname, arguments, this);
148
+ return invocation.invoke(currentFrame());
127
149
  }
128
150
 
129
- QVariant WebPage::invokeCapybaraFunction(QString &name, const QStringList &arguments) {
130
- return invokeCapybaraFunction(name.toAscii().data(), arguments);
151
+ InvocationResult WebPage::invokeCapybaraFunction(QString &name, const QStringList &arguments) {
152
+ return invokeCapybaraFunction(name.toLatin1().data(), arguments);
131
153
  }
132
154
 
133
155
  void WebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) {
@@ -171,7 +193,6 @@ bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &message, const Q
171
193
  void WebPage::loadStarted() {
172
194
  m_loading = true;
173
195
  m_errorPageMessage = QString();
174
- m_unsupportedContentLoaded = false;
175
196
  }
176
197
 
177
198
  void WebPage::loadFinished(bool success) {
@@ -247,8 +268,9 @@ QStringList WebPage::getAttachedFileNames() {
247
268
  }
248
269
 
249
270
  void WebPage::handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &errors) {
271
+ Q_UNUSED(errors);
250
272
  if (m_manager->ignoreSslErrors())
251
- reply->ignoreSslErrors(errors);
273
+ reply->ignoreSslErrors();
252
274
  }
253
275
 
254
276
  void WebPage::setSkipImageLoading(bool skip) {
@@ -256,15 +278,19 @@ void WebPage::setSkipImageLoading(bool skip) {
256
278
  }
257
279
 
258
280
  int WebPage::getLastStatus() {
259
- return networkAccessManager()->statusFor(currentFrame()->requestedUrl());
281
+ return currentFrame()->property("statusCode").toInt();
260
282
  }
261
283
 
262
- const QList<QNetworkReply::RawHeaderPair> &WebPage::pageHeaders() {
263
- return networkAccessManager()->headersFor(currentFrame()->requestedUrl());
284
+ QStringList WebPage::pageHeaders() {
285
+ return currentFrame()->property("headers").toStringList();
264
286
  }
265
287
 
266
- NetworkAccessManager *WebPage::networkAccessManager() {
267
- return qobject_cast<NetworkAccessManager *>(QWebPage::networkAccessManager());
288
+ QByteArray WebPage::body() {
289
+ return currentFrame()->property("body").toByteArray();
290
+ }
291
+
292
+ QString WebPage::contentType() {
293
+ return currentFrame()->property("contentType").toString();
268
294
  }
269
295
 
270
296
  void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
@@ -279,10 +305,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
279
305
  }
280
306
  }
281
307
 
282
- bool WebPage::unsupportedContentLoaded() {
283
- return m_unsupportedContentLoaded;
284
- }
285
-
286
308
  bool WebPage::supportsExtension(Extension extension) const {
287
309
  if (extension == ErrorPageExtension)
288
310
  return true;
data/src/WebPage.h CHANGED
@@ -1,18 +1,23 @@
1
1
  #ifndef _WEBPAGE_H
2
2
  #define _WEBPAGE_H
3
+ #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
4
+ #include <QtWebKitWidgets>
5
+ #else
3
6
  #include <QtWebKit>
7
+ #endif
4
8
  #include <QtNetwork>
5
9
 
6
10
  class WebPageManager;
7
- class NetworkAccessManager;
11
+ class InvocationResult;
12
+ class NetworkReplyProxy;
8
13
 
9
14
  class WebPage : public QWebPage {
10
15
  Q_OBJECT
11
16
 
12
17
  public:
13
18
  WebPage(WebPageManager *, QObject *parent = 0);
14
- QVariant invokeCapybaraFunction(const char *name, const QStringList &arguments);
15
- QVariant invokeCapybaraFunction(QString &name, const QStringList &arguments);
19
+ InvocationResult invokeCapybaraFunction(const char *name, const QStringList &arguments);
20
+ InvocationResult invokeCapybaraFunction(QString &name, const QStringList &arguments);
16
21
  QString failureString();
17
22
  QString userAgentForUrl(const QUrl &url ) const;
18
23
  void setUserAgent(QString userAgent);
@@ -29,14 +34,16 @@ class WebPage : public QWebPage {
29
34
  QVariantList confirmMessages();
30
35
  QVariantList promptMessages();
31
36
  void resetWindowSize();
37
+ void resetLocalStorage();
32
38
  QWebPage *createWindow(WebWindowType type);
33
39
  QString uuid();
34
40
  QString getWindowName();
35
41
  bool matchesWindowSelector(QString);
36
42
  void setFocus();
37
- NetworkAccessManager *networkAccessManager();
38
- bool unsupportedContentLoaded();
39
43
  void unsupportedContentFinishedReply(QNetworkReply *reply);
44
+ QStringList pageHeaders();
45
+ QByteArray body();
46
+ QString contentType();
40
47
 
41
48
  public slots:
42
49
  bool shouldInterruptJavaScript();
@@ -44,10 +51,10 @@ class WebPage : public QWebPage {
44
51
  void loadStarted();
45
52
  void loadFinished(bool);
46
53
  bool isLoading() const;
47
- const QList<QNetworkReply::RawHeaderPair> &pageHeaders();
48
54
  void frameCreated(QWebFrame *);
49
55
  void handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &);
50
56
  void handleUnsupportedContent(QNetworkReply *reply);
57
+ void replyFinished(QUrl &, QNetworkReply *);
51
58
 
52
59
  signals:
53
60
  void pageFinished(bool);
@@ -80,7 +87,7 @@ class WebPage : public QWebPage {
80
87
  QString m_uuid;
81
88
  WebPageManager *m_manager;
82
89
  QString m_errorPageMessage;
83
- bool m_unsupportedContentLoaded;
90
+ void setFrameProperties(QWebFrame *, QUrl &, NetworkReplyProxy *);
84
91
  };
85
92
 
86
93
  #endif //_WEBPAGE_H
@@ -1,17 +1,24 @@
1
1
  #include "WebPageManager.h"
2
2
  #include "WebPage.h"
3
3
  #include "NetworkCookieJar.h"
4
+ #include "NetworkAccessManager.h"
4
5
 
5
6
  WebPageManager::WebPageManager(QObject *parent) : QObject(parent) {
6
7
  m_ignoreSslErrors = false;
7
8
  m_cookieJar = new NetworkCookieJar(this);
8
9
  m_success = true;
9
10
  m_loggingEnabled = false;
10
- m_ignoredOutput = new QString();
11
+ m_ignoredOutput = new QFile(this);
11
12
  m_timeout = -1;
13
+ m_networkAccessManager = new NetworkAccessManager(this);
14
+ m_networkAccessManager->setCookieJar(m_cookieJar);
12
15
  createPage(this)->setFocus();
13
16
  }
14
17
 
18
+ NetworkAccessManager *WebPageManager::networkAccessManager() {
19
+ return m_networkAccessManager;
20
+ }
21
+
15
22
  void WebPageManager::append(WebPage *value) {
16
23
  m_pages.append(value);
17
24
  }
@@ -102,6 +109,8 @@ void WebPageManager::setTimeout(int timeout) {
102
109
  void WebPageManager::reset() {
103
110
  m_timeout = -1;
104
111
  m_cookieJar->clearCookies();
112
+ m_networkAccessManager->reset();
113
+ m_pages.first()->resetLocalStorage();
105
114
  m_pages.first()->deleteLater();
106
115
  m_pages.clear();
107
116
  createPage(this)->setFocus();
data/src/WebPageManager.h CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  class WebPage;
11
11
  class NetworkCookieJar;
12
+ class NetworkAccessManager;
12
13
 
13
14
  class WebPageManager : public QObject {
14
15
  Q_OBJECT
@@ -30,6 +31,7 @@ class WebPageManager : public QObject {
30
31
  QDebug logger() const;
31
32
  void enableLogging();
32
33
  void replyFinished(QNetworkReply *reply);
34
+ NetworkAccessManager *networkAccessManager();
33
35
 
34
36
  public slots:
35
37
  void emitLoadStarted();
@@ -52,8 +54,9 @@ class WebPageManager : public QObject {
52
54
  QSet<WebPage *> m_started;
53
55
  bool m_success;
54
56
  bool m_loggingEnabled;
55
- QString *m_ignoredOutput;
57
+ QFile *m_ignoredOutput;
56
58
  int m_timeout;
59
+ NetworkAccessManager *m_networkAccessManager;
57
60
  };
58
61
 
59
62
  #endif // _WEBPAGEMANAGER_H