Skip to content

Commit

Permalink
Clear localStorage on reset!
Browse files Browse the repository at this point in the history
  • Loading branch information
levicole authored and youpy committed Jul 22, 2014
1 parent 4b5843f commit 047be27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/driver_spec.rb
Expand Up @@ -1729,6 +1729,14 @@ def set_automatic_reload(value)
visit "/"
driver.find_xpath("//span[contains(.,'localStorage is enabled')]").should_not be_empty
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

context "form app with server-side handler" do
Expand Down
4 changes: 4 additions & 0 deletions src/WebPage.cpp
Expand Up @@ -42,6 +42,10 @@ void WebPage::resetWindowSize() {
this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
}

void WebPage::resetLocalStorage() {
this->currentFrame()->evaluateJavaScript("localStorage.clear()");
}

void WebPage::setCustomNetworkAccessManager() {
setNetworkAccessManager(m_manager->networkAccessManager());
connect(networkAccessManager(), SIGNAL(sslErrors(QNetworkReply *, QList<QSslError>)),
Expand Down
1 change: 1 addition & 0 deletions src/WebPage.h
Expand Up @@ -34,6 +34,7 @@ class WebPage : public QWebPage {
QVariantList confirmMessages();
QVariantList promptMessages();
void resetWindowSize();
void resetLocalStorage();
QWebPage *createWindow(WebWindowType type);
QString uuid();
QString getWindowName();
Expand Down
1 change: 1 addition & 0 deletions src/WebPageManager.cpp
Expand Up @@ -110,6 +110,7 @@ void WebPageManager::reset() {
m_timeout = -1;
m_cookieJar->clearCookies();
m_networkAccessManager->reset();
m_pages.first()->resetLocalStorage();
m_pages.first()->deleteLater();
m_pages.clear();
createPage(this)->setFocus();
Expand Down

0 comments on commit 047be27

Please sign in to comment.