Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Don't start queued commands more than once
Browse files Browse the repository at this point in the history
TimeoutCommand may receive pageFinished multiple times before
PageLoadingCommand has finished.
  • Loading branch information
mhoran committed Dec 19, 2012
1 parent 96e79e4 commit bca84f9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
46 changes: 46 additions & 0 deletions spec/integration/session_spec.rb
Expand Up @@ -182,4 +182,50 @@ module TestSessions
end end
end 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 end
3 changes: 1 addition & 2 deletions src/TimeoutCommand.cpp
Expand Up @@ -39,12 +39,12 @@ void TimeoutCommand::startTimeout() {
} }


void TimeoutCommand::pendingLoadFinished(bool success) { void TimeoutCommand::pendingLoadFinished(bool success) {
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
if (success) { if (success) {
startCommand(); startCommand();
} else { } else {
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout())); disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand())); disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
emitFinished(false, m_manager->currentPage()->failureString()); emitFinished(false, m_manager->currentPage()->failureString());
} }
} }
Expand All @@ -64,7 +64,6 @@ void TimeoutCommand::commandTimeout() {
void TimeoutCommand::commandFinished(Response *response) { void TimeoutCommand::commandFinished(Response *response) {
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout())); disconnect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand())); disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
disconnect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
emit finished(response); emit finished(response);
} }


1 comment on commit bca84f9

@seangeo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.