Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

page succeeds only when all loadFinished signals succeed #328

Closed
wants to merge 2 commits into from

3 participants

@joshuanapoli

Every time a page loads an iframe through a callback (such as setTimeout), QWebPage will emit a loadFinished signal. I think that m_pageSuccess should indicate whether all loadFinished signals were successful, rather than simply indicating the final signal (previous behavior was to overwrite m_pageSuccess on each signal). This allows us to reliably detect iframe failures in capybara/cucumber tests and avoids intermittent failures.

spec/driver_spec.rb
@@ -1515,4 +1515,50 @@ def which_for(character)
subject.source.should == "Hello\0World"
end
end
+
+ context "timers app" do
+ before(:all) do
+ @app = lambda do |env|
+ case env["PATH_INFO"]
+ when "/success"
+ [200, {'Content-Type' => 'text/html'}, ['<html><body></body></html>']]
+ when "/not-found"
+ puts 'not-found'
@halogenandtoast Owner

Left a puts in here

thanks! I removed the puts in commit 9cbf7d2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@halogenandtoast halogenandtoast commented on the diff
spec/driver_spec.rb
((20 lines not shown))
+ function goodFrame(){var divTag = document.createElement("div");divTag.innerHTML = "<iframe src='/success'></iframe>";document.body.appendChild(divTag);};
+
+ // emits WebPage::loadFinished(false) when called from timer
+ function badFrame(){var divTag = document.createElement("div");divTag.innerHTML = "<iframe src='/not-found'></iframe>";document.body.appendChild(divTag);};
+
+ function badThenGood() { badFrame(); setTimeout('goodFrame()',100); };
+ </script>
+ </head>
+ <body onload="setTimeout('badThenGood()',100)">
+ </body>
+ </html>
+ HTML
+ [200,
+ { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
+ [body]]
+ else
@halogenandtoast Owner

Is this else needed?

Yeah, it would be nice if that before filter didn't get executed for every context in this spec file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@halogenandtoast

Just a couple of small comments.

@joshuanapoli

Thanks for taking a look at my pull request!

@joshuanapoli

I'm closing this pull request, because it was incorporated by #311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 26, 2012
  1. page succeeds only when all loadFinished events succeed

    Joshua Napoli authored
Commits on May 4, 2012
  1. remove debug output

    Joshua Napoli authored
This page is out of date. Refresh to see the latest.
Showing with 46 additions and 1 deletion.
  1. +45 −0 spec/driver_spec.rb
  2. +1 −1  src/Connection.cpp
View
45 spec/driver_spec.rb
@@ -1515,4 +1515,49 @@ def which_for(character)
subject.source.should == "Hello\0World"
end
end
+
+ context "timers app" do
+ before(:all) do
+ @app = lambda do |env|
+ case env["PATH_INFO"]
+ when "/success"
+ [200, {'Content-Type' => 'text/html'}, ['<html><body></body></html>']]
+ when "/not-found"
+ [404, {}, []]
+ when "/outer"
+ body = <<-HTML
+ <html>
+ <head>
+ <script>
+ // emits WebPage::loadFinished(true) when called from timer
+ function goodFrame(){var divTag = document.createElement("div");divTag.innerHTML = "<iframe src='/success'></iframe>";document.body.appendChild(divTag);};
+
+ // emits WebPage::loadFinished(false) when called from timer
+ function badFrame(){var divTag = document.createElement("div");divTag.innerHTML = "<iframe src='/not-found'></iframe>";document.body.appendChild(divTag);};
+
+ function badThenGood() { badFrame(); setTimeout('goodFrame()',100); };
+ </script>
+ </head>
+ <body onload="setTimeout('badThenGood()',100)">
+ </body>
+ </html>
+ HTML
+ [200,
+ { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
+ [body]]
+ else
@halogenandtoast Owner

Is this else needed?

Yeah, it would be nice if that before filter didn't get executed for every context in this spec file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ body = "<html><body></body></html>"
+ return [200, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
+ end
+ end
+ end
+
+ it "raises error for any loadFinished failure" do
+ expect do
+ subject.visit("/outer")
+ sleep 1
+ subject.find("//body")
+ end.to raise_error(Capybara::Driver::Webkit::WebkitInvalidResponseError)
+ end
+ end
end
View
2  src/Connection.cpp
@@ -40,7 +40,7 @@ void Connection::startCommand() {
}
void Connection::pendingLoadFinished(bool success) {
- m_pageSuccess = success;
+ m_pageSuccess = m_pageSuccess && success;
if (m_commandWaiting)
startCommand();
}
Something went wrong with that request. Please try again.