Fixed subsequent failures when a page fails quickly before the next command begins
This commit is contained in:
parent
cc74875e4b
commit
728feeeff7
|
@ -550,7 +550,6 @@ describe Capybara::Driver::Webkit do
|
|||
before(:all) do
|
||||
@app = lambda do |env|
|
||||
if env['PATH_INFO'] == "/error"
|
||||
body = "error"
|
||||
[404, {}, []]
|
||||
else
|
||||
body = <<-HTML
|
||||
|
@ -568,10 +567,15 @@ describe Capybara::Driver::Webkit do
|
|||
it "raises a webkit error for the requested url" do
|
||||
expect {
|
||||
subject.find("//input").first.click
|
||||
subject.find("//p")
|
||||
wait_for_error_to_complete
|
||||
subject.find("//body")
|
||||
}.
|
||||
to raise_error(Capybara::Driver::Webkit::WebkitError, %r{/error})
|
||||
end
|
||||
|
||||
def wait_for_error_to_complete
|
||||
sleep(0.5)
|
||||
end
|
||||
end
|
||||
|
||||
context "slow error app" do
|
||||
|
|
|
@ -20,7 +20,10 @@ Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
|
|||
m_page = page;
|
||||
m_command = NULL;
|
||||
m_expectingDataSize = -1;
|
||||
m_pageSuccess = true;
|
||||
m_commandWaiting = false;
|
||||
connect(m_socket, SIGNAL(readyRead()), this, SLOT(checkNext()));
|
||||
connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
||||
}
|
||||
|
||||
void Connection::checkNext() {
|
||||
|
@ -75,13 +78,15 @@ void Connection::processArgument(const char *data) {
|
|||
|
||||
if (m_arguments.length() == m_argumentsExpected) {
|
||||
if (m_page->isLoading())
|
||||
connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
||||
m_commandWaiting = true;
|
||||
else
|
||||
startCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Connection::startCommand() {
|
||||
m_commandWaiting = false;
|
||||
if (m_pageSuccess) {
|
||||
m_command = createCommand(m_commandName.toAscii().constData());
|
||||
if (m_command) {
|
||||
connect(m_command,
|
||||
|
@ -94,6 +99,11 @@ void Connection::startCommand() {
|
|||
writeResponse(new Response(false, failure));
|
||||
}
|
||||
m_commandName = QString();
|
||||
} else {
|
||||
m_pageSuccess = true;
|
||||
QString message = m_page->failureString();
|
||||
writeResponse(new Response(false, message));
|
||||
}
|
||||
}
|
||||
|
||||
Command *Connection::createCommand(const char *name) {
|
||||
|
@ -102,13 +112,9 @@ Command *Connection::createCommand(const char *name) {
|
|||
}
|
||||
|
||||
void Connection::pendingLoadFinished(bool success) {
|
||||
m_page->disconnect(this, SLOT(pendingLoadFinished(bool)));
|
||||
if (success) {
|
||||
m_pageSuccess = success;
|
||||
if (m_commandWaiting)
|
||||
startCommand();
|
||||
} else {
|
||||
QString message = m_page->failureString();
|
||||
writeResponse(new Response(false, message));
|
||||
}
|
||||
}
|
||||
|
||||
void Connection::finishCommand(Response *response) {
|
||||
|
|
|
@ -33,5 +33,7 @@ class Connection : public QObject {
|
|||
int m_argumentsExpected;
|
||||
WebPage *m_page;
|
||||
int m_expectingDataSize;
|
||||
bool m_pageSuccess;
|
||||
bool m_commandWaiting;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue