Bug 1284455 - Remove the System Messages API, Gecko part r=me
authorFabrice Desré <fabrice@mozilla.com>
Wed, 20 Apr 2016 19:04:13 +0200
changeset 343846 1a5c34f5aa206516af0fd3befd730039c467489a
parent 343845 069a431e7053008d7583a1bfde76e6deef3fcf85
child 343847 f00d45823516184f05e5707472037e5e3afff4e7
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1284455
milestone50.0a1
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
Bug 1284455 - Remove the System Messages API, Gecko part r=me MozReview-Commit-ID: 1mhzddSLkuu
b2g/components/B2GComponents.manifest
b2g/components/SystemMessageGlue.js
b2g/components/SystemMessageInternal.js
b2g/components/moz.build
b2g/components/nsISystemMessagesInternal.idl
browser/installer/package-manifest.in
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsGkAtomList.h
dom/browser-element/mochitest/priority/mochitest.ini
dom/browser-element/mochitest/priority/test_ExpectingSystemMessage.html
dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html
dom/html/nsGenericHTMLFrameElement.cpp
dom/interfaces/html/nsIMozBrowserFrame.idl
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/ProcessPriorityManager.cpp
dom/messages/SystemMessageCache.js
dom/messages/SystemMessageInternal.js
dom/messages/SystemMessageManager.js
dom/messages/SystemMessageManager.manifest
dom/messages/SystemMessagePermissionsChecker.jsm
dom/messages/interfaces/moz.build
dom/messages/interfaces/nsIDOMNavigatorSystemMessages.idl
dom/messages/interfaces/nsISystemMessageCache.idl
dom/messages/interfaces/nsISystemMessageGlue.idl
dom/messages/interfaces/nsISystemMessagesInternal.idl
dom/messages/moz.build
dom/messages/test/chrome.ini
dom/messages/test/file_hasPendingMessage.html
dom/messages/test/invalid_manifest.webapp
dom/messages/test/invalid_manifest.webapp^headers^
dom/messages/test/manifest.webapp
dom/messages/test/manifest.webapp^headers^
dom/messages/test/mochitest.ini
dom/messages/test/system_message_chrome_script.js
dom/messages/test/test_bug_993732.html
dom/messages/test/test_hasPendingMessage.html
dom/messages/test/test_sysmsg_registration.html
dom/moz.build
dom/webidl/Navigator.webidl
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -116,8 +116,12 @@ contract @mozilla.org/presentation-devic
 
 # PresentationRequestUIGlue.js
 component {ccc8a839-0b64-422b-8a60-fb2af0e376d0} PresentationRequestUIGlue.js
 contract @mozilla.org/presentation/requestuiglue;1 {ccc8a839-0b64-422b-8a60-fb2af0e376d0}
 
 # KillSwitch.js
 component {b6eae5c6-971c-4772-89e5-5df626bf3f09} KillSwitch.js
 contract @mozilla.org/moz-kill-switch;1 {b6eae5c6-971c-4772-89e5-5df626bf3f09}
+
+# SystemMessageInternal.js
+component {70589ca5-91ac-4b9e-b839-d6a88167d714} SystemMessageInternal.js
+contract @mozilla.org/system-message-internal;1 {70589ca5-91ac-4b9e-b839-d6a88167d714}
deleted file mode 100644
--- a/b2g/components/SystemMessageGlue.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict"
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
-                                  "resource://gre/modules/SystemAppProxy.jsm");
-
-function SystemMessageGlue() {
-}
-
-SystemMessageGlue.prototype = {
-  openApp: function(aPageURL, aManifestURL, aType, aTarget, aShowApp,
-                    aOnlyShowApp, aExtra) {
-    let payload = { url: aPageURL,
-                    manifestURL: aManifestURL,
-                    isActivity: (aType == "activity"),
-                    target: aTarget,
-                    showApp: aShowApp,
-                    onlyShowApp: aOnlyShowApp,
-                    expectingSystemMessage: true,
-                    extra: aExtra };
-
-    // |SystemAppProxy| will queue "open-app" events for non-activity system
-    // messages without actually sending them until the system app is ready.
-    SystemAppProxy._sendCustomEvent("open-app", payload, (aType == "activity"));
-  },
-
-  classID: Components.ID("{2846f034-e614-11e3-93cd-74d02b97e723}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessageGlue])
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageGlue]);
new file mode 100644
--- /dev/null
+++ b/b2g/components/SystemMessageInternal.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/SystemAppProxy.jsm");
+
+function debug(aMsg) {
+  dump("-- SystemMessageInternal " + Date.now() + " : " + aMsg + "\n");
+}
+
+// Implementation of the component used by internal users.
+
+function SystemMessageInternal() {
+}
+
+SystemMessageInternal.prototype = {
+
+  sendMessage: function(aType, aMessage, aPageURI, aManifestURI, aExtra) {
+    debug(`sendMessage ${aType} ${aMessage} ${aPageURI} ${aExtra}`);
+    SystemAppProxy._sendCustomEvent("mozSystemMessage", {
+      action: "send",
+      type: aType,
+      message: aMessage,
+      pageURI: aPageURI,
+      extra: aExtra
+    });
+    return Promise.resolve();
+  },
+
+  broadcastMessage: function(aType, aMessage, aExtra) {
+    debug(`broadcastMessage ${aType} ${aMessage} ${aExtra}`);
+    SystemAppProxy._sendCustomEvent("mozSystemMessage", {
+      action: "broadcast",
+      type: aType,
+      message: aMessage,
+      extra: aExtra
+    });
+    return Promise.resolve();
+  },
+
+  registerPage: function(aType, aPageURI, aManifestURI) {
+    SystemAppProxy._sendCustomEvent("mozSystemMessage", {
+      action: "register",
+      type: aType,
+      pageURI: aPageURI
+    });
+    debug(`registerPage ${aType} ${aPageURI} ${aManifestURI}`);
+  },
+
+  classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"),
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal])
+}
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageInternal]);
--- a/b2g/components/moz.build
+++ b/b2g/components/moz.build
@@ -20,17 +20,17 @@ EXTRA_COMPONENTS += [
     'MailtoProtocolHandler.js',
     'MobileIdentityUIGlue.js',
     'OMAContentHandler.js',
     'PaymentGlue.js',
     'PaymentProviderStrategy.js',
     'PresentationRequestUIGlue.js',
     'ProcessGlobal.js',
     'SmsProtocolHandler.js',
-    'SystemMessageGlue.js',
+    'SystemMessageInternal.js',
     'TelProtocolHandler.js',
     'WebappsUpdateTimer.js',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
     EXTRA_COMPONENTS += [
       'CommandLine.js',
       'OopCommandLine.js',
@@ -75,8 +75,14 @@ EXTRA_JS_MODULES += [
     'TelURIParser.jsm',
     'WebappsUpdater.jsm',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     EXTRA_JS_MODULES += [
       'GlobalSimulatorScreen.jsm'
     ]
+
+XPIDL_SOURCES += [
+    'nsISystemMessagesInternal.idl'
+]
+
+XPIDL_MODULE = 'gaia_chrome'
new file mode 100644
--- /dev/null
+++ b/b2g/components/nsISystemMessagesInternal.idl
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "domstubs.idl"
+
+interface nsIURI;
+interface nsIDOMWindow;
+interface nsIMessageSender;
+
+// Implemented by the contract id @mozilla.org/system-message-internal;1
+
+[scriptable, uuid(59b6beda-f911-4d47-a296-8c81e6abcfb9)]
+interface nsISystemMessagesInternal : nsISupports
+{
+  /*
+   * Allow any internal user to send a message of a given type to a given page
+   * of an app. The message will be sent to all the registered pages of the app
+   * when |pageURI| is not specified.
+   * @param type        The type of the message to be sent.
+   * @param message     The message payload.
+   * @param pageURI     The URI of the page that will be opened. Nullable.
+   * @param manifestURI The webapp's manifest URI.
+   * @param extra       Extra opaque information that will be passed around in the observer
+   *                    notification to open the page.
+   * returns a Promise
+   */
+  nsISupports sendMessage(in DOMString type, in jsval message,
+                          in nsIURI pageURI, in nsIURI manifestURI,
+                          [optional] in jsval extra);
+
+  /*
+   * Allow any internal user to broadcast a message of a given type.
+   * The application that registers the message will be launched.
+   * @param type        The type of the message to be sent.
+   * @param message     The message payload.
+   * @param extra       Extra opaque information that will be passed around in the observer
+   *                    notification to open the page.
+   * returns a Promise
+   */
+  nsISupports broadcastMessage(in DOMString type, in jsval message,
+                               [optional] in jsval extra);
+
+  /*
+   * Registration of a page that wants to be notified of a message type.
+   * @param type          The message type.
+   * @param pageURI       The URI of the page that will be opened.
+   * @param manifestURI   The webapp's manifest URI.
+   */
+  void registerPage(in DOMString type, in nsIURI pageURI, in nsIURI manifestURI);
+};
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -528,21 +528,16 @@
 @RESPATH@/components/RemoteWebNavigation.js
 
 @RESPATH@/components/SlowScriptDebug.manifest
 @RESPATH@/components/SlowScriptDebug.js
 
 @RESPATH@/components/TVSimulatorService.js
 @RESPATH@/components/TVSimulatorService.manifest
 
-@RESPATH@/components/SystemMessageCache.js
-@RESPATH@/components/SystemMessageInternal.js
-@RESPATH@/components/SystemMessageManager.js
-@RESPATH@/components/SystemMessageManager.manifest
-
 @RESPATH@/components/Payment.js
 @RESPATH@/components/PaymentFlowInfo.js
 @RESPATH@/components/Payment.manifest
 
 #ifdef MOZ_WEBRTC
 @RESPATH@/components/PeerConnection.js
 @RESPATH@/components/PeerConnection.manifest
 #endif
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -72,17 +72,16 @@
 #include "nsNetUtil.h"
 #include "nsStringStream.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIStringStream.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "TimeManager.h"
 #include "DeviceStorage.h"
-#include "nsIDOMNavigatorSystemMessages.h"
 #include "nsStreamUtils.h"
 #include "nsIAppsService.h"
 #include "mozIApplication.h"
 #include "WidgetUtils.h"
 #include "nsIPresentationService.h"
 
 #include "mozilla/dom/MediaDevices.h"
 #include "MediaManager.h"
@@ -253,17 +252,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
 #ifdef MOZ_B2G_BT
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBluetooth)
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioChannelManager)
 #endif
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCameraManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaDevices)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessagesManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimeManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
 #ifdef MOZ_EME
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager)
 #endif
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeviceStorageAreaListener)
@@ -368,20 +366,16 @@ Navigator::Invalidate()
   if (mBluetooth) {
     mBluetooth = nullptr;
   }
 #endif
 
   mCameraManager = nullptr;
   mMediaDevices = nullptr;
 
-  if (mMessagesManager) {
-    mMessagesManager = nullptr;
-  }
-
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   if (mAudioChannelManager) {
     mAudioChannelManager = nullptr;
   }
 #endif
 
   uint32_t len = mDeviceStorageStores.Length();
   for (uint32_t i = 0; i < len; ++i) {
@@ -2126,112 +2120,16 @@ Navigator::GetMozBluetooth(ErrorResult& 
     }
     mBluetooth = bluetooth::BluetoothManager::Create(mWindow);
   }
 
   return mBluetooth;
 }
 #endif //MOZ_B2G_BT
 
-nsresult
-Navigator::EnsureMessagesManager()
-{
-  if (mMessagesManager) {
-    return NS_OK;
-  }
-
-  NS_ENSURE_STATE(mWindow);
-
-  nsresult rv;
-  nsCOMPtr<nsIDOMNavigatorSystemMessages> messageManager =
-    do_CreateInstance("@mozilla.org/system-message-manager;1", &rv);
-
-  nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
-    do_QueryInterface(messageManager);
-  NS_ENSURE_TRUE(gpi, NS_ERROR_FAILURE);
-
-  // We don't do anything with the return value.
-  AutoJSContext cx;
-  JS::Rooted<JS::Value> prop_val(cx);
-  rv = gpi->Init(mWindow, &prop_val);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mMessagesManager = messageManager.forget();
-
-  return NS_OK;
-}
-
-bool
-Navigator::MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv)
-{
-  // The WebIDL binding is responsible for the pref check here.
-  nsresult rv = EnsureMessagesManager();
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return false;
-  }
-
-  bool result = false;
-  rv = mMessagesManager->MozHasPendingMessage(aType, &result);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return false;
-  }
-  return result;
-}
-
-void
-Navigator::MozSetMessageHandlerPromise(Promise& aPromise,
-                                       ErrorResult& aRv)
-{
-  // The WebIDL binding is responsible for the pref check here.
-  aRv = EnsureMessagesManager();
-  if (NS_WARN_IF(aRv.Failed())) {
-    return;
-  }
-
-  bool result = false;
-  aRv = mMessagesManager->MozIsHandlingMessage(&result);
-  if (NS_WARN_IF(aRv.Failed())) {
-    return;
-  }
-
-  if (!result) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    return;
-  }
-
-  aRv = mMessagesManager->MozSetMessageHandlerPromise(&aPromise);
-  if (NS_WARN_IF(aRv.Failed())) {
-    return;
-  }
-}
-
-void
-Navigator::MozSetMessageHandler(const nsAString& aType,
-                                systemMessageCallback* aCallback,
-                                ErrorResult& aRv)
-{
-  // The WebIDL binding is responsible for the pref check here.
-  nsresult rv = EnsureMessagesManager();
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return;
-  }
-
-  CallbackObjectHolder<systemMessageCallback, nsIDOMSystemMessageCallback>
-    holder(aCallback);
-  nsCOMPtr<nsIDOMSystemMessageCallback> callback = holder.ToXPCOMCallback();
-
-  rv = mMessagesManager->MozSetMessageHandler(aType, callback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
-}
-
 #ifdef MOZ_TIME_MANAGER
 time::TimeManager*
 Navigator::GetMozTime(ErrorResult& aRv)
 {
   if (!mWindow) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -142,19 +142,16 @@ public:
    */
   void SetWindow(nsPIDOMWindowInner *aInnerWindow);
 
   /**
    * Called when the inner window navigates to a new page.
    */
   void OnNavigation();
 
-  // Helper to initialize mMessagesManager.
-  nsresult EnsureMessagesManager();
-
   // The XPCOM GetProduct is OK
   // The XPCOM GetLanguage is OK
   void GetUserAgent(nsString& aUserAgent, ErrorResult& /* unused */)
   {
     GetUserAgent(aUserAgent);
   }
   bool OnLine();
   void RegisterProtocolHandler(const nsAString& aScheme, const nsAString& aURL,
@@ -246,21 +243,16 @@ public:
   Telephony* GetMozTelephony(ErrorResult& aRv);
   Voicemail* GetMozVoicemail(ErrorResult& aRv);
   TVManager* GetTv();
   InputPortManager* GetInputPortManager(ErrorResult& aRv);
   already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
   network::Connection* GetConnection(ErrorResult& aRv);
   nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   MediaDevices* GetMediaDevices(ErrorResult& aRv);
-  void MozSetMessageHandler(const nsAString& aType,
-                            systemMessageCallback* aCallback,
-                            ErrorResult& aRv);
-  bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
-  void MozSetMessageHandlerPromise(Promise& aPromise, ErrorResult& aRv);
 
 #ifdef MOZ_B2G
   already_AddRefed<Promise> GetMobileIdAssertion(const MobileIdOptions& options,
                                                  ErrorResult& aRv);
 #endif
 #ifdef MOZ_B2G_RIL
   MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
@@ -388,17 +380,16 @@ private:
 #ifdef MOZ_B2G_BT
   RefPtr<bluetooth::BluetoothManager> mBluetooth;
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   RefPtr<system::AudioChannelManager> mAudioChannelManager;
 #endif
   RefPtr<nsDOMCameraManager> mCameraManager;
   RefPtr<MediaDevices> mMediaDevices;
-  nsCOMPtr<nsIDOMNavigatorSystemMessages> mMessagesManager;
   nsTArray<nsWeakPtr> mDeviceStorageStores;
   RefPtr<time::TimeManager> mTimeManager;
   RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   RefPtr<DeviceStorageAreaListener> mDeviceStorageAreaListener;
   RefPtr<Presentation> mPresentation;
 #ifdef MOZ_GAMEPAD
   RefPtr<GamepadServiceTest> mGamepadServiceTest;
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -368,17 +368,16 @@ GK_ATOM(end_before, "end_before")
 GK_ATOM(equalsize, "equalsize")
 GK_ATOM(error, "error")
 GK_ATOM(even, "even")
 GK_ATOM(event, "event")
 GK_ATOM(events, "events")
 GK_ATOM(excludeResultPrefixes, "exclude-result-prefixes")
 GK_ATOM(excludes, "excludes")
 GK_ATOM(expr, "expr")
-GK_ATOM(expectingSystemMessage, "expecting-system-message")
 GK_ATOM(extends, "extends")
 GK_ATOM(extensionElementPrefixes, "extension-element-prefixes")
 GK_ATOM(face, "face")
 GK_ATOM(fallback, "fallback")
 GK_ATOM(_false, "false")
 GK_ATOM(farthest, "farthest")
 GK_ATOM(field, "field")
 GK_ATOM(fieldset, "fieldset")
--- a/dom/browser-element/mochitest/priority/mochitest.ini
+++ b/dom/browser-element/mochitest/priority/mochitest.ini
@@ -22,13 +22,11 @@ support-files =
 [test_BackgroundLRU.html]
 [test_Activity.html]
 [test_Audio.html]
 [test_Keyboard.html]
 [test_MultipleActivities.html]
 [test_MultipleFrames.html]
 [test_Preallocated.html]
 disabled = bug 968604, bug 987164
-[test_ExpectingSystemMessage.html]
-[test_ExpectingSystemMessage2.html]
 [test_NestedFrames.html]
 [test_WebGLContextLost.html]
 disabled = bug 865844
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_ExpectingSystemMessage.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that a high-priority frame that's expecting a system message initially
-gets priority FOREGROUND_HIGH.
--->
-<head>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-browserElementTestHelpers.enableProcessPriorityManager();
-SpecialPowers.addPermission("embed-apps", true, document);
-
-function runTest() {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', true);
-  iframe.setAttribute('expecting-system-message', true);
-  iframe.setAttribute('mozapptype', 'critical');
-  iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-
-  var childID = null;
-  expectOnlyOneProcessCreated('FOREGROUND_HIGH').then(function(chid) {
-    childID = chid;
-  }).then(function() {
-    // We go back to foreground when the wake lock taken on behalf of our new
-    // process times out.
-    return expectPriorityChange(childID, 'FOREGROUND');
-  }).then(SimpleTest.finish);
-
-  document.body.appendChild(iframe);
-}
-
-addEventListener('testready', function() {
-  // Cause the CPU wake lock taken on behalf of this new process to time out
-  // after 1s.
-  SpecialPowers.pushPrefEnv(
-    {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 1]]},
-    runTest);
-});
-
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that a regular (not mozapptype=critical) frame that's expecting a system
-message gets priority BACKGROUND_PERCEIVABLE when it's in the background.
--->
-<head>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-browserElementTestHelpers.enableProcessPriorityManager();
-SpecialPowers.addPermission("embed-apps", true, document);
-
-// Give our origin permission to open browsers, and remove it when the test is complete.
-var principal = SpecialPowers.wrap(document).nodePrincipal;
-SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
-                                              originAttributes: {
-                                                appId: principal.appId,
-                                                inIsolatedMozBrowser: true
-                                              }});
-
-addEventListener('unload', function() {
-  var principal = SpecialPowers.wrap(document).nodePrincipal;
-  SpecialPowers.removePermission("browser", {url: SpecialPowers.wrap(principal.URI).spec,
-                                             originAttributes: {
-                                               appId: principal.appId,
-                                               inIsolatedMozBrowser: true
-                                             }});
-});
-
-function runTest() {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', true);
-  iframe.setAttribute('expecting-system-message', true);
-  iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-
-  var childID = null;
-  Promise.all([
-    expectOnlyOneProcessCreated('FOREGROUND').then(function(chid) {
-      childID = chid;
-    }),
-    expectMozbrowserEvent(iframe, 'loadend')
-  ]).then(function() {
-    var p = expectPriorityChange(childID, 'BACKGROUND_PERCEIVABLE');
-    iframe.setVisible(false);
-    return p;
-  }).then(SimpleTest.finish);
-
-  document.body.appendChild(iframe);
-}
-
-addEventListener('testready', function() {
-  // We don't want this wake lock to time out during the test; if it did, then
-  // we might see BACKGROUND priority instead of BACKGROUND_PERCEIVABLE.  So
-  // set the timeout to a large value.
-  SpecialPowers.pushPrefEnv(
-    {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 99999]]},
-    runTest);
-});
-
-</script>
-</body>
-</html>
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -590,29 +590,16 @@ nsGenericHTMLFrameElement::GetIsolated(b
     return NS_OK;
   }
 
   // Isolation is only disabled if the attribute is present
   *aOut = !HasAttr(kNameSpaceID_None, nsGkAtoms::noisolation);
   return NS_OK;
 }
 
-/* [infallible] */ NS_IMETHODIMP
-nsGenericHTMLFrameElement::GetIsExpectingSystemMessage(bool *aOut)
-{
-  *aOut = false;
-
-  if (!nsIMozBrowserFrame::GetReallyIsApp()) {
-    return NS_OK;
-  }
-
-  *aOut = HasAttr(kNameSpaceID_None, nsGkAtoms::expectingSystemMessage);
-  return NS_OK;
-}
-
 /** Get manifest url of app or widget
  * @param AppType: nsGkAtoms::mozapp or nsGkAtoms::mozwidget
  */
 void nsGenericHTMLFrameElement::GetManifestURLByType(nsIAtom *aAppType,
                                                      nsAString& aManifestURL)
 {
   aManifestURL.Truncate();
 
--- a/dom/interfaces/html/nsIMozBrowserFrame.idl
+++ b/dom/interfaces/html/nsIMozBrowserFrame.idl
@@ -53,26 +53,16 @@ interface nsIMozBrowserFrame : nsIDOMMoz
    *
    * Isolation can be disabled by setting the frame's isolated attribute to
    * false.  Disabling isolation is only allowed if the containing document has
    * browser permission (or equivalent access).
    */
   [infallible] readonly attribute boolean isolated;
 
   /**
-   * This corresponds to the expecting-system-message attribute, which tells us
-   * whether we should expect that this frame will receive a system message once
-   * it starts up.
-   *
-   * It's the embedder's job to set this attribute on a frame.  Its presence
-   * might cause us to increase the priority of the frame's process.
-   */
-  [infallible] readonly attribute boolean isExpectingSystemMessage;
-
-  /**
    * Gets this frame's app manifest URL or widget manifest URL, if the frame
    * really is an app frame.
    * Otherwise, returns the empty string.
    *
    * This method is guaranteed not to fail.
    */
   readonly attribute AString appManifestURL;
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -103,17 +103,16 @@
 #include "SandboxHal.h"
 #include "nsDebugImpl.h"
 #include "nsHashPropertyBag.h"
 #include "nsLayoutStylesheetCache.h"
 #include "nsThreadManager.h"
 #include "nsAnonymousTemporaryFile.h"
 #include "nsISpellChecker.h"
 #include "nsClipboardProxy.h"
-#include "nsISystemMessageCache.h"
 #include "nsDirectoryService.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsContentPermissionHelper.h"
 #ifdef NS_PRINTING
 #include "nsPrintingProxy.h"
 #endif
 
@@ -482,49 +481,16 @@ ConsoleListener::Observe(nsIConsoleMessa
 
   nsXPIDLString msg;
   nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
   NS_ENSURE_SUCCESS(rv, rv);
   mChild->SendConsoleMessage(msg);
   return NS_OK;
 }
 
-class SystemMessageHandledObserver final : public nsIObserver
-{
-  ~SystemMessageHandledObserver() {}
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-
-  void Init();
-};
-
-void SystemMessageHandledObserver::Init()
-{
-  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-
-  if (os) {
-    os->AddObserver(this, "handle-system-messages-done", /* ownsWeak */ false);
-  }
-}
-
-NS_IMETHODIMP
-SystemMessageHandledObserver::Observe(nsISupports* aSubject,
-                                      const char* aTopic,
-                                      const char16_t* aData)
-{
-  if (ContentChild::GetSingleton()) {
-    ContentChild::GetSingleton()->SendSystemMessageHandled();
-  }
-  return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS(SystemMessageHandledObserver, nsIObserver)
-
 class BackgroundChildPrimer final :
   public nsIIPCBackgroundChildCreateCallback
 {
 public:
   BackgroundChildPrimer()
   { }
 
   NS_DECL_ISUPPORTS
@@ -564,20 +530,16 @@ InitOnContentProcessCreated()
   nsCOMPtr<nsIPermissionManager> permManager = services::GetPermissionManager();
   MOZ_ASSERT(permManager, "Unable to get permission manager");
   nsresult rv = permManager->RefreshPermission();
   if (NS_FAILED(rv)) {
     MOZ_ASSERT(false, "Failed updating permission in child process");
   }
 #endif
 
-  nsCOMPtr<nsISystemMessageCache> smc =
-    do_GetService("@mozilla.org/system-message-cache;1");
-  NS_WARN_IF(!smc);
-
   // This will register cross-process observer.
   mozilla::dom::time::InitializeDateCacheCleaner();
 }
 
 #ifdef MOZ_NUWA_PROCESS
 static void
 ResetTransports(void* aUnused)
 {
@@ -1076,21 +1038,16 @@ ContentChild::InitXPCOM()
     initialData.Read(jsapi.cx(), &data, rv);
     if (NS_WARN_IF(rv.Failed())) {
       MOZ_CRASH();
     }
     ProcessGlobal* global = ProcessGlobal::Get();
     global->SetInitialProcessData(data);
   }
 
-  // This object is held alive by the observer service.
-  RefPtr<SystemMessageHandledObserver> sysMsgObserver =
-    new SystemMessageHandledObserver();
-  sysMsgObserver->Init();
-
   InitOnContentProcessCreated();
 }
 
 PMemoryReportRequestChild*
 ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
                                              const bool &aAnonymize,
                                              const bool &aMinimizeMemoryUsage,
                                              const MaybeFileDesc& aDMDFile)
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -145,17 +145,16 @@
 #include "nsIParentChannel.h"
 #include "nsIPresShell.h"
 #include "nsIRemoteWindowContext.h"
 #include "nsIScriptError.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsISiteSecurityService.h"
 #include "nsISpellChecker.h"
 #include "nsISupportsPrimitives.h"
-#include "nsISystemMessagesInternal.h"
 #include "nsITimer.h"
 #include "nsIURIFixup.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIXULWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIWindowWatcher.h"
 #include "nsWindowWatcher.h"
@@ -882,19 +881,17 @@ ContentParent::GetInitialProcessPriority
     return PROCESS_PRIORITY_FOREGROUND;
   }
 
   nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aFrameElement);
   if (!browserFrame) {
     return PROCESS_PRIORITY_FOREGROUND;
   }
 
-  return browserFrame->GetIsExpectingSystemMessage() ?
-           PROCESS_PRIORITY_FOREGROUND_HIGH :
-           PROCESS_PRIORITY_FOREGROUND;
+  return PROCESS_PRIORITY_FOREGROUND;
 }
 
 #if defined(XP_WIN)
 extern const wchar_t* kPluginWidgetContentParentProperty;
 
 /*static*/ void
 ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
 {
@@ -1352,18 +1349,16 @@ ContentParent::CreateBrowserOrApp(const 
       return ContentParent::CreateBrowserOrApp(aContext, aFrameElement,
                                                aOpenerContentParent);
     }
 
     // Otherwise just give up.
     return nullptr;
   }
 
-  parent->AsContentParent()->MaybeTakeCPUWakeLock(aFrameElement);
-
   return TabParent::GetFrom(browser);
 }
 
 /*static*/ ContentBridgeParent*
 ContentParent::CreateContentBridgeParent(const TabContext& aContext,
                                          const hal::ProcessPriority& aPriority,
                                          const TabId& aOpenerTabId,
                                          /*out*/ TabId* aTabId)
@@ -1480,113 +1475,20 @@ ContentParent::ForwardKnownInfo()
 #ifdef MOZ_WIDGET_GONK
   InfallibleTArray<VolumeInfo> volumeInfo;
   RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
   if (vs) {
     vs->GetVolumesForIPC(&volumeInfo);
     Unused << SendVolumes(volumeInfo);
   }
 #endif /* MOZ_WIDGET_GONK */
-
-  nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
-    do_GetService("@mozilla.org/system-message-internal;1");
-  if (systemMessenger && !mIsForBrowser) {
-    nsCOMPtr<nsIURI> manifestURI;
-    nsresult rv = NS_NewURI(getter_AddRefs(manifestURI), mAppManifestURL);
-    if (NS_SUCCEEDED(rv)) {
-      systemMessenger->RefreshCache(mMessageManager, manifestURI);
-    }
-  }
 }
 
 namespace {
 
-class SystemMessageHandledListener final
-  : public nsITimerCallback
-  , public LinkedListElement<SystemMessageHandledListener>
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  SystemMessageHandledListener() {}
-
-  static void OnSystemMessageHandled()
-  {
-    if (!sListeners) {
-      return;
-    }
-
-    SystemMessageHandledListener* listener = sListeners->popFirst();
-    if (!listener) {
-      return;
-    }
-
-    // Careful: ShutDown() may delete |this|.
-    listener->ShutDown();
-  }
-
-  void Init(WakeLock* aWakeLock)
-  {
-    MOZ_ASSERT(!mWakeLock);
-    MOZ_ASSERT(!mTimer);
-
-    // mTimer keeps a strong reference to |this|.  When this object's
-    // destructor runs, it will remove itself from the LinkedList.
-
-    if (!sListeners) {
-      sListeners = new LinkedList<SystemMessageHandledListener>();
-      ClearOnShutdown(&sListeners);
-    }
-    sListeners->insertBack(this);
-
-    mWakeLock = aWakeLock;
-
-    mTimer = do_CreateInstance("@mozilla.org/timer;1");
-
-    uint32_t timeoutSec =
-      Preferences::GetInt("dom.ipc.systemMessageCPULockTimeoutSec", 30);
-    mTimer->InitWithCallback(this, timeoutSec * 1000, nsITimer::TYPE_ONE_SHOT);
-  }
-
-  NS_IMETHOD Notify(nsITimer* aTimer) override
-  {
-    // Careful: ShutDown() may delete |this|.
-    ShutDown();
-    return NS_OK;
-  }
-
-private:
-  ~SystemMessageHandledListener() {}
-
-  static StaticAutoPtr<LinkedList<SystemMessageHandledListener> > sListeners;
-
-  void ShutDown()
-  {
-    RefPtr<SystemMessageHandledListener> kungFuDeathGrip = this;
-
-    ErrorResult rv;
-    mWakeLock->Unlock(rv);
-
-    if (mTimer) {
-      mTimer->Cancel();
-      mTimer = nullptr;
-    }
-  }
-
-  RefPtr<WakeLock> mWakeLock;
-  nsCOMPtr<nsITimer> mTimer;
-};
-
-StaticAutoPtr<LinkedList<SystemMessageHandledListener> >
-  SystemMessageHandledListener::sListeners;
-
-NS_IMPL_ISUPPORTS(SystemMessageHandledListener,
-                  nsITimerCallback)
-
-
 class RemoteWindowContext final : public nsIRemoteWindowContext
                                 , public nsIInterfaceRequestor
 {
 public:
   explicit RemoteWindowContext(TabParent* aTabParent)
   : mTabParent(aTabParent)
   {
   }
@@ -1616,40 +1518,16 @@ NS_IMETHODIMP
 RemoteWindowContext::OpenURI(nsIURI* aURI)
 {
   mTabParent->LoadURL(aURI);
   return NS_OK;
 }
 
 } // namespace
 
-void
-ContentParent::MaybeTakeCPUWakeLock(Element* aFrameElement)
-{
-  // Take the CPU wake lock on behalf of this processs if it's expecting a
-  // system message.  We'll release the CPU lock once the message is
-  // delivered, or after some period of time, which ever comes first.
-
-  nsCOMPtr<nsIMozBrowserFrame> browserFrame =
-    do_QueryInterface(aFrameElement);
-  if (!browserFrame ||
-    !browserFrame->GetIsExpectingSystemMessage()) {
-    return;
-  }
-
-  RefPtr<PowerManagerService> pms = PowerManagerService::GetInstance();
-  RefPtr<WakeLock> lock =
-    pms->NewWakeLockOnBehalfOfProcess(NS_LITERAL_STRING("cpu"), this);
-
-  // This object's Init() function keeps it alive.
-  RefPtr<SystemMessageHandledListener> listener =
-    new SystemMessageHandledListener();
-  listener->Init(lock);
-}
-
 bool
 ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
 {
   ProcessPriorityManager::SetProcessPriority(this, aPriority);
 
   // Now that we've set this process's priority, check whether the process is
   // still alive.  Hopefully we've set the priority to FOREGROUND*, so the
   // process won't unexpectedly crash after this point!
@@ -4798,23 +4676,16 @@ ContentParent::KillChild()
 
 PBlobParent*
 ContentParent::SendPBlobConstructor(PBlobParent* aActor,
                                     const BlobConstructorParams& aParams)
 {
   return PContentParent::SendPBlobConstructor(aActor, aParams);
 }
 
-bool
-ContentParent::RecvSystemMessageHandled()
-{
-  SystemMessageHandledListener::OnSystemMessageHandled();
-  return true;
-}
-
 PBrowserParent*
 ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
                                        const TabId& aTabId,
                                        const IPCTabContext& aContext,
                                        const uint32_t& aChromeFlags,
                                        const ContentParentId& aCpId,
                                        const bool& aIsForApp,
                                        const bool& aIsForBrowser)
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -655,22 +655,16 @@ private:
 
   void Init();
 
   // Some information could be sent to content very early, it
   // should be send from this function. This function should only be
   // called after the process has been transformed to app or browser.
   void ForwardKnownInfo();
 
-  // If the frame element indicates that the child process is "critical" and
-  // has a pending system message, this function acquires the CPU wake lock on
-  // behalf of the child.  We'll release the lock when the system message is
-  // handled or after a timeout, whichever comes first.
-  void MaybeTakeCPUWakeLock(Element* aFrameElement);
-
   // Set the child process's priority and then check whether the child is
   // still alive.  Returns true if the process is still alive, and false
   // otherwise.  If you pass a FOREGROUND* priority here, it's (hopefully)
   // unlikely that the process will be killed after this point.
   bool SetPriorityAndCheckIsAlive(hal::ProcessPriority aPriority);
 
   // Transform a pre-allocated app process into a "real" app
   // process, for the specified manifest URL.
@@ -1058,18 +1052,16 @@ private:
   virtual bool RecvGetSystemMemory(const uint64_t& getterId) override;
 
   virtual bool RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>* aLookAndFeelIntCache) override;
 
   virtual bool RecvSpeakerManagerGetSpeakerStatus(bool* aValue) override;
 
   virtual bool RecvSpeakerManagerForceSpeaker(const bool& aEnable) override;
 
-  virtual bool RecvSystemMessageHandled() override;
-
   // Callbacks from NuwaParent.
   void OnNuwaReady();
   void OnNewProcessCreated(uint32_t aPid,
                            UniquePtr<nsTArray<ProtocolFdMapping>>&& aFds);
 
   virtual bool RecvCreateFakeVolume(const nsString& aFsName,
                                     const nsString& aMountPoint) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -923,19 +923,16 @@ parent:
 
     async AudioChannelChangeDefVolChannel(int32_t aChannel, bool aHidden);
 
     async FilePathUpdateNotify(nsString aType,
                                nsString aStorageName,
                                nsString aFilepath,
                                nsCString aReason);
 
-    // Notify the parent that the child has finished handling a system message.
-    async SystemMessageHandled();
-
     // called by the child (test code only) to propagate volume changes to the parent
     async CreateFakeVolume(nsString fsName, nsString mountPoint);
     async SetFakeVolumeState(nsString fsName, int32_t fsState);
     async RemoveFakeVolume(nsString fsName);
 
     sync KeywordToURI(nsCString keyword)
         returns (nsString providerName, OptionalInputStreamParams postData, OptionalURIParams uri);
 
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -1040,20 +1040,16 @@ ParticularProcessPriorityManager::IsExpe
   const ManagedContainer<PBrowserParent>& browsers =
     mContentParent->ManagedPBrowserParent();
   for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) {
     TabParent* tp = TabParent::GetFrom(iter.Get()->GetKey());
     nsCOMPtr<nsIMozBrowserFrame> bf = do_QueryInterface(tp->GetOwnerElement());
     if (!bf) {
       continue;
     }
-
-    if (bf->GetIsExpectingSystemMessage()) {
-      return true;
-    }
   }
 
   return false;
 }
 
 ProcessPriority
 ParticularProcessPriorityManager::CurrentPriority()
 {
deleted file mode 100644
--- a/dom/messages/SystemMessageCache.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-                                   "@mozilla.org/childprocessmessagemanager;1",
-                                   "nsISyncMessageSender");
-
-function debug(aMsg) {
-   // dump("-- SystemMessageCache " + Date.now() + " : " + aMsg + "\n");
-}
-
-const kMessages = ["SystemMessageCache:RefreshCache"];
-
-function SystemMessageCache() {
-  debug("init");
-
-  this._pagesCache = [];
-
-  Services.obs.addObserver(this, "xpcom-shutdown", false);
-  kMessages.forEach(function(aMessage) {
-    cpmm.addMessageListener(aMessage, this);
-  }, this);
-}
-
-SystemMessageCache.prototype = {
-
-  observe: function(aSubject, aTopic, aData) {
-    switch (aTopic) {
-    case "xpcom-shutdown":
-      debug("received xpcom-shutdown");
-      kMessages.forEach(function(aMessage) {
-        cpmm.removeMessageListener(aMessage, this);
-      }, this);
-      Services.obs.removeObserver(this, "xpcom-shutdown");
-      cpmm = null;
-      break;
-    default:
-      break;
-    }
-  },
-
-  receiveMessage: function(aMessage) {
-    switch (aMessage.name) {
-    case "SystemMessageCache:RefreshCache":
-      this._pagesCache = aMessage.data;
-      debug("received RefreshCache");
-      break;
-    default:
-      debug("received unknown message " + aMessage.name);
-      break;
-    }
-  },
-
-  hasPendingMessage: function(aType, aPageURL, aManifestURL) {
-    let hasMessage = this._pagesCache.some(function(aPage) {
-      if (aPage.type === aType &&
-          aPage.pageURL === aPageURL &&
-          aPage.manifestURL === aManifestURL) {
-        return true;
-      }
-      return false;
-    }, this);
-    debug("hasPendingMessage " + aType + " " + aPageURL + " " +
-          aManifestURL + ": " + hasMessage);
-    return hasMessage;
-  },
-
-  classID: Components.ID("{5a19d86a-21e5-4ac8-9634-8c364c73f87f}"),
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessageCache,
-                                         Ci.nsIMessageListener,
-                                         Ci.nsIObserver])
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageCache]);
deleted file mode 100644
--- a/dom/messages/SystemMessageInternal.js
+++ /dev/null
@@ -1,860 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/SystemMessagePermissionsChecker.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
-                                   "@mozilla.org/parentprocessmessagemanager;1",
-                                   "nsIMessageBroadcaster");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
-                                   "@mozilla.org/uuid-generator;1",
-                                   "nsIUUIDGenerator");
-
-XPCOMUtils.defineLazyServiceGetter(this, "powerManagerService",
-                                   "@mozilla.org/power/powermanagerservice;1",
-                                   "nsIPowerManagerService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "appsService",
-                                   "@mozilla.org/AppsService;1",
-                                   "nsIAppsService");
-
-// Limit the number of pending messages for a given page.
-var kMaxPendingMessages;
-try {
-  kMaxPendingMessages =
-    Services.prefs.getIntPref("dom.messages.maxPendingMessages");
-} catch(e) {
-  // getIntPref throws when the pref is not set.
-  kMaxPendingMessages = 5;
-}
-
-const kMessages =["SystemMessageManager:GetPendingMessages",
-                  "SystemMessageManager:HasPendingMessages",
-                  "SystemMessageManager:Register",
-                  "SystemMessageManager:Unregister",
-                  "SystemMessageManager:Message:Return:OK",
-                  "SystemMessageManager:AskReadyToRegister",
-                  "SystemMessageManager:HandleMessagesDone",
-                  "SystemMessageManager:HandleMessageDone",
-                  "child-process-shutdown"];
-
-function debug(aMsg) {
-  // dump("-- SystemMessageInternal " + Date.now() + " : " + aMsg + "\n");
-}
-
-
-var defaultMessageConfigurator = {
-  get mustShowRunningApp() {
-    return false;
-  }
-};
-
-const MSG_SENT_SUCCESS = 0;
-const MSG_SENT_FAILURE_PERM_DENIED = 1;
-const MSG_SENT_FAILURE_APP_NOT_RUNNING = 2;
-
-// Implementation of the component used by internal users.
-
-function SystemMessageInternal() {
-  // The set of pages registered by installed apps. We keep the
-  // list of pending messages for each page here also.
-  this._pages = [];
-
-  // The set of listeners. This is a multi-dimensional object. The _listeners
-  // object itself is a map from manifest URL -> an array mapping proccesses to
-  // windows. We do this so that we can track both what processes we have to
-  // send system messages to as well as supporting the single-process case
-  // where we track windows instead.
-  this._listeners = {};
-
-  this._webappsRegistryReady = false;
-  this._bufferedSysMsgs = [];
-
-  this._cpuWakeLocks = {};
-
-  this._configurators = {};
-
-  this._pendingPromises = new Map();
-
-  Services.obs.addObserver(this, "xpcom-shutdown", false);
-  Services.obs.addObserver(this, "webapps-registry-start", false);
-  Services.obs.addObserver(this, "webapps-registry-ready", false);
-  Services.obs.addObserver(this, "webapps-clear-data", false);
-  kMessages.forEach(function(aMsg) {
-    ppmm.addMessageListener(aMsg, this);
-  }, this);
-
-  Services.obs.notifyObservers(this, "system-message-internal-ready", null);
-}
-
-SystemMessageInternal.prototype = {
-
-  _getMessageConfigurator: function(aType) {
-    debug("_getMessageConfigurator for type: " + aType);
-    if (this._configurators[aType] === undefined) {
-      let contractID =
-        "@mozilla.org/dom/system-messages/configurator/" + aType + ";1";
-      if (contractID in Cc) {
-        debug(contractID + " is registered, creating an instance");
-        this._configurators[aType] =
-          Cc[contractID].createInstance(Ci.nsISystemMessagesConfigurator);
-      } else {
-        debug(contractID + "is not registered, caching the answer");
-        this._configurators[aType] = null;
-      }
-    }
-    return this._configurators[aType] || defaultMessageConfigurator;
-  },
-
-  _cancelCpuWakeLock: function(aPageKey) {
-    let cpuWakeLock = this._cpuWakeLocks[aPageKey];
-    if (cpuWakeLock) {
-      debug("Releasing the CPU wake lock for page key = " + aPageKey);
-      cpuWakeLock.wakeLock.unlock();
-      cpuWakeLock.timer.cancel();
-      delete this._cpuWakeLocks[aPageKey];
-    }
-  },
-
-  _acquireCpuWakeLock: function(aPageKey) {
-    let cpuWakeLock = this._cpuWakeLocks[aPageKey];
-    if (!cpuWakeLock) {
-      // We have to ensure the CPU doesn't sleep during the process of the page
-      // handling the system messages, so that they can be handled on time.
-      debug("Acquiring a CPU wake lock for page key = " + aPageKey);
-      cpuWakeLock = this._cpuWakeLocks[aPageKey] = {
-        wakeLock: powerManagerService.newWakeLock("cpu"),
-        timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
-        lockCount: 1
-      };
-    } else {
-      // We've already acquired the CPU wake lock for this page,
-      // so just add to the lock count and extend the timeout.
-      cpuWakeLock.lockCount++;
-    }
-
-    // Set a watchdog to avoid locking the CPU wake lock too long,
-    // because it'd exhaust the battery quickly which is very bad.
-    // This could probably happen if the app failed to launch or
-    // handle the system messages due to any unexpected reasons.
-    cpuWakeLock.timer.initWithCallback(function timerCb() {
-      debug("Releasing the CPU wake lock because the system messages " +
-            "were not handled by its registered page before time out.");
-      this._cancelCpuWakeLock(aPageKey);
-    }.bind(this), 30000, Ci.nsITimer.TYPE_ONE_SHOT);
-  },
-
-  _releaseCpuWakeLock: function _releaseCpuWakeLock(aPageKey, aHandledCount) {
-    let cpuWakeLock = this._cpuWakeLocks[aPageKey];
-    if (cpuWakeLock) {
-      cpuWakeLock.lockCount -= aHandledCount;
-      if (cpuWakeLock.lockCount <= 0) {
-        debug("Unlocking the CPU wake lock now that the system messages " +
-              "have been successfully handled by its registered page.");
-        this._cancelCpuWakeLock(aPageKey);
-      }
-    }
-  },
-
-  _findPage: function(aType, aPageURL, aManifestURL) {
-    let page = null;
-    this._pages.some(function(aPage) {
-      if (this._isPageMatched(aPage, aType, aPageURL, aManifestURL)) {
-        page = aPage;
-      }
-      return page !== null;
-    }, this);
-    return page;
-  },
-
-  _findCacheForApp: function(aManifestURL) {
-    let cache = [];
-    this._pages.forEach(function(aPage) {
-      if (aPage.manifestURL === aManifestURL &&
-          aPage.pendingMessages.length != 0) {
-        cache.push({ type: aPage.type,
-                     pageURL: aPage.pageURL,
-                     manifestURL: aPage.manifestURL });
-      }
-    });
-    return cache;
-  },
-
-  sendMessage: function(aType, aMessage, aPageURI, aManifestURI, aExtra) {
-    return new Promise((aResolve, aReject) => {
-      this.sendMessageInternal(aType, aMessage, aPageURI, aManifestURI, aExtra,
-                               aResolve, aReject);
-    });
-  },
-
-  sendMessageInternal: function(aType, aMessage, aPageURI, aManifestURI,
-                                aExtra, aResolvePromiseCb, aRejectPromiseCb) {
-    // Buffer system messages until the webapps' registration is ready,
-    // so that we can know the correct pages registered to be sent.
-    if (!this._webappsRegistryReady) {
-      this._bufferedSysMsgs.push({ how: "send",
-                                   type: aType,
-                                   msg: aMessage,
-                                   pageURI: aPageURI,
-                                   manifestURI: aManifestURI,
-                                   extra: aExtra,
-                                   resolvePromiseCb: aResolvePromiseCb,
-                                   rejectPromiseCb: aRejectPromiseCb });
-      return;
-    }
-
-    // Give this message an ID so that we can identify the message and
-    // clean it up from the pending message queue when apps receive it.
-    let messageID = gUUIDGenerator.generateUUID().toString();
-    let manifestURL = aManifestURI.spec;
-
-    let pendingPromise = { resolvePromiseCb: aResolvePromiseCb,
-                           rejectPromiseCb: aRejectPromiseCb,
-                           manifestURL: manifestURL,
-                           counter: 0 };
-
-    let pageURLs = [];
-    if (aPageURI) {
-      pageURLs.push(aPageURI.spec);
-    } else {
-      // Send this message to all the registered pages of the app if |aPageURI|
-      // is not specified.
-      for (let i = 0; i < this._pages.length; i++) {
-        let page = this._pages[i];
-        if (page.type === aType && page.manifestURL === manifestURL) {
-          pageURLs.push(page.pageURL);
-        }
-      }
-    }
-
-    pageURLs.forEach(function(aPageURL) {
-      debug("Sending " + aType + " " + JSON.stringify(aMessage) +
-        " for " + aPageURL + " @ " + manifestURL +
-        '; extra: ' + JSON.stringify(aExtra));
-
-      let result = this._sendMessageCommon(aType,
-                                           aMessage,
-                                           messageID,
-                                           aPageURL,
-                                           manifestURL,
-                                           aExtra);
-      debug("Returned status of sending message: " + result);
-
-      if (result === MSG_SENT_FAILURE_PERM_DENIED) {
-        return;
-      }
-
-      // For each page we must receive a confirm.
-      ++pendingPromise.counter;
-
-    }, this);
-
-    if (pendingPromise.counter) {
-      this._pendingPromises.set(messageID, pendingPromise);
-    }
-  },
-
-  broadcastMessage: function(aType, aMessage, aExtra) {
-    // Buffer system messages until the webapps' registration is ready,
-    // so that we can know the correct pages registered to be broadcasted.
-    if (!this._webappsRegistryReady) {
-      this._bufferedSysMsgs.push({ how: "broadcast",
-                                   type: aType,
-                                   msg: aMessage,
-                                   extra: aExtra });
-      return Promise.resolve();
-    }
-
-    // Give this message an ID so that we can identify the message and
-    // clean it up from the pending message queue when apps receive it.
-    let messageID = gUUIDGenerator.generateUUID().toString();
-
-    debug("Broadcasting " + aType + " " + JSON.stringify(aMessage) +
-      '; extra = ' + JSON.stringify(aExtra));
-
-    let shouldDispatchFunc = this._getMessageConfigurator(aType).shouldDispatch;
-
-    if (!this._pages.length) {
-      return Promise.resolve();
-    }
-
-    // Find pages that registered a handler for this type.
-    let promises = [];
-    for (let i = 0; i < this._pages.length; i++) {
-      let promise = ((page) => {
-        return new Promise((resolve, reject) => {
-          if (page.type !== aType) {
-            resolve();
-            return;
-          }
-
-          let doDispatch = () => {
-            let result = this._sendMessageCommon(aType,
-                                                 aMessage,
-                                                 messageID,
-                                                 page.pageURL,
-                                                 page.manifestURL,
-                                                 aExtra);
-            debug("Returned status of sending message: " + result);
-            resolve();
-          };
-
-          if ('function' !== typeof shouldDispatchFunc) {
-            // If the configurator has no 'shouldDispatch' defined,
-            // always dispatch this message.
-            doDispatch();
-            return;
-          }
-
-          shouldDispatchFunc(page.manifestURL, page.pageURL, aType, aMessage, aExtra)
-            .then(aShouldDispatch => {
-              if (aShouldDispatch) {
-                doDispatch();
-              }
-            });
-        });
-      })(this._pages[i]);
-      promises.push(promise);
-    }
-
-    return Promise.all(promises);
-  },
-
-  registerPage: function(aType, aPageURI, aManifestURI) {
-    if (!aPageURI || !aManifestURI) {
-      throw Cr.NS_ERROR_INVALID_ARG;
-    }
-
-    let pageURL = aPageURI.spec;
-    let manifestURL = aManifestURI.spec;
-
-    // Don't register duplicates for this tuple.
-    let page = this._findPage(aType, pageURL, manifestURL);
-    if (page) {
-      debug("Ignoring duplicate registration of " +
-            [aType, pageURL, manifestURL]);
-      return;
-    }
-
-    this._pages.push({ type: aType,
-                       pageURL: pageURL,
-                       manifestURL: manifestURL,
-                       pendingMessages: [] });
-  },
-
-  refreshCache: function(aChildMM, aManifestURI) {
-    if (!aManifestURI) {
-      throw Cr.NS_ERROR_INVALID_ARG;
-    }
-    this._refreshCacheInternal(aChildMM, aManifestURI.spec);
-  },
-
-  _refreshCacheInternal: function(aChildMM, aManifestURL) {
-    let cache = this._findCacheForApp(aManifestURL);
-    aChildMM.sendAsyncMessage("SystemMessageCache:RefreshCache", cache);
-  },
-
-  _findTargetIndex: function(aTargets, aTarget) {
-    if (!aTargets || !aTarget) {
-      return -1;
-    }
-    for (let index = 0; index < aTargets.length; ++index) {
-      let target = aTargets[index];
-      if (target.target === aTarget) {
-        return index;
-      }
-    }
-    return -1;
-  },
-
-  _isEmptyObject: function(aObj) {
-    for (let name in aObj) {
-      return false;
-    }
-    return true;
-  },
-
-  _removeTargetFromListener: function(aTarget,
-                                      aManifestURL,
-                                      aRemoveListener,
-                                      aPageURL) {
-    let targets = this._listeners[aManifestURL];
-    if (!targets) {
-      return false;
-    }
-
-    let index = this._findTargetIndex(targets, aTarget);
-    if (index === -1) {
-      return false;
-    }
-
-    if (aRemoveListener) {
-      debug("remove the listener for " + aManifestURL);
-      delete this._listeners[aManifestURL];
-      return true;
-    }
-
-    let target = targets[index];
-    if (aPageURL && target.winCounts[aPageURL] !== undefined &&
-        --target.winCounts[aPageURL] === 0) {
-      delete target.winCounts[aPageURL];
-    }
-
-    if (this._isEmptyObject(target.winCounts)) {
-      if (targets.length === 1) {
-        // If it's the only one, get rid of the entry of manifest URL entirely.
-        debug("remove the listener for " + aManifestURL);
-        delete this._listeners[aManifestURL];
-      } else {
-        // If more than one left, remove this one and leave the rest.
-        targets.splice(index, 1);
-      }
-    }
-    return true;
-  },
-
-  receiveMessage: function(aMessage) {
-    let msg = aMessage.json;
-
-    // To prevent the hacked child process from sending commands to parent
-    // to manage system messages, we need to check its manifest URL.
-    if (["SystemMessageManager:Register",
-         // TODO: fix bug 988142 to re-enable.
-         // "SystemMessageManager:Unregister",
-         "SystemMessageManager:GetPendingMessages",
-         "SystemMessageManager:HasPendingMessages",
-         "SystemMessageManager:Message:Return:OK",
-         "SystemMessageManager:HandleMessagesDone",
-         "SystemMessageManager:HandleMessageDone"].indexOf(aMessage.name) != -1) {
-      if (!aMessage.target.assertContainApp(msg.manifestURL)) {
-        debug("Got message from a child process containing illegal manifest URL.");
-        return null;
-      }
-    }
-
-    switch(aMessage.name) {
-      case "SystemMessageManager:AskReadyToRegister":
-        return true;
-        break;
-      case "SystemMessageManager:Register":
-      {
-        debug("Got Register from " + msg.pageURL + " @ " + msg.manifestURL);
-        let pageURL = msg.pageURL;
-        let targets, index;
-        if (!(targets = this._listeners[msg.manifestURL])) {
-          let winCounts = {};
-          winCounts[pageURL] = 1;
-          this._listeners[msg.manifestURL] = [{ target: aMessage.target,
-                                                winCounts: winCounts }];
-        } else if ((index = this._findTargetIndex(targets,
-                                                  aMessage.target)) === -1) {
-          let winCounts = {};
-          winCounts[pageURL] = 1;
-          targets.push({ target: aMessage.target,
-                         winCounts: winCounts });
-        } else {
-          let winCounts = targets[index].winCounts;
-          if (winCounts[pageURL] === undefined) {
-            winCounts[pageURL] = 1;
-          } else {
-            winCounts[pageURL]++;
-          }
-        }
-
-        this._refreshCacheInternal(aMessage.target, msg.manifestURL);
-        debug("listeners for " + msg.manifestURL +
-              " innerWinID " + msg.innerWindowID);
-        break;
-      }
-      case "child-process-shutdown":
-      {
-        debug("Got child-process-shutdown from " + aMessage.target);
-        for (let manifestURL in this._listeners) {
-          // See if any processes in this manifest URL have this target.
-          this._removeTargetFromListener(aMessage.target,
-                                         manifestURL,
-                                         true,
-                                         null);
-
-          this._rejectPendingPromisesFromManifestURL(manifestURL);
-        }
-        break;
-      }
-      case "SystemMessageManager:Unregister":
-      {
-        debug("Got Unregister from " + aMessage.target +
-              " innerWinID " + msg.innerWindowID);
-        this._removeTargetFromListener(aMessage.target,
-                                       msg.manifestURL,
-                                       false,
-                                       msg.pageURL);
-        this._rejectPendingPromisesFromManifestURL(msg.manifestURL);
-        break;
-      }
-      case "SystemMessageManager:GetPendingMessages":
-      {
-        debug("received SystemMessageManager:GetPendingMessages " + msg.type +
-          " for " + msg.pageURL + " @ " + msg.manifestURL);
-
-        // This is a sync call used to return the pending messages for a page.
-        // Find the right page to get its corresponding pending messages.
-        let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
-        if (!page) {
-          return;
-        }
-
-        // Return the |msg| of each pending message.
-        let pendingMessages = [];
-        page.pendingMessages.forEach(function(aMessage) {
-          pendingMessages.push({ msg: aMessage.msg, msgID: aMessage.msgID });
-        });
-
-        // Clear the pending queue for this page. This is OK since we'll store
-        // pending messages in the content process (|SystemMessageManager|).
-        page.pendingMessages.length = 0;
-
-        // Send the array of pending messages.
-        aMessage.target
-                .sendAsyncMessage("SystemMessageManager:GetPendingMessages:Return",
-                                  { type: msg.type,
-                                    manifestURL: msg.manifestURL,
-                                    pageURL: msg.pageURL,
-                                    msgQueue: pendingMessages });
-        this._refreshCacheInternal(aMessage.target, msg.manifestURL);
-        break;
-      }
-      case "SystemMessageManager:HasPendingMessages":
-      {
-        debug("received SystemMessageManager:HasPendingMessages " + msg.type +
-              " for " + msg.pageURL + " @ " + msg.manifestURL);
-
-        // NB: Sync message SystemMessageManager:HasPendingMessages
-        // should only be used by in-process app. For out-of-process
-        // app, SystemMessageCache should be used.
-
-        // This is a sync call used to return if a page has pending messages.
-        // Find the right page to get its corresponding pending messages.
-        let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
-        if (!page) {
-          return false;
-        }
-
-        return page.pendingMessages.length != 0;
-        break;
-      }
-      case "SystemMessageManager:Message:Return:OK":
-      {
-        debug("received SystemMessageManager:Message:Return:OK " + msg.type +
-          " for " + msg.pageURL + " @ " + msg.manifestURL);
-
-        // We need to clean up the pending message since the app has already
-        // received it, thus avoiding the re-lanunched app handling it again.
-        let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
-        if (page) {
-          let pendingMessages = page.pendingMessages;
-          for (let i = 0; i < pendingMessages.length; i++) {
-            if (pendingMessages[i].msgID === msg.msgID) {
-              pendingMessages.splice(i, 1);
-              break;
-            }
-          }
-        }
-        break;
-      }
-      case "SystemMessageManager:HandleMessageDone":
-      {
-        debug("received SystemMessageManager:HandleMessageDone " + msg.type +
-          " with msgID " + msg.msgID + " for " + msg.pageURL +
-          " @ " + msg.manifestURL + " - promise rejected: " + msg.rejected);
-
-        // Maybe this should resolve/reject a pending promise.
-        if (msg.rejected) {
-          this._rejectPendingPromises(msg.msgID);
-        } else {
-          this._resolvePendingPromises(msg.msgID);
-        }
-
-        // A page has finished handling some of its system messages, so we try
-        // to release the CPU wake lock we acquired on behalf of that page.
-        this._releaseCpuWakeLock(this._createKeyForPage(msg), 1);
-        break;
-      }
-
-      case "SystemMessageManager:HandleMessagesDone":
-      {
-        debug("received SystemMessageManager:HandleMessagesDone " + msg.type +
-          " with " + msg.handledCount + " for " + msg.pageURL +
-          " @ " + msg.manifestURL);
-
-        // A page has finished handling some of its system messages, so we try
-        // to release the CPU wake lock we acquired on behalf of that page.
-        this._releaseCpuWakeLock(this._createKeyForPage(msg), msg.handledCount);
-        break;
-      }
-    }
-  },
-
-  observe: function(aSubject, aTopic, aData) {
-    switch (aTopic) {
-      case "xpcom-shutdown":
-        kMessages.forEach(function(aMsg) {
-          ppmm.removeMessageListener(aMsg, this);
-        }, this);
-        Services.obs.removeObserver(this, "xpcom-shutdown");
-        Services.obs.removeObserver(this, "webapps-registry-start");
-        Services.obs.removeObserver(this, "webapps-registry-ready");
-        Services.obs.removeObserver(this, "webapps-clear-data");
-        ppmm = null;
-        this._pages = null;
-        this._bufferedSysMsgs = null;
-        this._pendingPromises.clear();
-        break;
-      case "webapps-registry-start":
-        this._webappsRegistryReady = false;
-        break;
-      case "webapps-registry-ready":
-        // After the webapps' registration has been done for sure,
-        // re-fire the buffered system messages if there is any.
-        this._webappsRegistryReady = true;
-        this._bufferedSysMsgs.forEach(function(aSysMsg) {
-          switch (aSysMsg.how) {
-            case "send":
-              this.sendMessageInternal(
-                aSysMsg.type, aSysMsg.msg,
-                aSysMsg.pageURI, aSysMsg.manifestURI, aSysMsg.extra,
-                aSysMsg.resolvePromiseCb, aSysMsg.rejectPromiseCb);
-              break;
-            case "broadcast":
-              this.broadcastMessage(aSysMsg.type, aSysMsg.msg, aSysMsg.extra);
-              break;
-          }
-        }, this);
-        this._bufferedSysMsgs.length = 0;
-        break;
-      case "webapps-clear-data":
-        let params =
-          aSubject.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
-        if (!params) {
-          debug("Error updating registered pages for an uninstalled app.");
-          return;
-        }
-
-        // Only update registered pages for apps.
-        if (params.browserOnly) {
-          return;
-        }
-
-        let manifestURL = appsService.getManifestURLByLocalId(params.appId);
-        if (!manifestURL) {
-          debug("Error updating registered pages for an uninstalled app.");
-          return;
-        }
-
-        for (let i = this._pages.length - 1; i >= 0; i--) {
-          let page = this._pages[i];
-          if (page.manifestURL === manifestURL) {
-            this._pages.splice(i, 1);
-            debug("Remove " + page.pageURL + " @ " + page.manifestURL +
-                  " from registered pages due to app uninstallation.");
-          }
-        }
-
-        this._rejectPendingPromisesFromManifestURL(manifestURL);
-
-        debug("Finish updating registered pages for an uninstalled app.");
-        break;
-    }
-  },
-
-  _queueMessage: function(aPage, aMessage, aMessageID) {
-    // Queue the message for this page because we've never known if an app is
-    // opened or not. We'll clean it up when the app has already received it.
-    aPage.pendingMessages.push({ msg: aMessage, msgID: aMessageID });
-    if (aPage.pendingMessages.length > kMaxPendingMessages) {
-      aPage.pendingMessages.splice(0, 1);
-    }
-  },
-
-  _openAppPage: function(aPage, aMessage, aExtra, aMsgSentStatus) {
-    // This means the app must be brought to the foreground.
-    let showApp = this._getMessageConfigurator(aPage.type).mustShowRunningApp;
-
-    // We should send the open-app message if the system message was
-    // not sent, or if it was sent but we should show the app anyway.
-    if ((aMsgSentStatus === MSG_SENT_SUCCESS) && !showApp) {
-      return;
-    }
-
-    // This flag means the app must *only* be brought to the foreground
-    // and we don't need to load the app to handle messages.
-    let onlyShowApp = (aMsgSentStatus === MSG_SENT_SUCCESS) && showApp;
-
-    debug("Asking to open pageURL: " + aPage.pageURL +
-          ", manifestURL: " + aPage.manifestURL + ", type: " + aPage.type +
-          ", target: " + JSON.stringify(aMessage.target) +
-          ", showApp: " + showApp + ", onlyShowApp: " + onlyShowApp +
-          ", extra: " + JSON.stringify(aExtra));
-
-    let glue = Cc["@mozilla.org/dom/messages/system-message-glue;1"]
-                 .createInstance(Ci.nsISystemMessageGlue);
-    if (glue) {
-      glue.openApp(aPage.pageURL, aPage.manifestURL, aPage.type, aMessage.target,
-                   showApp, onlyShowApp, aExtra);
-    } else {
-      debug("Error! The UI glue component is not implemented.");
-    }
-  },
-
-  _isPageMatched: function(aPage, aType, aPageURL, aManifestURL) {
-    return (aPage.type === aType &&
-            aPage.manifestURL === aManifestURL &&
-            aPage.pageURL === aPageURL);
-  },
-
-  _createKeyForPage: function _createKeyForPage(aPage) {
-    let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
-                      .createInstance(Ci.nsIScriptableUnicodeConverter);
-    converter.charset = "UTF-8";
-
-    let hasher = Cc["@mozilla.org/security/hash;1"]
-                   .createInstance(Ci.nsICryptoHash);
-    hasher.init(hasher.SHA1);
-
-    // add manifest/page URL and action to the hash
-    ["type", "manifestURL", "pageURL"].forEach(function(aProp) {
-      let data = converter.convertToByteArray(aPage[aProp], {});
-      hasher.update(data, data.length);
-    });
-
-    return hasher.finish(true);
-  },
-
-  _sendMessageCommon: function(aType, aMessage, aMessageID,
-                               aPageURL, aManifestURL, aExtra) {
-    // Don't send the system message not granted by the app's permissions.
-    if (!SystemMessagePermissionsChecker
-          .isSystemMessagePermittedToSend(aType,
-                                          aPageURL,
-                                          aManifestURL)) {
-      return MSG_SENT_FAILURE_PERM_DENIED;
-    }
-
-    // Queue this message in the corresponding pages.
-    let page = this._findPage(aType, aPageURL, aManifestURL);
-    if (!page) {
-      debug("Message " + aType + " is not registered for " +
-            aPageURL + " @ " + aManifestURL);
-      return MSG_SENT_FAILURE_PERM_DENIED;
-    }
-    this._queueMessage(page, aMessage, aMessageID);
-
-    let appPageIsRunning = false;
-    let pageKey = this._createKeyForPage({ type: aType,
-                                           manifestURL: aManifestURL,
-                                           pageURL: aPageURL });
-
-    let cache = this._findCacheForApp(aManifestURL);
-    let targets = this._listeners[aManifestURL];
-    if (targets) {
-      for (let index = 0; index < targets.length; ++index) {
-        let target = targets[index];
-        let manager = target.target;
-
-        // Ensure hasPendingMessage cache is refreshed before we open app
-        manager.sendAsyncMessage("SystemMessageCache:RefreshCache", cache);
-
-        // We only need to send the system message to the targets (processes)
-        // which contain the window page that matches the manifest/page URL of
-        // the destination of system message.
-        if (target.winCounts[aPageURL] === undefined) {
-          continue;
-        }
-
-        appPageIsRunning = true;
-        // We need to acquire a CPU wake lock for that page and expect that
-        // we'll receive a "SystemMessageManager:HandleMessagesDone" or a
-        // "SystemMessageManager:HandleMessageDone"  message when the page
-        // finishes handling the system message. At that point, we'll release
-        // the lock we acquired.
-        this._acquireCpuWakeLock(pageKey);
-
-        // Multiple windows can share the same target (process), the content
-        // window needs to check if the manifest/page URL is matched. Only
-        // *one* window should handle the system message.
-        manager.sendAsyncMessage("SystemMessageManager:Message",
-                                 { type: aType,
-                                   msg: aMessage,
-                                   manifestURL: aManifestURL,
-                                   pageURL: aPageURL,
-                                   msgID: aMessageID });
-      }
-    }
-
-    let result = MSG_SENT_SUCCESS;
-    if (!appPageIsRunning) {
-      // The app page isn't running and relies on the 'open-app' chrome event to
-      // wake it up. We still need to acquire a CPU wake lock for that page and
-      // expect that we will receive a "SystemMessageManager:HandleMessagesDone"
-      // or a "SystemMessageManager:HandleMessageDone" message when the page
-      // finishes handling the system message with other pending messages. At
-      // that point, we'll release the lock we acquired.
-      result = MSG_SENT_FAILURE_APP_NOT_RUNNING;
-      this._acquireCpuWakeLock(pageKey);
-    }
-    this._openAppPage(page, aMessage, aExtra, result);
-    return result;
-  },
-
-  _resolvePendingPromises: function(aMessageID) {
-    if (!this._pendingPromises.has(aMessageID)) {
-      debug("Unknown pendingPromise messageID. This seems a bug!!");
-      return;
-    }
-
-    let obj = this._pendingPromises.get(aMessageID);
-    if (!--obj.counter) {
-      obj.resolvePromiseCb();
-      this._pendingPromises.delete(aMessageID);
-    }
-  },
-
-  _rejectPendingPromises: function(aMessageID) {
-    if (!this._pendingPromises.has(aMessageID)) {
-      debug("Unknown pendingPromise messageID. This seems a bug!!");
-      return;
-    }
-
-    let obj = this._pendingPromises.get(aMessageID);
-    if (!--obj.counter) {
-      obj.rejectPromiseCb();
-      this._pendingPromises.delete(aMessageID);
-    }
-  },
-
-  _rejectPendingPromisesFromManifestURL: function(aManifestURL) {
-    for (var [i, obj] of this._pendingPromises) {
-      if (obj.manifestURL == aManifestURL) {
-        obj.rejectPromiseCb();
-        this._pendingPromises.delete(i);
-      }
-    }
-  },
-
-  classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal,
-                                         Ci.nsIObserver])
-}
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageInternal]);
deleted file mode 100644
--- a/dom/messages/SystemMessageManager.js
+++ /dev/null
@@ -1,405 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-const kSystemMessageInternalReady = "system-message-internal-ready";
-
-XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-                                   "@mozilla.org/childprocessmessagemanager;1",
-                                   "nsISyncMessageSender");
-
-function debug(aMsg) {
-   // dump("-- SystemMessageManager " + Date.now() + " : " + aMsg + "\n");
-}
-
-// Implementation of the DOM API for system messages
-
-function SystemMessageManager() {
-  // If we have a system message handler registered for messages of type
-  // |type|, this._dispatchers[type] equals {handler, messages, isHandling},
-  // where
-  //  - |handler| is the message handler that the page registered,
-  //  - |messages| is a list of messages which we've received while
-  //    dispatching messages to the handler, but haven't yet sent, and
-  //  - |isHandling| indicates whether we're currently dispatching messages
-  //    to this handler.
-  this._dispatchers = {};
-
-  // Pending messages for this page, keyed by message type.
-  this._pendings = {};
-
-  // Flag to specify if this process has already registered the manifest URL.
-  this._registerManifestURLReady = false;
-
-  // Used to know if the promise has to be accepted or not.
-  this._isHandling = false;
-  this._promise = null;
-
-  // Flag to determine this process is a parent or child process.
-  let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-  this._isParentProcess =
-    !appInfo || appInfo.getService(Ci.nsIXULRuntime)
-                  .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-
-  // An oberver to listen to whether the |SystemMessageInternal| is ready.
-  if (this._isParentProcess) {
-    Services.obs.addObserver(this, kSystemMessageInternalReady, false);
-  }
-}
-
-SystemMessageManager.prototype = {
-  __proto__: DOMRequestIpcHelper.prototype,
-
-  _dispatchMessage: function(aType, aDispatcher, aMessage, aMessageID) {
-    if (aDispatcher.isHandling) {
-      // Queue up the incomming message if we're currently dispatching a
-      // message; we'll send the message once we finish with the current one.
-      //
-      // _dispatchMethod is reentrant because a page can spin up a nested
-      // event loop from within a system message handler (e.g. via alert()),
-      // and we can then try to send the page another message while it's
-      // inside this nested event loop.
-      aDispatcher.messages.push({ message: aMessage, messageID: aMessageID });
-      return;
-    }
-
-    aDispatcher.isHandling = true;
-    this._isHandling = true;
-
-    // We get a json blob, but in some cases we want another kind of object
-    // to be dispatched. To do so, we check if we have a valid contract ID of
-    // "@mozilla.org/dom/system-messages/wrapper/TYPE;1" component implementing
-    // nsISystemMessageWrapper.
-    debug("Dispatching " + JSON.stringify(aMessage) + "\n");
-    let contractID = "@mozilla.org/dom/system-messages/wrapper/" + aType + ";1";
-    let wrapped = false;
-
-    if (contractID in Cc) {
-      debug(contractID + " is registered, creating an instance");
-      let wrapper = Cc[contractID].createInstance(Ci.nsISystemMessagesWrapper);
-      if (wrapper) {
-        aMessage = wrapper.wrapMessage(aMessage, this._window);
-        wrapped = true;
-        debug("wrapped = " + aMessage);
-      }
-    }
-
-    let message = wrapped ? aMessage : Cu.cloneInto(aMessage, this._window);
-
-    let rejectPromise = false;
-    try {
-      aDispatcher.handler.handleMessage(message);
-    } catch(e) {
-      rejectPromise = true;
-    }
-
-    this._isHandling = false;
-    aDispatcher.isHandling = false;
-
-    let self = this;
-    function sendResponse() {
-      // We need to notify the parent one of the system messages has been
-      // handled, so the parent can release the CPU wake lock it took on our
-      // behalf.
-      cpmm.sendAsyncMessage("SystemMessageManager:HandleMessageDone",
-                            { type: aType,
-                              manifestURL: self._manifestURL,
-                              pageURL: self._pageURL,
-                              msgID: aMessageID,
-                              rejected: rejectPromise });
-    }
-
-    if (!this._promise) {
-      debug("No promise set, sending the response immediately.");
-      sendResponse();
-    } else {
-      debug("Using the promise to postpone the response.");
-      this._promise.then(sendResponse, function() {
-        rejectPromise = true;
-        sendResponse();
-      });
-      this._promise = null;
-    }
-
-    if (aDispatcher.messages.length > 0) {
-      let msg = aDispatcher.messages.shift();
-      this._dispatchMessage(aType, aDispatcher, msg.message, msg.messageID);
-    } else {
-      // No more messages that need to be handled, we can notify the
-      // ContentChild to release the CPU wake lock grabbed by the ContentParent
-      // (i.e. NewWakeLockOnBehalfOfProcess()) and reset the process's priority.
-      //
-      // TODO: Bug 874353 - Remove SystemMessageHandledListener in ContentParent
-      Services.obs.notifyObservers(/* aSubject */ null,
-                                   "handle-system-messages-done",
-                                   /* aData */ null);
-    }
-  },
-
-  mozSetMessageHandler: function(aType, aHandler) {
-    debug("set message handler for [" + aType + "] " + aHandler);
-
-    if (this._isInBrowserElement) {
-      debug("the app loaded in the browser cannot set message handler");
-      // Don't throw there, but ignore the registration.
-      return;
-    }
-
-    if (!aType) {
-      // Just bail out if we have no type.
-      return;
-    }
-
-    let dispatchers = this._dispatchers;
-    if (!aHandler) {
-      // Setting the dispatcher to null means we don't want to handle messages
-      // for this type anymore.
-      delete dispatchers[aType];
-      return;
-    }
-
-    // Last registered handler wins.
-    dispatchers[aType] = { handler: aHandler, messages: [], isHandling: false };
-
-    // Ask for the list of currently pending messages.
-    cpmm.sendAsyncMessage("SystemMessageManager:GetPendingMessages",
-                          { type: aType,
-                            pageURL: this._pageURL,
-                            manifestURL: this._manifestURL });
-  },
-
-  mozHasPendingMessage: function(aType) {
-    debug("asking pending message for [" + aType + "]");
-
-    if (this._isInBrowserElement) {
-      debug("the app loaded in the browser cannot ask pending message");
-      // Don't throw there, but pretend to have no messages available.
-      return false;
-    }
-
-    // If we have a handler for this type, we can't have any pending message.
-    if (aType in this._dispatchers) {
-      return false;
-    }
-
-
-    // Use SystemMessageManager directly when we are in the same process.
-    if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT) {
-      return cpmm.sendSyncMessage("SystemMessageManager:HasPendingMessages",
-                                  { type: aType,
-                                    pageURL: this._pageURL,
-                                    manifestURL: this._manifestURL })[0];
-    }
-
-    /*
-     * NB: If the system message is fired after we received the cache
-     *     and before we registered the pageURL we will get false
-     *     negative however this is unlikely and will do no harm.
-     */
-    let cache = Cc["@mozilla.org/system-message-cache;1"]
-                  .getService(Ci.nsISystemMessageCache);
-
-    return cache.hasPendingMessage(aType, this._pageURL, this._manifestURL);
-  },
-
-  mozIsHandlingMessage: function() {
-    debug("is handling message: " + this._isHandling);
-    return this._isHandling;
-  },
-
-  mozSetMessageHandlerPromise: function(aPromise) {
-    debug("setting a promise");
-
-    if (!this._isHandling) {
-      throw "Not in a handleMessage method";
-    }
-
-    if (this._promise) {
-      throw "Promise already set";
-    }
-
-    this._promise = aPromise;
-  },
-
-  uninit: function()  {
-    this._dispatchers = null;
-    this._pendings = null;
-    this._promise = null;
-
-    if (this._isParentProcess) {
-      Services.obs.removeObserver(this, kSystemMessageInternalReady);
-    }
-
-    if (this._isInBrowserElement) {
-      debug("the app loaded in the browser doesn't need to unregister " +
-            "the manifest URL for listening to the system messages");
-      return;
-    }
-
-    cpmm.sendAsyncMessage("SystemMessageManager:Unregister",
-                          { manifestURL: this._manifestURL,
-                            pageURL: this._pageURL,
-                            innerWindowID: this.innerWindowID });
-  },
-
-  // Possible messages:
-  //
-  //   - SystemMessageManager:Message
-  //     This one will only be received when the child process is alive when
-  //     the message is initially sent.
-  //
-  //   - SystemMessageManager:GetPendingMessages:Return
-  //     This one will be received when the starting child process wants to
-  //     retrieve the pending system messages from the parent (i.e. after
-  //     sending SystemMessageManager:GetPendingMessages).
-  receiveMessage: function(aMessage) {
-    let msg = aMessage.data;
-    debug("receiveMessage " + aMessage.name + " for [" + msg.type + "] " +
-          "with manifest URL = " + msg.manifestURL +
-          " and page URL = " + msg.pageURL);
-
-    // Multiple windows can share the same target (process), the content
-    // window needs to check if the manifest/page URL is matched. Only
-    // *one* window should handle the system message.
-    if (msg.manifestURL !== this._manifestURL ||
-        msg.pageURL !== this._pageURL) {
-      debug("This page shouldn't handle the messages because its " +
-            "manifest URL = " + this._manifestURL +
-            " and page URL = " + this._pageURL);
-      return;
-    }
-
-    let messages = (aMessage.name == "SystemMessageManager:Message")
-                   ? [{ msg: msg.msg, msgID: msg.msgID }]
-                   : msg.msgQueue;
-
-    // We only dispatch messages when a handler is registered.
-    let dispatcher = this._dispatchers[msg.type];
-    if (dispatcher) {
-      if (aMessage.name == "SystemMessageManager:Message") {
-        // Send an acknowledgement to parent to clean up the pending message
-        // before we dispatch the message to apps, so a re-launched app won't
-        // handle it again, which is redundant.
-        cpmm.sendAsyncMessage("SystemMessageManager:Message:Return:OK",
-                              { type: msg.type,
-                                manifestURL: this._manifestURL,
-                                pageURL: this._pageURL,
-                                msgID: msg.msgID });
-      }
-
-      messages.forEach(function(aMsg) {
-        this._dispatchMessage(msg.type, dispatcher, aMsg.msg, aMsg.msgID);
-      }, this);
-
-    } else {
-      // Since no handlers are registered, we need to notify the parent as if
-      // all the queued system messages have been handled (notice |handledCount:
-      // messages.length|), so the parent can release the CPU wake lock it took
-      // on our behalf.
-      cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
-                            { type: msg.type,
-                              manifestURL: this._manifestURL,
-                              pageURL: this._pageURL,
-                              handledCount: messages.length });
-
-      // We also need to notify the ContentChild to release the CPU wake lock
-      // grabbed by the ContentParent (i.e. NewWakeLockOnBehalfOfProcess()) and
-      // reset the process's priority.
-      //
-      // TODO: Bug 874353 - Remove SystemMessageHandledListener in ContentParent
-      Services.obs.notifyObservers(/* aSubject */ null,
-                                   "handle-system-messages-done",
-                                   /* aData */ null);
-    }
-  },
-
-  // nsIDOMGlobalPropertyInitializer implementation.
-  init: function(aWindow) {
-    debug("init");
-    this.initDOMRequestHelper(aWindow,
-                              ["SystemMessageManager:Message",
-                               "SystemMessageManager:GetPendingMessages:Return"]);
-
-    let principal = aWindow.document.nodePrincipal;
-
-    // After bug 1238160, the principal no longer knows how to answer "is this a
-    // browser element", which is really what this code path wants. Currently,
-    // desktop is the only platform where we intend to disable isolation on a
-    // browser frame, so non-desktop should be able to assume that
-    // inIsolatedMozBrowser is true for all mozbrowser frames.  Additionally,
-    // this system message API is disabled on desktop behind the pref
-    // "dom.sysmsg.enabled".   We use a release assertion in
-    // nsFrameLoader::OwnerIsIsolatedMozBrowserFrame so that platforms with apps
-    // can assume inIsolatedMozBrowser is true for all mozbrowser frames.
-    this._isInBrowserElement = principal.isInIsolatedMozBrowserElement;
-    this._pageURL = principal.URI.spec;
-
-    let appsService = Cc["@mozilla.org/AppsService;1"]
-                        .getService(Ci.nsIAppsService);
-    this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
-
-    // Two cases are valid to register the manifest URL for the current process:
-    // 1. This is asked by a child process (parent process must be ready).
-    // 2. Parent process has already constructed the |SystemMessageInternal|.
-    // Otherwise, delay to do it when the |SystemMessageInternal| is ready.
-    let readyToRegister = true;
-    if (this._isParentProcess) {
-      let ready = cpmm.sendSyncMessage(
-        "SystemMessageManager:AskReadyToRegister", null);
-      if (ready.length == 0 || !ready[0]) {
-        readyToRegister = false;
-      }
-    }
-    if (readyToRegister) {
-      this._registerManifestURL();
-    }
-
-    debug("done");
-  },
-
-  observe: function(aSubject, aTopic, aData) {
-    if (aTopic === kSystemMessageInternalReady) {
-      this._registerManifestURL();
-    }
-
-    // Call the DOMRequestIpcHelper.observe method.
-    this.__proto__.__proto__.observe.call(this, aSubject, aTopic, aData);
-  },
-
-  _registerManifestURL: function() {
-    if (this._isInBrowserElement) {
-      debug("the app loaded in the browser doesn't need to register " +
-            "the manifest URL for listening to the system messages");
-      return;
-    }
-
-    if (!this._registerManifestURLReady) {
-      cpmm.sendAsyncMessage("SystemMessageManager:Register",
-                            { manifestURL: this._manifestURL,
-                              pageURL: this._pageURL,
-                              innerWindowID: this.innerWindowID });
-
-      this._registerManifestURLReady = true;
-    }
-  },
-
-  classID: Components.ID("{bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMNavigatorSystemMessages,
-                                         Ci.nsIDOMGlobalPropertyInitializer,
-                                         Ci.nsIObserver,
-                                         Ci.nsISupportsWeakReference])
-}
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageManager]);
deleted file mode 100644
--- a/dom/messages/SystemMessageManager.manifest
+++ /dev/null
@@ -1,8 +0,0 @@
-component {bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2} SystemMessageManager.js
-contract @mozilla.org/system-message-manager;1 {bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}
-
-component {70589ca5-91ac-4b9e-b839-d6a88167d714} SystemMessageInternal.js
-contract @mozilla.org/system-message-internal;1 {70589ca5-91ac-4b9e-b839-d6a88167d714}
-
-component {5a19d86a-21e5-4ac8-9634-8c364c73f87f} SystemMessageCache.js
-contract @mozilla.org/system-message-cache;1 {5a19d86a-21e5-4ac8-9634-8c364c73f87f}
deleted file mode 100644
--- a/dom/messages/SystemMessagePermissionsChecker.jsm
+++ /dev/null
@@ -1,253 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/AppsUtils.jsm");
-Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
-Cu.import("resource://gre/modules/PermissionsTable.jsm");
-Cu.import("resource://gre/modules/PermissionSettings.jsm");
-
-this.EXPORTED_SYMBOLS = ["SystemMessagePermissionsChecker",
-                         "SystemMessagePermissionsTable"];
-
-function debug(aStr) {
-  // dump("SystemMessagePermissionsChecker.jsm: " + aStr + "\n");
-}
-
-// This table maps system message to permission(s), indicating only
-// the system messages granted by the page's permissions are allowed
-// to be registered or sent to that page. Note the empty permission
-// set means this type of system message is always permitted.
-
-this.SystemMessagePermissionsTable = {
-  "activity": { },
-  "alarm": {
-    "alarms": []
-  },
-  "bluetooth-dialer-command": {
-    "telephony": []
-  },
-  "bluetooth-cancel": {
-    "bluetooth": []
-  },
-  "bluetooth-hid-status-changed": {
-    "bluetooth": []
-  },
-  "bluetooth-pairing-request": {
-    "bluetooth": []
-  },
-  "bluetooth-opp-transfer-complete": {
-    "bluetooth": []
-  },
-  "bluetooth-opp-update-progress": {
-    "bluetooth": []
-  },
-  "bluetooth-opp-receiving-file-confirmation": {
-    "bluetooth": []
-  },
-  "bluetooth-opp-transfer-start": {
-    "bluetooth": []
-  },
-  "cellbroadcast-received": {
-    "cellbroadcast": []
-  },
-  "captive-portal": {
-    "wifi-manage": []
-  },
-  "dummy-system-message": { }, // for system message testing framework
-  "dummy-system-message2": { }, // for system message testing framework
-  "headset-button": { },
-  "icc-stkcommand": {
-    "settings": ["read", "write"]
-  },
-  "media-button": { },
-  "networkstats-alarm": {
-    "networkstats-manage": []
-  },
-  "notification": {
-    "desktop-notification": []
-  },
-  "push": {
-  	"push": []
-  },
-  "push-register": {
-  	"push": []
-  },
-  "request-sync": { },
-  "sms-delivery-success": {
-    "sms": []
-  },
-  "sms-delivery-error": {
-    "sms": []
-  },
-  "sms-read-success": {
-    "sms": []
-  },
-  "sms-received": {
-    "sms": []
-  },
-  "sms-sent": {
-    "sms": []
-  },
-  "sms-failed": {
-    "sms": []
-  },
-  "telephony-new-call": {
-    "telephony": []
-  },
-  "telephony-call-ended": {
-    "telephony": []
-  },
-  "ussd-received": {
-    "mobileconnection": []
-  },
-  "wappush-received": {
-    "wappush": []
-  },
-  "cdma-info-rec-received": {
-    "mobileconnection": []
-  },
-  "nfc-hci-event-transaction": {
-    "nfc-hci-events": []
-  },
-  "nfc-manager-tech-discovered": {
-    "nfc-manager": []
-  },
-  "nfc-manager-tech-lost": {
-    "nfc-manager": []
-  },
-  "nfc-manager-send-file": {
-    "nfc-manager": []
-  },
-  "wifip2p-pairing-request": {
-    "wifi-manage": []
-  },
-  "first-run-with-sim": {
-    "settings": ["read", "write"]
-  },
-  "audiochannel-interruption-begin" : {},
-  "audiochannel-interruption-ended" : {}
-};
-
-
-this.SystemMessagePermissionsChecker = {
-  /**
-   * Return all the needed permission names for the given system message.
-   * @param string aSysMsgName
-   *        The system messsage name.
-   * @returns object
-   *        Format: { permName (string): permNamesWithAccess (string array), ... }
-   *        Ex, { "settings": ["settings-read", "settings-write"], ... }.
-   *        Note: an empty object will be returned if it's always permitted.
-   * @returns null
-   *        Return and report error when any unexpected error is ecountered.
-   *        Ex, when the system message we want to search is not included.
-   **/
-  getSystemMessagePermissions: function getSystemMessagePermissions(aSysMsgName) {
-    debug("getSystemMessagePermissions(): aSysMsgName: " + aSysMsgName);
-
-    let permNames = SystemMessagePermissionsTable[aSysMsgName];
-    if (permNames === undefined) {
-      debug("'" + aSysMsgName + "' is not associated with permissions. " +
-            "Please add them to the SystemMessage[Prefix]PermissionsTable.");
-      return null;
-    }
-
-    let object = { };
-    for (let permName in permNames) {
-      if (PermissionsTable[permName] === undefined) {
-        debug("'" + permName + "' for '" + aSysMsgName + "' is invalid. " +
-              "Please correct it in the SystemMessage[Prefix]PermissionsTable.");
-        return null;
-      }
-
-      // Construct a new permission name array by adding the access suffixes.
-      let access = permNames[permName];
-      if (!access || !Array.isArray(access)) {
-        debug("'" + permName + "' is not associated with access array. " +
-              "Please correct it in the SystemMessage[Prefix]PermissionsTable.");
-        return null;
-      }
-      object[permName] = appendAccessToPermName(permName, access);
-    }
-    return object
-  },
-
-  /**
-   * Check if the system message is permitted to be registered for the given
-   * app at start-up based on the permissions claimed in the app's manifest.
-   * @param string aSysMsgName
-   *        The system messsage name.
-   * @param string aManifestURL
-   *        The app's manifest URL.
-   * @param string aOrigin
-   *        The app's origin.
-   * @param object aManifest
-   *        The app's manifest.
-   * @returns bool
-   *        Is permitted or not.
-   **/
-  isSystemMessagePermittedToRegister: function (aSysMsgName,
-                                                aManifestURL,
-                                                aOrigin,
-                                                aManifest) {
-    // Test if the launch path of the app has the right permission.
-    let newManifest = new ManifestHelper(aManifest, aOrigin, aManifestURL);
-    let launchUrl = newManifest.fullLaunchPath();
-    return this.isSystemMessagePermittedToSend(aSysMsgName,
-                                               launchUrl,
-                                               aManifestURL);
-  },
-
-  /**
-   * Check if the system message is permitted to be sent to the given
-   * app's page at run-time based on the current app's permissions.
-   * @param string aSysMsgName
-   *        The system messsage name.
-   * @param string aPageURL
-   *        The app's page URL.
-   * @param string aManifestURL
-   *        The app's manifest URL.
-   * @returns bool
-   *        Is permitted or not.
-   **/
-  isSystemMessagePermittedToSend:
-    function isSystemMessagePermittedToSend(aSysMsgName, aPageURL, aManifestURL) {
-    debug("isSystemMessagePermittedToSend(): " +
-          "aSysMsgName: " + aSysMsgName + ", " +
-          "aPageURL: " + aPageURL + ", " +
-          "aManifestURL: " + aManifestURL);
-
-    let permNames = this.getSystemMessagePermissions(aSysMsgName);
-    if (permNames === null) {
-      return false;
-    }
-
-    let pageURI = Services.io.newURI(aPageURL, null, null);
-    for (let permName in permNames) {
-      let permNamesWithAccess = permNames[permName];
-
-      // Early return false as soon as any permission is not matched.
-      for (let idx in permNamesWithAccess) {
-        if(PermissionSettingsModule.getPermission(permNamesWithAccess[idx],
-                                                  aManifestURL,
-                                                  pageURI.prePath,
-                                                  false) != "allow") {
-          debug("'" + aSysMsgName + "' isn't permitted by '" + permName + "'. " +
-                "Please add the permission for app: '" + pageURI.prePath + "'.");
-          return false;
-        }
-      }
-    }
-
-    // All the permissions needed for this system message are matched.
-    return true;
-  }
-};
deleted file mode 100644
--- a/dom/messages/interfaces/moz.build
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-XPIDL_SOURCES += [
-    'nsIDOMNavigatorSystemMessages.idl',
-    'nsISystemMessageCache.idl',
-    'nsISystemMessageGlue.idl',
-    'nsISystemMessagesInternal.idl',
-]
-
-XPIDL_MODULE = 'dom_messages'
-
deleted file mode 100644
--- a/dom/messages/interfaces/nsIDOMNavigatorSystemMessages.idl
+++ /dev/null
@@ -1,24 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-[scriptable, function, uuid(42692976-57fd-4bb4-ab95-2b97ebdc5056)]
-interface nsIDOMSystemMessageCallback : nsISupports
-{
-    void handleMessage(in jsval message);
-};
-
-[scriptable, uuid(d04d3c11-26aa-46eb-a981-353af101f9cf)]
-interface nsIDOMNavigatorSystemMessages : nsISupports
-{
-    void mozSetMessageHandler(in DOMString type, in nsIDOMSystemMessageCallback callback);
-
-    boolean mozHasPendingMessage(in DOMString type); 
-
-    // the parameter is a promise object.
-    void mozSetMessageHandlerPromise(in nsISupports promise);
-
-    bool mozIsHandlingMessage();
-};
deleted file mode 100644
--- a/dom/messages/interfaces/nsISystemMessageCache.idl
+++ /dev/null
@@ -1,13 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-[scriptable, uuid(e888447c-6d4d-4045-92bd-1a5985404375)]
-interface nsISystemMessageCache : nsISupports
-{
-  boolean hasPendingMessage(in DOMString type,
-                            in DOMString pageURL,
-                            in DOMString manifestURL);
-};
deleted file mode 100644
--- a/dom/messages/interfaces/nsISystemMessageGlue.idl
+++ /dev/null
@@ -1,31 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-// Implemented by the contract id @mozilla.org/dom/messages/system-message-glue;1
-
-[scriptable, uuid(b5d98286-e7cc-11e3-92fb-74d02b97e723)]
-interface nsISystemMessageGlue : nsISupports
-{
-    /* Notify the system app to open the target app.
-     *
-     * @param pageURL     The URL of the page that will be opened.
-     * @param manifestURL The webapp's manifest URL.
-     * @param type        The message type.
-     * @param target      The target which the message is associated with.
-     * @param showApp     This flag indicates the app must be brought to the
-     *                    foreground.
-     * @param onlyShowApp This flag indicates the app must be *only* brought to
-     *                    the foreground without loading to handle messages.
-     * @param extra       Extra opaque info to pass around for opening the page.
-     */
-    void openApp(in DOMString pageURL,
-                 in DOMString manifestURL,
-                 in DOMString type,
-                 in jsval target,
-                 in boolean showApp,
-                 in boolean onlyShowApp,
-                 [optional] in jsval extra);
-};
deleted file mode 100644
--- a/dom/messages/interfaces/nsISystemMessagesInternal.idl
+++ /dev/null
@@ -1,90 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-interface nsIURI;
-interface nsIDOMWindow;
-interface nsIMessageSender;
-
-// Implemented by the contract id @mozilla.org/system-message-internal;1
-
-[scriptable, uuid(59b6beda-f911-4d47-a296-8c81e6abcfb9)]
-interface nsISystemMessagesInternal : nsISupports
-{
-  /*
-   * Allow any internal user to send a message of a given type to a given page
-   * of an app. The message will be sent to all the registered pages of the app
-   * when |pageURI| is not specified.
-   * @param type        The type of the message to be sent.
-   * @param message     The message payload.
-   * @param pageURI     The URI of the page that will be opened. Nullable.
-   * @param manifestURI The webapp's manifest URI.
-   * @param extra       Extra opaque information that will be passed around in the observer
-   *                    notification to open the page.
-   * returns a Promise
-   */
-  nsISupports sendMessage(in DOMString type, in jsval message,
-                          in nsIURI pageURI, in nsIURI manifestURI,
-                          [optional] in jsval extra);
-
-  /*
-   * Allow any internal user to broadcast a message of a given type.
-   * The application that registers the message will be launched.
-   * @param type        The type of the message to be sent.
-   * @param message     The message payload.
-   * @param extra       Extra opaque information that will be passed around in the observer
-   *                    notification to open the page.
-   * returns a Promise
-   */
-  nsISupports broadcastMessage(in DOMString type, in jsval message,
-                               [optional] in jsval extra);
-
-  /*
-   * Registration of a page that wants to be notified of a message type.
-   * @param type          The message type.
-   * @param pageURI       The URI of the page that will be opened.
-   * @param manifestURI   The webapp's manifest URI.
-   */
-  void registerPage(in DOMString type, in nsIURI pageURI, in nsIURI manifestURI);
-
-  /*
-   * Refresh the system message cache in a content process.
-   * @param manifestURI The webapp's manifest URI.
-   */
-  void refreshCache(in nsIMessageSender childMM, in nsIURI manifestURI);
-};
-
-[scriptable, uuid(002f0e82-91f0-41de-ad43-569a2b9d12df)]
-interface nsISystemMessagesWrapper: nsISupports
-{
-  /*
-   * Wrap a message and gives back any kind of object.
-   * @param message  The json blob to wrap.
-   */
-  jsval wrapMessage(in jsval message, in nsIDOMWindow window);
-};
-
-/*
- * Implements an interface to allow specific message types to
- * configure some behaviors
- */
-[scriptable, uuid(31b78730-21c6-11e4-8c21-0800200c9a66)]
-interface nsISystemMessagesConfigurator: nsISupports
-{
-  /*
-   * Will be true if this type of system messages assumes/requires
-   * that the app will be brought to the front always.
-   */
-  readonly attribute boolean mustShowRunningApp;
-
-  /*
-   * A broadcast filter for a specific message type.
-   *
-   * @return Promise which resolves with |true| or |false| to indicate if
-   *         we want to dispatch this message.
-   */
-  jsval shouldDispatch(in DOMString manifestURL, in DOMString pageURL,
-                       in DOMString type, in jsval message, [optional] in jsval extra);
-};
deleted file mode 100644
--- a/dom/messages/moz.build
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DIRS += ['interfaces']
-
-EXTRA_COMPONENTS += [
-    'SystemMessageCache.js',
-    'SystemMessageInternal.js',
-    'SystemMessageManager.js',
-    'SystemMessageManager.manifest',
-]
-
-EXTRA_JS_MODULES += [
-    'SystemMessagePermissionsChecker.jsm',
-]
-
-MOCHITEST_MANIFESTS += ['test/mochitest.ini']
-MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
deleted file mode 100644
--- a/dom/messages/test/chrome.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[DEFAULT]
-skip-if = e10s
-support-files =
-  file_hasPendingMessage.html
-  invalid_manifest.webapp
-  invalid_manifest.webapp^headers^
-  manifest.webapp
-  manifest.webapp^headers^
-
-[test_hasPendingMessage.html]
-skip-if = buildapp != "browser"
-[test_sysmsg_registration.html]
-skip-if = buildapp != 'mulet'
deleted file mode 100644
--- a/dom/messages/test/file_hasPendingMessage.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-  <head>
-    <script type="application/javascript;version=1.8">
-      "use strict";
-      if (navigator.mozHasPendingMessage("dummy-system-message")) {
-        alert("before load");
-      }
-      window.addEventListener("load", e => {
-        if (navigator.mozHasPendingMessage("dummy-system-message")) {
-          alert("load");
-        }
-      });
-      window.addEventListener("hashchange", e => {
-        switch (window.location.hash) {
-          case "#checkPendingMessages":
-            if (navigator.mozHasPendingMessage("dummy-system-message2")) {
-              alert("after launch");
-            }
-            break;
-          case "#setMessageHandler":
-            navigator.mozSetMessageHandler("dummy-system-message", () => {
-              alert("handle message");
-              if (!navigator.mozHasPendingMessage("dummy-system-message")) {
-                alert("no hasPendingMessages");
-              }
-            });
-            break;
-          case "#setMessageHandler2":
-            navigator.mozSetMessageHandler("dummy-system-message2", () => {
-              alert("handle message");
-              if (!navigator.mozHasPendingMessage("dummy-system-message2")) {
-                alert("no hasPendingMessages");
-              }
-            });
-            break;
-        }
-      });
-    </script>
-  </head>
-</html>
deleted file mode 100644
--- a/dom/messages/test/invalid_manifest.webapp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "name": "Random app",
-  "launch_path": "/index.html",
-  "messages": [{
-    "dummy-system-message": "/index.html",
-    "dummy-system-message2": "/index.html"
-  }]
-}
deleted file mode 100644
--- a/dom/messages/test/invalid_manifest.webapp^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: application/manifest+json
deleted file mode 100644
--- a/dom/messages/test/manifest.webapp
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "name": "Random app",
-  "launch_path": "/index.html",
-  "messages": [{
-    "dummy-system-message": "/index.html"
-  }, {
-    "dummy-system-message2": "/index.html"
-  }]
-}
deleted file mode 100644
--- a/dom/messages/test/manifest.webapp^headers^
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: application/manifest+json
deleted file mode 100644
--- a/dom/messages/test/mochitest.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[DEFAULT]
-support-files =
-  system_message_chrome_script.js
-
-[test_bug_993732.html]
-skip-if =  (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
deleted file mode 100644
--- a/dom/messages/test/system_message_chrome_script.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-'use strict';
-
-var { classes: Cc, interfaces: Ci } = Components;
-
-const systemMessenger = Cc["@mozilla.org/system-message-internal;1"]
-                          .getService(Ci.nsISystemMessagesInternal);
-const ioService = Cc["@mozilla.org/network/io-service;1"]
-                    .getService(Ci.nsIIOService);
-
-addMessageListener("trigger-register-page", function(aData) {
-  systemMessenger.registerPage(aData.type,
-                               ioService.newURI(aData.pageURL, null, null),
-                               ioService.newURI(aData.manifestURL, null, null));
-  sendAsyncMessage("page-registered");
-});
deleted file mode 100644
--- a/dom/messages/test/test_bug_993732.html
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test Bug 993732</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  // The syndrome of Bug 993732 is that the running app (either foreground or background)
-  // is not able to receive system messages. Even worse, the app will be killed when the
-  // listening system message is broadcast. So this test case uses the alarm message
-  // to test if a running app can receive the system message.
-
-  function registerPage() {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('system_message_chrome_script.js'));
-    gScript.addMessageListener("page-registered", function pageRegisteredHandler() {
-      gScript.removeMessageListener("page-registered", pageRegisteredHandler);
-      gScript.destroy();
-      testAlarm(10000);
-    });
-
-    gScript.sendAsyncMessage("trigger-register-page",
-                             { type: "alarm",
-                               manifestURL: window.location.origin + "/manifest.webapp",
-                               pageURL: window.location.href });
-  }
-
-  function testAlarm(aMillisecondsFromNow) {
-    var at = new Date();
-    at.setTime(at.getTime() + aMillisecondsFromNow);
-
-    navigator.mozSetMessageHandler('alarm', function(message) {
-      ok(true, "We got alarm message!");
-      SimpleTest.finish();
-    });
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(at, "honorTimezone", {});
-    } catch (e) {
-      ok(false,
-         "Unexpected exception while adding alarm " + aMillisecondsFromNow + " ms from now.");
-      SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      // Waiting for alarm message.
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm.");
-      SimpleTest.finish();
-    };
-  }
-
-  function startTests() {
-
-    SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
-      // Currently applicable only on FxOS
-      if (navigator.userAgent.indexOf("Mobile") != -1 &&
-          navigator.appVersion.indexOf("Android") == -1)
-      {
-        registerPage();
-      } else {
-        ok(true, "mozAlarms on Firefox OS only.");
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPermissions([{'type': 'alarms', 'allow': true, 'context': document}], startTests);
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/messages/test/test_hasPendingMessage.html
+++ /dev/null
@@ -1,110 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test navigator.mozHasPendingMessage</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-  <script type="application/javascript;version=1.8">
-    "use strict";
-
-    const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
-    Cu.import("resource://gre/modules/Services.jsm");
-    Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-    SimpleTest.waitForExplicitFinish();
-
-    function expectAlert(iframe, message, assertion) {
-      return new Promise((resolve, reject) => {
-        iframe.addEventListener("mozbrowsershowmodalprompt", function cb(e) {
-          iframe.removeEventListener("mozbrowsershowmodalprompt", cb);
-          is(e.detail.message, message, assertion);
-          resolve();
-        });
-      });
-    }
-
-    function runTest(isRemote) {
-      return new Promise((finish, reject) => {
-        let testURL = "http://mochi.test:8888/chrome/dom/messages/test/file_hasPendingMessage.html";
-        let manifestURL = "http://example.org/manifest.webapp";
-        let testURI = Services.io.newURI(testURL, null, null);
-        let manifestURI = Services.io.newURI(manifestURL, null, null);
-        let body = document.getElementsByTagName("body")[0];
-        let test_frame = document.createElement("iframe");
-        test_frame.setAttribute("mozbrowser", "true");
-        test_frame.setAttribute("remote", isRemote);
-        test_frame.setAttribute("src", testURL);
-        test_frame.setAttribute("mozapp", manifestURL);
-
-        // Step 0. Register Page or install app
-        let smi = Cc["@mozilla.org/system-message-internal;1"]
-                  .getService(Ci.nsISystemMessagesInternal);
-        smi.registerPage("dummy-system-message", testURI, manifestURI);
-        smi.registerPage("dummy-system-message2", testURI, manifestURI);
-        // XXX lie to SystemMessageInternal to unblock sendMessage
-        Services.obs.notifyObservers(null, "webapps-registry-ready", null);
-        // Step 1. Send system message
-        smi.sendMessage("dummy-system-message", null, testURI, manifestURI);
-        // Step 2. Run app & check hasPendingMessages
-        body.appendChild(test_frame);
-        expectAlert(test_frame, "before load", "hasPendingMessages before load").then(() => {
-          // Step 3. Wait load & check hasPendingMessages
-          return expectAlert(test_frame, "load", "hasPendingMessages after load");
-        }).then(() => {
-          // Step 4. Send second system message
-          smi.sendMessage("dummy-system-message2", null, testURI, manifestURI);
-          // Step 5. Check hasPendingMessages
-          test_frame.src = testURL + "#checkPendingMessages";
-          return expectAlert(test_frame, "after launch", "hasPendingMessages after app launch");
-        }).then(() => {
-          // Step 6. mozSetMessageHandler
-          test_frame.src = testURL + "#setMessageHandler";
-          return expectAlert(test_frame, "handle message", "message handled");
-        }).then(() => {
-          // Setp 7. Check hasPendingMessages
-          return expectAlert(test_frame, "no hasPendingMessages",
-                             "no hasPendingMessages after mozSetMessageHandler");
-        }).then(() => {
-          // Step 6. mozSetMessageHandler2
-          test_frame.src = testURL + "#setMessageHandler2";
-          return expectAlert(test_frame, "handle message", "message handled");
-        }).then(() => {
-          // Step 7. Check hasPendingMessages2
-          return expectAlert(test_frame, "no hasPendingMessages",
-                             "no hasPendingMessages after mozSetMessageHandler");
-        }).then(() => {
-          // Be nice with the rest of the tests and clean up what we registered.
-          let appsSvc = Cc["@mozilla.org/AppsService;1"]
-                         .getService(Ci.nsIAppsService);
-          let appId = appsSvc.getAppLocalIdByManifestURL(manifestURL);
-          let subject = {
-            appId: appId,
-            browserOnly: false,
-            QueryInterface: XPCOMUtils.generateQI([
-              Ci.mozIApplicationClearPrivateDataParams
-            ])
-          };
-          Services.obs.notifyObservers(subject, "webapps-clear-data", null);
-
-          test_frame.remove();
-          finish();
-        });
-      });
-    }
-
-    window.addEventListener("load", function onLoad() {
-      window.removeEventListener("load", onLoad);
-      SpecialPowers.pushPrefEnv({'set': [["dom.mozBrowserFramesEnabled", true],
-                                         ["dom.sysmsg.enabled", true]]}, () => {
-        runTest(/* isRemote= */false)
-          .then(() => runTest(/* isRemote= */true))
-          .then(SimpleTest.finish);
-      });
-    });
-  </script>
-</head>
-<body>
-</body>
-</html>
deleted file mode 100644
--- a/dom/messages/test/test_sysmsg_registration.html
+++ /dev/null
@@ -1,231 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>System messages registration tests</title>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/chrome-harness.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1162281}">Mozilla Bug {1162281}</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-<script class="testbody" type="application/javascript;version=1.7">
-
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-// We need to keep the same CID as the one used on activities tests.
-// Check https://bugzilla.mozilla.org/show_bug.cgi?id=1176712#c13
-const SYS_MSG_GLUE_CID = Components.ID("{b0b6b9af-bc4e-4200-bffe-fb7691065ec9}");
-
-XPCOMUtils.defineLazyGetter(this, "messenger", () => {
-   return Cc["@mozilla.org/system-message-internal;1"]
-   .getService(Ci.nsISystemMessagesInternal);
-});
-
-let gRootUrl = "http://test/chrome/dom/messages/test/";
-let validAppUrl = gRootUrl + "manifest.webapp";
-let invalidAppUrl = gRootUrl + "invalid_manifest.webapp";
-let validApp;
-let initialAppsCount;
-let index = 0;
-
-SimpleTest.waitForExplicitFinish();
-
-function go() {
-  SpecialPowers.pushPermissions(
-    [{ "type": "webapps-manage", "allow": 1, "context": document },
-     { "type": "browser", "allow": 1, "context": document },
-     { "type": "embed-apps", "allow": 1, "context": document }],
-    function() {
-      SpecialPowers.pushPrefEnv(
-        {'set': [["dom.mozBrowserFramesEnabled", true],
-                 ["dom.sysmsg.enabled", true]]},
-        next) });
-}
-
-function finish() {
-  unregisterComponent(SystemMessageGlue);
-  SimpleTest.finish();
-}
-
-function next() {
-  info("Step " + index);
-  if (index >= steps.length) {
-    ok(false, "Shouldn't get here!");
-    return;
-  }
-  try {
-    let i = index++;
-    steps[i]();
-  } catch(ex) {
-    ok(false, "Caught exception", ex);
-  }
-}
-
-function cbError(aEvent) {
-  ok(false, "Error callback invoked " +
-            aEvent.target.error.name + " " + aEvent.target.error.message);
-  finish();
-}
-
-function uninstall(aApp) {
-  info("Uninstalling " + (aApp ? aApp.manifestURL : "NO APP!!"));
-}
-
-function registerComponent(aObject, aDescription, aContract) {
-  info("Registering " + SYS_MSG_GLUE_CID);
-
-  let componentManager =
-    Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-  componentManager.registerFactory(SYS_MSG_GLUE_CID, aDescription, aContract, aObject);
-}
-
-function unregisterComponent(aObject) {
-  info("Unregistering " + SYS_MSG_GLUE_CID);
-  let componentManager =
-    Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-  componentManager.unregisterFactory(SYS_MSG_GLUE_CID, aObject);
-}
-
-let SystemMessageGlue = {
-  // nsISupports implementation.
-  QueryInterface: function(iid) {
-    if (iid.equals(Ci.nsISupports) ||
-        iid.equals(Ci.nsIFactory) ||
-        iid.equals(Ci.nsISystemMessageGlue)) {
-      return this;
-    }
-
-    throw Cr.NS_ERROR_NO_INTERFACE;
-  },
-
-  // nsIFactory implementation.
-  createInstance: function(outer, iid) {
-    return this.QueryInterface(iid);
-  },
-
-  _lastManifestURL: null,
-
-  // nsISystemMessageGlue implementation.
-  openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) {
-    this._lastManifestURL = manifestURL;
-  }
-};
-
-registerComponent(SystemMessageGlue,
-                  "System Message Glue",
-                  "@mozilla.org/dom/messages/system-message-glue;1");
-
-function testBroadcastMessage(aMessage, aExpectedManifestURL, aMsg) {
-  SystemMessageGlue._lastManifestURL = null;
-  messenger.broadcastMessage(aMessage, {}, {})
-  .then(() => {
-    is(SystemMessageGlue._lastManifestURL, aExpectedManifestURL, aMsg);
-    next();
-  })
-  .catch(cbError);
-}
-
-/**
- * TESTS
- */
-let steps = [() => {
-  Services.obs.notifyObservers(null, "webapps-registry-ready", null);
-  SpecialPowers.autoConfirmAppInstall(next);
-}, () => {
-  SpecialPowers.autoConfirmAppUninstall(next);
-}, () => {
-  // Check how many apps we are starting with.
-  let request = navigator.mozApps.mgmt.getAll();
-  request.onerror = cbError;
-  request.onsuccess = () => {
-    initialAppsCount = request.result.length;
-    info("Starting with " + initialAppsCount + " apps installed.");
-    next();
-  };
-}, () => {
-  // We still have not installed any app handling dummy-system-message.
-  testBroadcastMessage("dummy-system-message", null,
-                       "no system message should be sent");
-}, () => {
-  testBroadcastMessage("dummy-system-message2", null,
-                       "no system message should be sent");
-}, () => {
-  navigator.mozApps.mgmt.oninstall = ()  => {
-    validApp = request.result;
-    next();
-  };
-  let request = navigator.mozApps.install(validAppUrl, { });
-  request.error = cbError;
-  request.onsuccess = () => {
-    validApp = request.result;
-  };
-}, () => {
-  // Installing the test app should register the system message.
-  testBroadcastMessage("dummy-system-message", validAppUrl,
-                       "system message should be sent");
-}, () => {
-  // Installing the test app should register the system message.
-  testBroadcastMessage("dummy-system-message2", validAppUrl,
-                       "system message should be sent");
-}, () => {
-  navigator.mozApps.mgmt.onuninstall = ()  => {
-    validApp = null;
-    next();
-  };
-  let request = navigator.mozApps.mgmt.uninstall(validApp);
-  request.onerror = cbError;
-}, () => {
-  // Uninstalling the app should unregister the system messages.
-  testBroadcastMessage("dummy-system-message", null,
-                       "no system message should be sent");
-}, () => {
-  // Uninstalling the app should unregister the system messages.
-  testBroadcastMessage("dummy-system-message2", null,
-                       "no system message should be sent");
-}, () => {
-  navigator.mozApps.mgmt.oninstall = ()  => {
-    validApp = request.result;
-    next();
-  };
-  let request = navigator.mozApps.install(invalidAppUrl, { });
-  request.onerror = () => {
-    ok(true, "should not install invalid app");
-    next();
-  };
-  request.onsuccess = () => {
-    ok(false, "should not install invalid app");
-    finish();
-  };
-}, () => {
-  testBroadcastMessage("dummy-system-message", null,
-                       "no system message should be sent");
-}, () => {
-  testBroadcastMessage("dummy-system-message2", null,
-                       "no system message should be sent");
-}, () => {
-   // Check how many apps we are finishing with.
-  let request = navigator.mozApps.mgmt.getAll();
-  request.onerror = cbError;
-  request.onsuccess = () => {
-    info("Finishing with " + request.result.length + " apps installed.");
-    is(initialAppsCount, request.result.length, "All apps are uninstalled");
-    next();
-  };
-}, finish];
-
-addLoadEvent(go);
-
-</script>
-</pre>
-</body>
-</html>
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -65,17 +65,16 @@ DIRS += [
     'html',
     'icc',
     'inputport',
     'json',
     'jsurl',
     'asmjscache',
     'mathml',
     'media',
-    'messages',
     'mobileconnection',
     'notification',
     'offline',
     'power',
     'quota',
     'security',
     'settings',
     'storage',
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -292,32 +292,16 @@ partial interface Navigator {
 };
 
 // nsIDOMNavigatorCamera
 partial interface Navigator {
   [Throws, Func="Navigator::HasCameraSupport", UnsafeInPrerendering]
   readonly attribute CameraManager mozCameras;
 };
 
-// nsIDOMNavigatorSystemMessages and sort of maybe
-// http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
-callback systemMessageCallback = void (optional object message);
-partial interface Navigator {
-  [Throws, Pref="dom.sysmsg.enabled"]
-  void    mozSetMessageHandler (DOMString type, systemMessageCallback? callback);
-  [Throws, Pref="dom.sysmsg.enabled"]
-  boolean mozHasPendingMessage (DOMString type);
-
-  // This method can be called only from the systeMessageCallback function and
-  // it allows the page to set a promise to keep alive the app until the
-  // current operation is not fully completed.
-  [Throws, Pref="dom.sysmsg.enabled"]
-  void mozSetMessageHandlerPromise (Promise<any> promise);
-};
-
 #ifdef MOZ_B2G_RIL
 partial interface Navigator {
   [Throws, Pref="dom.mobileconnection.enabled", CheckAnyPermissions="mobileconnection mobilenetwork", UnsafeInPrerendering]
   readonly attribute MozMobileConnectionArray mozMobileConnections;
 };
 
 partial interface Navigator {
   [Throws, Pref="dom.cellbroadcast.enabled", CheckAnyPermissions="cellbroadcast",