Don't cast raw frame content to QString

The conversion is lossy and drops non-ASCII characters.

Fixes #503.
This commit is contained in:
Matthew Horan 2013-04-01 23:08:11 -04:00
parent f8731b692a
commit e72b48fc26
2 changed files with 20 additions and 5 deletions

View File

@ -301,6 +301,24 @@ describe Capybara::Webkit::Driver do
end
end
context "binary content app" do
let(:driver) do
driver_for_app do
get '/' do
headers 'Content-Type' => 'application/octet-stream'
"Hello\xFF\xFF\xFF\xFFWorld"
end
end
end
before { visit("/") }
it "should return the binary content" do
src = driver.html.force_encoding('binary')
src.should == "Hello\xFF\xFF\xFF\xFFWorld".force_encoding('binary')
end
end
context "hello app" do
let(:driver) do
driver_for_html(<<-HTML)

View File

@ -6,11 +6,8 @@ Body::Body(WebPageManager *manager, QStringList &arguments, QObject *parent) : S
}
void Body::start() {
QString result;
if (page()->contentType().contains("html"))
result = page()->currentFrame()->toHtml();
finish(true, page()->currentFrame()->toHtml());
else
result = page()->body();
finish(true, result);
finish(true, page()->body());
}