Backed out changeset 44ab0cca4956 (bug 1357486)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 08 Jul 2017 11:23:32 +0200
changeset 416654 9761dc56f9178fc96aefe20bfe2a764d9e56223b
parent 416653 40566f684eddedbdfe0b77a109d645cae07a4248
child 416655 85e8fc25e21d6cb340bad5f4ca551ff92e20c2e1
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1357486
milestone56.0a1
backs out44ab0cca4956dec0ea97cfce9d1503f43d3b9916
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 44ab0cca4956 (bug 1357486)
toolkit/components/extensions/ExtensionParent.jsm
toolkit/components/extensions/LegacyExtensionsUtils.jsm
toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -172,92 +172,53 @@ ProxyMessenger = {
     let messageManagers = [Services.mm, Services.ppmm];
 
     MessageChannel.addListener(messageManagers, "Extension:Connect", this);
     MessageChannel.addListener(messageManagers, "Extension:Message", this);
     MessageChannel.addListener(messageManagers, "Extension:Port:Disconnect", this);
     MessageChannel.addListener(messageManagers, "Extension:Port:PostMessage", this);
   },
 
-  async receiveMessage({target, messageName, channelId, sender, recipient, data, responseType}) {
+  receiveMessage({target, messageName, channelId, sender, recipient, data, responseType}) {
     if (recipient.toNativeApp) {
       let {childId, toNativeApp} = recipient;
       if (messageName == "Extension:Message") {
         let context = ParentAPIManager.getContextById(childId);
         return new NativeApp(context, toNativeApp).sendMessage(data);
       }
       if (messageName == "Extension:Connect") {
         let context = ParentAPIManager.getContextById(childId);
         NativeApp.onConnectNative(context, target.messageManager, data.portId, sender, toNativeApp);
         return true;
       }
       // "Extension:Port:Disconnect" and "Extension:Port:PostMessage" for
       // native messages are handled by NativeApp.
       return;
     }
 
-    const noHandlerError = {
-      result: MessageChannel.RESULT_NO_HANDLER,
-      message: "No matching message handler for the given recipient.",
-    };
-
     let extension = GlobalManager.extensionMap.get(sender.extensionId);
     let receiverMM = this.getMessageManagerForRecipient(recipient);
     if (!extension || !receiverMM) {
-      return Promise.reject(noHandlerError);
+      return Promise.reject({
+        result: MessageChannel.RESULT_NO_HANDLER,
+        message: "No matching message handler for the given recipient.",
+      });
     }
 
     if ((messageName == "Extension:Message" ||
          messageName == "Extension:Connect") &&
         apiManager.global.tabGetSender) {
       // From ext-tabs.js, undefined on Android.
       apiManager.global.tabGetSender(extension, target, sender);
     }
-
-    let promise1 = MessageChannel.sendMessage(receiverMM, messageName, data, {
-      sender,
-      recipient,
-      responseType,
-    });
-
-    if (!extension.isEmbedded || !extension.remote) {
-      return promise1;
-    }
-
-    // If we have a remote, embedded extension, the legacy side is
-    // running in a different process than the WebExtension side.
-    // As a result, we need to dispatch the message to both the parent
-    // and extension processes, and manually merge the results.
-    let promise2 = MessageChannel.sendMessage(Services.ppmm.getChildAt(0), messageName, data, {
+    return MessageChannel.sendMessage(receiverMM, messageName, data, {
       sender,
       recipient,
       responseType,
     });
-
-    let result = undefined;
-    let failures = 0;
-    let tryPromise = async promise => {
-      try {
-        let res = await promise;
-        if (result === undefined) {
-          result = res;
-        }
-      } catch (e) {
-        if (e.result != MessageChannel.RESULT_NO_HANDLER) {
-          throw e;
-        }
-        failures++;
-      }
-    };
-
-    await Promise.all([tryPromise(promise1), tryPromise(promise2)]);
-    if (failures == 2) {
-      return Promise.reject(noHandlerError);
-    }
-    return result;
   },
 
   /**
    * @param {object} recipient An object that was passed to
    *     `MessageChannel.sendMessage`.
    * @param {Extension} extension
    * @returns {object|null} The message manager matching the recipient if found.
    */
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -140,18 +140,16 @@ class EmbeddedExtension {
 
       // This is the instance of the WebExtension embedded in the hybrid add-on.
       this.extension = new Extension({
         id: this.addonId,
         resourceURI: embeddedExtensionURI,
         version: this.version,
       });
 
-      this.extension.isEmbedded = true;
-
       // This callback is register to the "startup" event, emitted by the Extension instance
       // after the extension manifest.json has been loaded without any errors, but before
       // starting any of the defined contexts (which give the legacy part a chance to subscribe
       // runtime.onMessage/onConnect listener before the background page has been loaded).
       const onBeforeStarted = () => {
         this.extension.off("startup", onBeforeStarted);
 
         // Resolve the startup promise and reset the startupError.
--- a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
@@ -52,17 +52,16 @@ add_task(async function test_legacy_exte
     });
   }
 
   let extensionData = {
     background,
   };
 
   let extension = Extension.generate(extensionData);
-  extension.isEmbedded = true;
 
   let waitForExtensionInfo = new Promise((resolve, reject) => {
     extension.on("test-message", function testMessageListener(kind, msg, ...args) {
       if (msg != "webextension-ready") {
         reject(new Error(`Got an unexpected test-message: ${msg}`));
       } else {
         extension.off("test-message", testMessageListener);
         resolve(args[0]);
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -24,18 +24,16 @@ skip-if = os == "android" || (os=='linux
 [test_ext_downloads_search.js]
 skip-if = os == "android"
 [test_ext_experiments.js]
 [test_ext_extension.js]
 [test_ext_extensionPreferencesManager.js]
 [test_ext_extensionSettingsStore.js]
 [test_ext_extension_startup_telemetry.js]
 [test_ext_idle.js]
-[test_ext_legacy_extension_context.js]
-[test_ext_legacy_extension_embedding.js]
 [test_ext_localStorage.js]
 [test_ext_management.js]
 [test_ext_management_uninstall_self.js]
 [test_ext_onmessage_removelistener.js]
 skip-if = true # This test no longer tests what it is meant to test.
 [test_ext_privacy.js]
 [test_ext_privacy_disable.js]
 [test_ext_privacy_update.js]
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -46,12 +46,14 @@ tags = webextensions in-process-webexten
 [test_ext_unknown_permissions.js]
 [test_locale_converter.js]
 [test_locale_data.js]
 
 [test_ext_permissions.js]
 skip-if = os == "android" # Bug 1350559
 [test_ext_runtime_sendMessage_args.js]
 
+[test_ext_legacy_extension_context.js]
+[test_ext_legacy_extension_embedding.js]
 [test_proxy_scripts.js]
 
 [include:xpcshell-common.ini]
 [include:xpcshell-content.ini]