page succeeds only when all loadFinished signals succeed #328

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+46 −1
Split
View
@@ -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

halogenandtoast May 4, 2012

Contributor

Is this else needed?

@samwgoldman

samwgoldman May 4, 2012

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

+ 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
@@ -40,7 +40,7 @@ void Connection::startCommand() {
}
void Connection::pendingLoadFinished(bool success) {
- m_pageSuccess = success;
+ m_pageSuccess = m_pageSuccess && success;
if (m_commandWaiting)
startCommand();
}