mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Clear localStorage on reset!
This commit is contained in:
parent
0abc7e139f
commit
7bf3c80031
4 changed files with 14 additions and 0 deletions
|
@ -1729,6 +1729,14 @@ describe Capybara::Webkit::Driver do
|
||||||
visit "/"
|
visit "/"
|
||||||
driver.find_xpath("//span[contains(.,'localStorage is enabled')]").should_not be_empty
|
driver.find_xpath("//span[contains(.,'localStorage is enabled')]").should_not be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "clears the message after a driver reset!" do
|
||||||
|
visit "/"
|
||||||
|
driver.find_xpath("//span[contains(.,'localStorage is enabled')]").should_not be_empty
|
||||||
|
driver.reset!
|
||||||
|
visit "/"
|
||||||
|
driver.find_xpath("//span[contains(.,'localStorage is enabled')]").should be_empty
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "form app with server-side handler" do
|
context "form app with server-side handler" do
|
||||||
|
|
|
@ -42,6 +42,10 @@ void WebPage::resetWindowSize() {
|
||||||
this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
|
this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPage::resetLocalStorage() {
|
||||||
|
this->currentFrame()->evaluateJavaScript("localStorage.clear()");
|
||||||
|
}
|
||||||
|
|
||||||
void WebPage::setCustomNetworkAccessManager() {
|
void WebPage::setCustomNetworkAccessManager() {
|
||||||
setNetworkAccessManager(m_manager->networkAccessManager());
|
setNetworkAccessManager(m_manager->networkAccessManager());
|
||||||
connect(networkAccessManager(), SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
|
connect(networkAccessManager(), SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
|
||||||
|
|
|
@ -34,6 +34,7 @@ class WebPage : public QWebPage {
|
||||||
QVariantList confirmMessages();
|
QVariantList confirmMessages();
|
||||||
QVariantList promptMessages();
|
QVariantList promptMessages();
|
||||||
void resetWindowSize();
|
void resetWindowSize();
|
||||||
|
void resetLocalStorage();
|
||||||
QWebPage *createWindow(WebWindowType type);
|
QWebPage *createWindow(WebWindowType type);
|
||||||
QString uuid();
|
QString uuid();
|
||||||
QString getWindowName();
|
QString getWindowName();
|
||||||
|
|
|
@ -110,6 +110,7 @@ void WebPageManager::reset() {
|
||||||
m_timeout = -1;
|
m_timeout = -1;
|
||||||
m_cookieJar->clearCookies();
|
m_cookieJar->clearCookies();
|
||||||
m_networkAccessManager->reset();
|
m_networkAccessManager->reset();
|
||||||
|
m_pages.first()->resetLocalStorage();
|
||||||
m_pages.first()->deleteLater();
|
m_pages.first()->deleteLater();
|
||||||
m_pages.clear();
|
m_pages.clear();
|
||||||
createPage(this)->setFocus();
|
createPage(this)->setFocus();
|
||||||
|
|
Loading…
Reference in a new issue