diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 11f4739..8d105cd 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -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 + +
+

hello

+ + 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| diff --git a/src/Connection.cpp b/src/Connection.cpp index 3733be6..a770069 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -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; }