From 85ac9c17d592ec3eb8ad41afab3264228daae606 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Thu, 5 May 2011 09:19:46 -0400 Subject: [PATCH] Fixed attempting to delete NULL commands after pages fail to load; fixed command request/response params overlapping after failures --- spec/driver_spec.rb | 32 ++++++++++++++++++++++++++++++++ src/Connection.cpp | 6 ++++-- 2 files changed, 36 insertions(+), 2 deletions(-) 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; }