fixup! [M108 Migration] Remove EWK_BRINGUP from EWebView::ExecuteJavaScript 85/287085/3
authorBakka Uday Kiran <b.kiran@samsung.com>
Thu, 19 Jan 2023 10:49:23 +0000 (16:19 +0530)
committerBot Blink <blinkbot@samsung.com>
Fri, 20 Jan 2023 05:39:51 +0000 (05:39 +0000)
This patch fixes the error[1] that occurs during starting
of efl_webview_app on both desktop and tv

[1] RAW: Bad variant access, Aborted (core dumped)

Reference: https://review.tizen.org/gerrit/c/273935

Change-Id: I1617011377bedf37ab9142b0efa3012fd89e147a
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
tizen_src/ewk/efl_integration/eweb_view.cc

index 11e805b..821c731 100644 (file)
@@ -4,8 +4,13 @@
 
 #include "eweb_view.h"
 
+#include <Ecore_Evas.h>
+#include <Eina.h>
+#include <Elementary.h>
+
 #include "base/command_line.h"
 #include "base/files/file_path.h"
+#include "base/json/json_string_value_serializer.h"
 #include "base/logging.h"
 #include "base/pickle.h"
 #include "base/strings/utf_string_conversions.h"
 #include "web_contents_delegate_efl.h"
 #include "web_contents_efl_delegate_ewk.h"
 
-#include <Ecore_Evas.h>
-#include <Elementary.h>
-#include <Eina.h>
-
 #include <iostream>
 
 using namespace content;
@@ -705,7 +706,19 @@ void JavaScriptComplete(JavaScriptCallbackDetails* script_callback_data,
   if (!script_callback_data->callback_func_)
     return;
 
-  std::string return_string = result.GetString();
+  std::string return_string;
+  if (result.is_string()) {
+    // We don't want to serialize strings with JSONStringValueSerializer
+    // to avoid quotation marks.
+    return_string = result.GetString();
+  } else if (result.is_none()) {
+    // Value::TYPE_NULL is for lack of value, undefined, null
+    return_string = "";
+  } else {
+    JSONStringValueSerializer serializer(&return_string);
+    serializer.Serialize(result);
+  }
+
   script_callback_data->callback_func_(script_callback_data->view_,
                                        return_string.c_str(),
                                        script_callback_data->user_data_);