|
2 | 2 |
|
3 | 3 | #include <include/cef_version.h> |
4 | 4 |
|
| 5 | +#include <cmath> |
| 6 | + |
5 | 7 | #include <Common/CefViewCoreLog.h> |
6 | 8 |
|
7 | 9 | #include <CefViewCoreProtocol.h> |
8 | 10 |
|
9 | | - |
10 | 11 | #if CEF_VERSION_MAJOR >= 119 |
11 | 12 | class CefViewArrayBuffer : public CefV8ArrayBufferReleaseCallback |
12 | 13 | { |
@@ -236,7 +237,8 @@ CefViewBridgeObject::CefViewBridgeObject(CefRefPtr<CefBrowser> browser, |
236 | 237 | static_cast<CefV8Value::PropertyAttribute>(V8_PROPERTY_ATTRIBUTE_READONLY | |
237 | 238 | V8_PROPERTY_ATTRIBUTE_DONTENUM | |
238 | 239 | V8_PROPERTY_ATTRIBUTE_DONTDELETE)); |
239 | | - frame_->ExecuteJavaScript("console.info('[JSRuntime]:window." + name_.ToString() + " [object] created');", frame_->GetURL(), 0); |
| 240 | + frame_->ExecuteJavaScript( |
| 241 | + "console.info('[JSRuntime]:window." + name_.ToString() + " [object] created');", frame_->GetURL(), 0); |
240 | 242 |
|
241 | 243 | // create "__cefview_report_js_result__" function and mount it on the global context(window) |
242 | 244 | reportJSResultFunction_ = CefV8Value::CreateFunction(kCefViewReportJSResultFunctionName, v8Handler_); |
@@ -362,9 +364,15 @@ CefViewBridgeObject::V8ValueToCefValue(CefV8Value* v8Value) |
362 | 364 | cefValue->SetBool(v8Value->GetBoolValue()); |
363 | 365 | else if (v8Value->IsInt()) |
364 | 366 | cefValue->SetInt(v8Value->GetIntValue()); |
365 | | - else if (v8Value->IsDouble()) |
366 | | - cefValue->SetDouble(v8Value->GetDoubleValue()); |
367 | | - else if (v8Value->IsString()) |
| 367 | + else if (v8Value->IsDouble()) { |
| 368 | + auto v = v8Value->GetDoubleValue(); |
| 369 | + if (std::isfinite(v)) { |
| 370 | + cefValue->SetDouble(v); |
| 371 | + } else { |
| 372 | + // convert non-representable value(NaN/+inf/-inf) to string |
| 373 | + cefValue->SetString(std::to_string(v)); |
| 374 | + } |
| 375 | + } else if (v8Value->IsString()) |
368 | 376 | cefValue->SetString(v8Value->GetStringValue()); |
369 | 377 | else if (v8Value->IsArrayBuffer()) { |
370 | 378 | #if CEF_VERSION_MAJOR >= 119 |
|
0 commit comments