Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't start queued commands more than once

TimeoutCommand may receive pageFinished multiple times before
PageLoadingCommand has finished.
  • Loading branch information...
commit bca84f9a577963d99c99e735690905c5afb744b3 1 parent 96e79e4
@mhoran mhoran authored
Showing with 47 additions and 2 deletions.
  1. +46 −0 spec/integration/session_spec.rb
  2. +1 −2  src/TimeoutCommand.cpp
View
46 spec/integration/session_spec.rb
@@ -182,4 +182,50 @@ module TestSessions
end
end
end
+
+ context "session app" do
+ before do
+ @app = Class.new(ExampleApp) do
+ enable :sessions
+ get '/' do
+ <<-HTML
+ <html>
+ <body>
+ <form method="post" action="/sign_in">
+ <input type="text" name="username">
+ <input type="password" name="password">
+ <input type="submit" value="Submit">
+ </form>
+ </body>
+ </html>
+ HTML
+ end
+
+ post '/sign_in' do
+ session[:username] = params[:username]
+ session[:password] = params[:password]
+ redirect '/'
+ end
+
+ get '/other' do
+ <<-HTML
+ <html>
+ <body>
+ <p>Welcome, #{session[:username]}.</p>
+ </body>
+ </html>
+ HTML
+ end
+ end
+ end
+
+ it "should not start queued commands more than once" do
+ subject.visit('/')
+ subject.fill_in('username', with: 'admin')
+ subject.fill_in('password', with: 'temp4now')
+ subject.click_button('Submit')
+ subject.visit('/other')
+ subject.should have_content('admin')
+ end
+ end
end
View
3  src/TimeoutCommand.cpp
@@ -39,12 +39,12 @@ void TimeoutCommand::startTimeout() {
}
void TimeoutCommand::pendingLoadFinished(bool success) {
+ disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
if (success) {
startCommand();
} else {
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
emitFinished(false, m_manager->currentPage()->failureString());
}
}
@@ -64,7 +64,6 @@ void TimeoutCommand::commandTimeout() {
void TimeoutCommand::commandFinished(Response *response) {
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
emit finished(response);
}

1 comment on commit bca84f9

@seangeo

Excellent work! I've been seeing similar strange things with commands being started multiple times but wasn't able to track down the error, thought it was due to some left over state in our long running webkit_server processes. Great job!

Please sign in to comment.
Something went wrong with that request. Please try again.