1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

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
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 context "hello app" do
let(:driver) do let(:driver) do
driver_for_html(<<-HTML) driver_for_html(<<-HTML)

View file

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