[epiphany/pgriffis/web-extension/runtime-send-message: 28/29] WebExtensions: Always reply to runtime._sendMessageReply




commit 87a11e7e81ca64eccf1f853356d4c9559dcc7901
Author: Patrick Griffis <pgriffis igalia com>
Date:   Thu Jun 2 10:32:07 2022 -0500

    WebExtensions: Always reply to runtime._sendMessageReply

 embed/web-process-extension/resources/js/webextensions-common.js | 4 +++-
 src/webextension/ephy-web-extension-manager.c                    | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/embed/web-process-extension/resources/js/webextensions-common.js 
b/embed/web-process-extension/resources/js/webextensions-common.js
index 411411bad..0cba51763 100644
--- a/embed/web-process-extension/resources/js/webextensions-common.js
+++ b/embed/web-process-extension/resources/js/webextensions-common.js
@@ -30,7 +30,9 @@ class EphyEventListener {
     _emit_with_reply (message, sender, message_guid) {
         let handled = false;
         const reply_callback = function (reply_message) {
-            ephy_message ('runtime._sendMessageReply', [message_guid, reply_message]);
+            ephy_message ('runtime._sendMessageReply', [message_guid, reply_message]).catch(error_message => 
{
+                console.error(error_message);
+            });
         };
 
         for (const listener of this._listeners) {
diff --git a/src/webextension/ephy-web-extension-manager.c b/src/webextension/ephy-web-extension-manager.c
index f53db140c..d4ce5ee8d 100644
--- a/src/webextension/ephy-web-extension-manager.c
+++ b/src/webextension/ephy-web-extension-manager.c
@@ -529,7 +529,9 @@ ephy_web_extension_handle_user_message (WebKitWebContext  *context,
 
   /* Private API for message replies handled by the manager. */
   if (strcmp (name, "runtime._sendMessageReply") == 0) {
+    WebKitUserMessage *reply = webkit_user_message_new ("", g_variant_new_string (""));
     handle_message_reply (web_extension, args);
+    webkit_user_message_send_reply (message, reply);
     return TRUE;
   }
 
@@ -1161,8 +1163,6 @@ handle_message_reply (EphyWebExtension *web_extension,
   g_autoptr (JSCValue) message_guid_value = NULL;
   g_autoptr (JSCValue) reply_value = NULL;
 
-  g_message ("handle_message_reply");
-
   message_guid_value = jsc_value_object_get_property_at_index (args, 0);
   if (!jsc_value_is_string (message_guid_value)) {
     g_debug ("Received invalid message reply");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]