Backed out changeset 562910144a3a (bug 1286746)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 28 Jul 2016 10:34:56 +0200
changeset 349126 b62676e921c5d985713576df7ddec6a0c3a3c760
parent 349125 f7ef7be1560827973c75924d0163830cd15a49f1
child 349127 4f78b9f4278fab7f3fc606f974c104a2721ba769
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1286746
milestone50.0a1
backs out562910144a3a32a69af4957e52d250df5a83136e
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 562910144a3a (bug 1286746)
toolkit/components/extensions/ExtensionUtils.jsm
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_no_receiver.html
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -1141,30 +1141,26 @@ Port.prototype = {
   handleDisconnection() {
     this.messageManager.removeMessageListener(this.disconnectName, this);
     this.context.forgetOnClose(this);
     this.disconnected = true;
   },
 
   receiveMessage(msg) {
     if (msg.name == this.disconnectName) {
-      this.disconnectByOtherEnd();
-    }
-  },
+      if (this.disconnected) {
+        return;
+      }
 
-  disconnectByOtherEnd() {
-    if (this.disconnected) {
-      return;
-    }
+      for (let listener of this.disconnectListeners) {
+        listener();
+      }
 
-    for (let listener of this.disconnectListeners) {
-      listener();
+      this.handleDisconnection();
     }
-
-    this.handleDisconnection();
   },
 
   disconnect() {
     if (this.disconnected) {
       // disconnect() may be called without side effects even after the port is
       // closed - https://developer.chrome.com/extensions/runtime#type-Port
       return;
     }
@@ -1281,18 +1277,18 @@ Messenger.prototype = {
     }).api();
   },
 
   connect(messageManager, name, recipient) {
     // TODO(robwu): Use a process ID instead of the process type. bugzil.la/1287626
     let portId = `${gNextPortId++}-${Services.appinfo.processType}`;
     let port = new Port(this.context, messageManager, name, portId, null);
     let msg = {name, portId};
-    this._sendMessage(messageManager, "Extension:Connect", msg, recipient)
-      .catch(e => port.disconnectByOtherEnd());
+    // TODO: Disconnect the port if no response?
+    this._sendMessage(messageManager, "Extension:Connect", msg, recipient);
     return port.api();
   },
 
   onConnect(name) {
     return new SingletonEventManager(this.context, name, callback => {
       let listener = {
         messageFilterPermissive: this.filter,
 
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -58,17 +58,16 @@ skip-if = buildapp == 'b2g' # runat != d
 [test_ext_localStorage.html]
 [test_ext_onmessage_removelistener.html]
 [test_ext_notifications.html]
 [test_ext_permission_xhr.html]
 skip-if = buildapp == 'b2g' # JavaScript error: jar:remoteopenfile:///data/local/tmp/generated-extension.xpi!/content.js, line 46: NS_ERROR_ILLEGAL_VALUE:
 [test_ext_runtime_connect.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_runtime_connect_twoway.html]
-[test_ext_runtime_connect_no_receiver.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_runtime_connect2.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_runtime_disconnect.html]
 [test_ext_runtime_getPlatformInfo.html]
 [test_ext_runtime_id.html]
 [test_ext_runtime_sendMessage.html]
 [test_ext_runtime_sendMessage_no_receiver.html]
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_no_receiver.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>WebExtension test</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
-</head>
-<body>
-
-<script>
-"use strict";
-
-add_task(function* test_connect_without_listener() {
-  function backgroundScript() {
-    let port = browser.runtime.connect();
-    port.onDisconnect.addListener(() => {
-      browser.test.notifyPass("port.onDisconnect was called");
-    });
-  }
-  let extensionData = {
-    background: `(${backgroundScript})();`,
-  };
-
-  let extension = ExtensionTestUtils.loadExtension(extensionData);
-  yield extension.startup();
-
-  yield extension.awaitFinish("port.onDisconnect was called");
-
-  yield extension.unload();
-});
-</script>
-</body>