diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 115a944..1dd1f5d 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -104,6 +104,35 @@ describe Capybara::Driver::Webkit do end end + context "error iframe app" do + before(:all) do + @app = lambda do |env| + case env["PATH_INFO"] + when "/inner-not-found" + [404, {}, []] + when "/outer" + body = <<-HTML + +
+ + + + HTML + [200, + { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, + [body]] + else + body = "" + return [200, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]] + end + end + end + + it "raises error whose message references the actual missing url" do + expect { subject.visit("/outer") }.to raise_error(Capybara::Driver::Webkit::WebkitInvalidResponseError, /inner-not-found/) + end + end + context "redirect app" do before(:all) do @app = lambda do |env| diff --git a/src/WebPage.cpp b/src/WebPage.cpp index c0f3469..b269fb5 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -141,6 +141,7 @@ bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &message, const Q void WebPage::loadStarted() { m_loading = true; + m_errorPageMessage = QString(); } void WebPage::loadFinished(bool success) { @@ -153,7 +154,11 @@ bool WebPage::isLoading() const { } QString WebPage::failureString() { - return QString("Unable to load URL: ") + currentFrame()->requestedUrl().toString(); + QString message = QString("Unable to load URL: ") + currentFrame()->requestedUrl().toString(); + if(m_errorPageMessage.isEmpty()) + return message; + else + return message + ": " + m_errorPageMessage; } bool WebPage::render(const QString &fileName) { @@ -191,12 +196,16 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile } bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { - Q_UNUSED(option); if (extension == ChooseMultipleFilesExtension) { QStringList names = QStringList() << getLastAttachedFileName(); static_cast