diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 6c3a6fa..b131d0f 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -408,6 +408,11 @@ describe Capybara::Webkit::Driver do result.should == nil end + it "evaluates Infinity and returns null" do + result = driver.evaluate_script(%) + result.should == nil + end + it "evaluates Javascript and returns an object" do result = driver.evaluate_script(%<({ 'one' : 1 })>) result.should == { 'one' => 1 } diff --git a/src/JsonSerializer.cpp b/src/JsonSerializer.cpp index eaa76ec..8809ba1 100644 --- a/src/JsonSerializer.cpp +++ b/src/JsonSerializer.cpp @@ -1,4 +1,5 @@ #include "JsonSerializer.h" +#include JsonSerializer::JsonSerializer(QObject *parent) : QObject(parent) { } @@ -24,7 +25,10 @@ void JsonSerializer::addVariant(const QVariant &object) { } break; case QMetaType::Double: - m_buffer.append(object.toString()); + if (std::isinf(object.toDouble())) + m_buffer.append("null"); + else + m_buffer.append(object.toString()); break; case QMetaType::QVariantMap: {