mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Fixed attempting to delete NULL commands after pages fail to load; fixed command request/response params overlapping after failures
This commit is contained in:
parent
81a039f3bc
commit
85ac9c17d5
2 changed files with 36 additions and 2 deletions
|
@ -546,6 +546,38 @@ describe Capybara::Driver::Webkit do
|
|||
end
|
||||
end
|
||||
|
||||
context "slow error app" do
|
||||
before(:all) do
|
||||
@app = lambda do |env|
|
||||
if env['PATH_INFO'] == "/error"
|
||||
puts "time for an error"
|
||||
body = "error"
|
||||
sleep(1)
|
||||
puts "done with error"
|
||||
[304, {}, []]
|
||||
else
|
||||
puts "time for great success"
|
||||
body = <<-HTML
|
||||
<html><body>
|
||||
<form action="/error"><input type="submit"/></form>
|
||||
<p>hello</p>
|
||||
</body></html>
|
||||
HTML
|
||||
[200,
|
||||
{ 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
|
||||
[body]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "raises a webkit error and then continues" do
|
||||
subject.find("//input").first.click
|
||||
expect { subject.find("//p") }.to raise_error(Capybara::Driver::Webkit::WebkitError)
|
||||
subject.visit("/")
|
||||
subject.find("//p").first.text.should == "hello"
|
||||
end
|
||||
end
|
||||
|
||||
context "popup app" do
|
||||
before(:all) do
|
||||
@app = lambda do |env|
|
||||
|
|
|
@ -107,14 +107,13 @@ void Connection::pendingLoadFinished(bool success) {
|
|||
startCommand();
|
||||
} else {
|
||||
QString response = m_page->failureString();
|
||||
finishCommand(false, response);
|
||||
writeResponse(false, response);
|
||||
}
|
||||
}
|
||||
|
||||
void Connection::finishCommand(bool success, QString &response) {
|
||||
m_command->deleteLater();
|
||||
m_command = NULL;
|
||||
m_arguments.clear();
|
||||
writeResponse(success, response);
|
||||
}
|
||||
|
||||
|
@ -128,5 +127,8 @@ void Connection::writeResponse(bool success, QString &response) {
|
|||
QString responseLength = QString::number(response_utf8.size()) + "\n";
|
||||
m_socket->write(responseLength.toAscii());
|
||||
m_socket->write(response_utf8);
|
||||
m_arguments.clear();
|
||||
m_commandName = QString();
|
||||
m_argumentsExpected = -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue