[epiphany/pgriffis/web-extension-gtask] WebExtensions: Resolve to undefined when no return value
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/pgriffis/web-extension-gtask] WebExtensions: Resolve to undefined when no return value
- Date: Thu, 26 May 2022 18:08:59 +0000 (UTC)
commit 8085b44eaf989c357522c3b22d5b126aaa0f142d
Author: Patrick Griffis <pgriffis igalia com>
Date: Thu May 26 11:54:41 2022 -0500
WebExtensions: Resolve to undefined when no return value
embed/web-process-extension/ephy-webextension-api.c | 7 ++++++-
src/webextension/ephy-web-extension-manager.c | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/embed/web-process-extension/ephy-webextension-api.c
b/embed/web-process-extension/ephy-webextension-api.c
index bdcf38cda..41cd1f6dc 100644
--- a/embed/web-process-extension/ephy-webextension-api.c
+++ b/embed/web-process-extension/ephy-webextension-api.c
@@ -195,12 +195,17 @@ on_ephy_message_finish (EphyWebExtensionExtension *extension,
g_autoptr (GError) error = NULL;
EphyMessageData *message_data = g_task_get_task_data (G_TASK (result));
g_autofree char *json = g_task_propagate_pointer (G_TASK (result), &error);
- g_autoptr (JSCValue) value = jsc_value_new_from_json (jsc_value_get_context
(message_data->resolve_callback), json);
+ JSCContext *context = jsc_value_get_context (message_data->resolve_callback);
+ g_autoptr (JSCValue) value = NULL;
g_autoptr (JSCValue) ret = NULL;
if (error) {
ret = jsc_value_function_call (message_data->reject_callback, G_TYPE_STRING, error->message,
G_TYPE_NONE);
+ } else if (strcmp (json, "") == 0) {
+ value = jsc_value_new_undefined (context);
+ ret = jsc_value_function_call (message_data->resolve_callback, JSC_TYPE_VALUE, value, G_TYPE_NONE);
} else {
+ value = jsc_value_new_from_json (context, json);
ret = jsc_value_function_call (message_data->resolve_callback, JSC_TYPE_VALUE, value, G_TYPE_NONE);
}
}
diff --git a/src/webextension/ephy-web-extension-manager.c b/src/webextension/ephy-web-extension-manager.c
index 88a51e19c..9b647d5be 100644
--- a/src/webextension/ephy-web-extension-manager.c
+++ b/src/webextension/ephy-web-extension-manager.c
@@ -482,7 +482,7 @@ ephy_web_extension_handle_user_message (WebKitWebContext *context,
if (ret) {
reply = webkit_user_message_new ("", g_variant_new_take_string (g_steal_pointer (&ret)));
} else {
- reply = webkit_user_message_new ("", g_variant_new_string ("{}"));
+ reply = webkit_user_message_new ("", g_variant_new_string (""));
}
webkit_user_message_send_reply (message, reply);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]