mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Use old method to find current URL in Qt < 4.8.0
This commit is contained in:
parent
ecfa7836d9
commit
f95e4ebe0b
3 changed files with 23 additions and 0 deletions
|
@ -6,8 +6,24 @@ CurrentUrl::CurrentUrl(WebPageManager *manager, QStringList &arguments, QObject
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentUrl::start() {
|
void CurrentUrl::start() {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QVariant result = page()->invokeCapybaraFunction("currentUrl", arguments);
|
QVariant result = page()->invokeCapybaraFunction("currentUrl", arguments);
|
||||||
QString url = result.toString();
|
QString url = result.toString();
|
||||||
emit finished(new Response(true, url));
|
emit finished(new Response(true, url));
|
||||||
|
#else
|
||||||
|
QUrl humanUrl = wasRedirectedAndNotModifiedByJavascript() ?
|
||||||
|
page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
|
||||||
|
QByteArray encodedBytes = humanUrl.toEncoded();
|
||||||
|
emit finished(new Response(true, encodedBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CurrentUrl::wasRegularLoad() {
|
||||||
|
return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CurrentUrl::wasRedirectedAndNotModifiedByJavascript() {
|
||||||
|
return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,11 @@ class CurrentUrl : public SocketCommand {
|
||||||
public:
|
public:
|
||||||
CurrentUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
CurrentUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0)
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool wasRegularLoad();
|
||||||
|
bool wasRedirectedAndNotModifiedByJavascript();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ void WebPageManager::reset() {
|
||||||
m_pages.first()->deleteLater();
|
m_pages.first()->deleteLater();
|
||||||
m_pages.clear();
|
m_pages.clear();
|
||||||
createPage(this)->setFocus();
|
createPage(this)->setFocus();
|
||||||
|
currentPage()->currentFrame()->setUrl(QUrl("about:blank"));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkCookieJar *WebPageManager::cookieJar() {
|
NetworkCookieJar *WebPageManager::cookieJar() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue