Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reset history when resetting session

  • Loading branch information...
commit eaec9792b370ca0a133acdbb16ed7bb65dad7898 1 parent 5eacd08
@marcisme marcisme authored halogenandtoast committed
Showing with 15 additions and 0 deletions.
  1. +5 −0 spec/driver_spec.rb
  2. +7 −0 src/Reset.cpp
  3. +3 −0  src/Reset.h
View
5 spec/driver_spec.rb
@@ -211,6 +211,11 @@
subject.find("//*[contains(., 'hello')]").should be_empty
end
+ it "has a location of 'about:blank' after reseting" do
+ subject.reset!
+ subject.current_url.should == "about:blank"
+ end
+
it "raises an error for an invalid xpath query" do
expect { subject.find("totally invalid salad") }.
to raise_error(Capybara::Driver::Webkit::WebkitInvalidResponseError, /xpath/i)
View
7 src/Reset.cpp
@@ -16,6 +16,13 @@ void Reset::start(QStringList &arguments) {
page()->setUserAgent(NULL);
page()->resetResponseHeaders();
page()->resetConsoleMessages();
+ resetHistory();
emit finished(new Response(true));
}
+void Reset::resetHistory() {
+ // Clearing the history preserves the current history item, so set it to blank first.
+ page()->currentFrame()->setUrl(QUrl("about:blank"));
+ page()->history()->clear();
+}
+
View
3  src/Reset.h
@@ -8,5 +8,8 @@ class Reset : public Command {
public:
Reset(WebPage *page, QObject *parent = 0);
virtual void start(QStringList &arguments);
+
+ private:
+ void resetHistory();
};
Please sign in to comment.
Something went wrong with that request. Please try again.