Skip to content

Commit

Permalink
reset history when resetting session
Browse files Browse the repository at this point in the history
  • Loading branch information
marcisme authored and halogenandtoast committed Feb 17, 2012
1 parent 5eacd08 commit eaec979
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/Reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

3 changes: 3 additions & 0 deletions src/Reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ class Reset : public Command {
public:
Reset(WebPage *page, QObject *parent = 0);
virtual void start(QStringList &arguments);

private:
void resetHistory();
};

0 comments on commit eaec979

Please sign in to comment.