Backed out changeset 721eb8e94100 (bug 1014023) for exceptions during test_widget.html
authorEd Morley <emorley@mozilla.com>
Tue, 19 Aug 2014 15:12:32 +0100
changeset 200273 087e8fbc1cf9e26fd414197fe3af7bf64c311324
parent 200272 03acff0b4f82634c7ce31b7a57698b6882116110
child 200274 498506843eaf6a49d57799090ac7ca63751ea0f1
push id47865
push useremorley@mozilla.com
push dateTue, 19 Aug 2014 14:12:49 +0000
treeherdermozilla-inbound@087e8fbc1cf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1014023
milestone34.0a1
backs out721eb8e94100c8947b6c00e22ea69b4462d6050b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 721eb8e94100 (bug 1014023) for exceptions during test_widget.html
b2g/app/b2g.js
dom/datastore/DataStoreChangeNotifier.jsm
dom/datastore/DataStoreService.cpp
dom/datastore/nsIDataStoreService.idl
dom/datastore/tests/file_notify_system_message.html
dom/datastore/tests/mochitest.ini
dom/datastore/tests/test_app_install.html
dom/datastore/tests/test_arrays.html
dom/datastore/tests/test_basic.html
dom/datastore/tests/test_basic_worker.html
dom/datastore/tests/test_bug1008044.html
dom/datastore/tests/test_bug924104.html
dom/datastore/tests/test_bug957086.html
dom/datastore/tests/test_bug976311.html
dom/datastore/tests/test_bug986056.html
dom/datastore/tests/test_certifiedApp.html
dom/datastore/tests/test_changes.html
dom/datastore/tests/test_duplicate.html
dom/datastore/tests/test_keys.html
dom/datastore/tests/test_notify_system_message.html
dom/datastore/tests/test_oop.html
dom/datastore/tests/test_oop_events.html
dom/datastore/tests/test_readonly.html
dom/datastore/tests/test_sync.html
dom/datastore/tests/test_sync_worker.html
dom/datastore/tests/test_transactions.html
dom/messages/SystemMessageInternal.js
dom/messages/SystemMessagePermissionsChecker.jsm
dom/messages/interfaces/nsISystemMessagesInternal.idl
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -884,20 +884,16 @@ pref("network.sntp.maxRetryCount", 10);
 pref("network.sntp.refreshPeriod", 86400); // In seconds.
 pref("network.sntp.pools", // Servers separated by ';'.
      "0.pool.ntp.org;1.pool.ntp.org;2.pool.ntp.org;3.pool.ntp.org");
 pref("network.sntp.port", 123);
 pref("network.sntp.timeout", 30); // In seconds.
 
 // Enable dataStore
 pref("dom.datastore.enabled", true);
-// When an entry is changed, use two timers to fire system messages in a more
-// moderate pattern.
-pref("dom.datastore.sysMsgOnChangeShortTimeoutSec", 10);
-pref("dom.datastore.sysMsgOnChangeLongTimeoutSec", 60);
 
 // DOM Inter-App Communication API.
 pref("dom.inter-app-communication-api.enabled", true);
 
 // Allow ADB to run for this many hours before disabling
 // (only applies when marionette is disabled)
 // 0 disables the timer.
 pref("b2g.adb.timeout-hours", 12);
--- a/dom/datastore/DataStoreChangeNotifier.jsm
+++ b/dom/datastore/DataStoreChangeNotifier.jsm
@@ -18,43 +18,22 @@ Cu.import("resource://gre/modules/Servic
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageBroadcaster");
 
 XPCOMUtils.defineLazyServiceGetter(this, "dataStoreService",
                                    "@mozilla.org/datastore-service;1",
                                    "nsIDataStoreService");
 
-XPCOMUtils.defineLazyServiceGetter(this, "systemMessenger",
-                                   "@mozilla.org/system-message-internal;1",
-                                   "nsISystemMessagesInternal");
-
-var kSysMsgOnChangeShortTimeoutSec =
-    Services.prefs.getIntPref("dom.datastore.sysMsgOnChangeShortTimeoutSec");
-var kSysMsgOnChangeLongTimeoutSec =
-    Services.prefs.getIntPref("dom.datastore.sysMsgOnChangeLongTimeoutSec");
-
 this.DataStoreChangeNotifier = {
   children: [],
   messages: [ "DataStore:Changed", "DataStore:RegisterForMessages",
               "DataStore:UnregisterForMessages",
               "child-process-shutdown" ],
 
-  // These hashes are used for storing the mapping between the datastore
-  // identifiers (name | owner manifest URL) and their correspondent timers. 
-  // The object literal is defined as below:
-  //
-  // {
-  //   "datastore name 1|owner manifest URL 1": timer1,
-  //   "datastore name 2|owner manifest URL 2": timer2,
-  //   ...
-  // }
-  sysMsgOnChangeShortTimers: {},
-  sysMsgOnChangeLongTimers: {},
-
   init: function() {
     debug("init");
 
     this.messages.forEach((function(msgName) {
       ppmm.addMessageListener(msgName, this);
     }).bind(this));
 
     Services.obs.addObserver(this, 'xpcom-shutdown', false);
@@ -75,88 +54,24 @@ this.DataStoreChangeNotifier = {
 
       default:
         debug("Wrong observer topic: " + aTopic);
         break;
     }
   },
 
   broadcastMessage: function broadcastMessage(aData) {
-    debug("broadcast");
-
+    debug("Broadast");
     this.children.forEach(function(obj) {
       if (obj.store == aData.store && obj.owner == aData.owner) {
         obj.mm.sendAsyncMessage("DataStore:Changed:Return:OK", aData);
       }
     });
   },
 
-  broadcastSystemMessage: function(aStore, aOwner) {
-    debug("broadcastSystemMessage");
-
-    // Clear relevant timers.
-    var storeKey = aStore + "|" + aOwner;
-    var shortTimer = this.sysMsgOnChangeShortTimers[storeKey];
-    if (shortTimer) {
-      shortTimer.cancel();
-      delete this.sysMsgOnChangeShortTimers[storeKey];
-    }
-    var longTimer = this.sysMsgOnChangeLongTimers[storeKey];
-    if (longTimer) {
-      longTimer.cancel();
-      delete this.sysMsgOnChangeLongTimers[storeKey];
-    }
-
-    // Get all the manifest URLs of the apps which can access the datastore.
-    var manifestURLs = dataStoreService.getAppManifestURLsForDataStore(aStore);
-    var enumerate = manifestURLs.enumerate();
-    while (enumerate.hasMoreElements()) {
-      var manifestURL = enumerate.getNext().QueryInterface(Ci.nsISupportsString);
-      debug("Notify app " + manifestURL + " of datastore updates");
-      // Send the system message 'datastore-update-{store name}' to all the
-      // pages for these apps. With the manifest URL of the owner in the message
-      // payload, it notifies the consumer a sync operation should be performed.
-      systemMessenger.sendMessage("datastore-update-" + aStore,
-                                  { owner: aOwner },
-                                  null,
-                                  Services.io.newURI(manifestURL, null, null));
-    }
-  },
-
-  // Use the following logic to broadcast system messages in a moderate pattern.
-  // 1. When an entry is changed, start a short timer and a long timer.
-  // 2. If an entry is changed while the short timer is running, reset it.
-  //    Do not reset the long timer.
-  // 3. Once either fires, broadcast the system message and cancel both timers.
-  setSystemMessageTimeout: function(aStore, aOwner) {
-    debug("setSystemMessageTimeout");
-
-    var storeKey = aStore + "|" + aOwner;
-
-    // Reset the short timer.
-    var shortTimer = this.sysMsgOnChangeShortTimers[storeKey];
-    if (!shortTimer) {
-      shortTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-      this.sysMsgOnChangeShortTimers[storeKey] = shortTimer;
-    } else {
-      shortTimer.cancel();
-    }
-    shortTimer.initWithCallback({ notify: this.broadcastSystemMessage.bind(this, aStore, aOwner) },
-                                kSysMsgOnChangeShortTimeoutSec * 1000,
-                                Ci.nsITimer.TYPE_ONE_SHOT);
-
-    // Set the long timer if necessary.
-    if (!this.sysMsgOnChangeLongTimers[storeKey]) {
-      var longTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-      this.sysMsgOnChangeLongTimers[storeKey] = longTimer;
-      longTimer.initWithCallback({ notify: this.broadcastSystemMessage.bind(this, aStore, aOwner) },
-                                 kSysMsgOnChangeLongTimeoutSec * 1000,
-                                 Ci.nsITimer.TYPE_ONE_SHOT);
-    }
-  },
 
   receiveMessage: function(aMessage) {
     debug("receiveMessage ");
 
     // No check has to be done when the message is 'child-process-shutdown'.
     if (aMessage.name != "child-process-shutdown") {
       if (!("principal" in aMessage)) {
         return;
@@ -169,19 +84,16 @@ this.DataStoreChangeNotifier = {
       if (!principal || !dataStoreService.checkPermission(principal)) {
         return;
       }
     }
 
     switch (aMessage.name) {
       case "DataStore:Changed":
         this.broadcastMessage(aMessage.data);
-        if (Services.prefs.getBoolPref("dom.sysmsg.enabled")) {
-          this.setSystemMessageTimeout(aMessage.data.store, aMessage.data.owner);
-        }
         break;
 
       case "DataStore:RegisterForMessages":
         debug("Register!");
 
         for (let i = 0; i < this.children.length; ++i) {
           if (this.children[i].mm == aMessage.target &&
               this.children[i].store == aMessage.data.store &&
--- a/dom/datastore/DataStoreService.cpp
+++ b/dom/datastore/DataStoreService.cpp
@@ -28,21 +28,19 @@
 
 #include "mozIApplication.h"
 #include "mozIApplicationClearPrivateDataParams.h"
 #include "nsIAppsService.h"
 #include "nsIDOMEvent.h"
 #include "nsIDocument.h"
 #include "nsIDOMGlobalPropertyInitializer.h"
 #include "nsIIOService.h"
-#include "nsIMutableArray.h"
 #include "nsIObserverService.h"
 #include "nsIPermissionManager.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsISupportsPrimitives.h"
 #include "nsIUUIDGenerator.h"
 #include "nsPIDOMWindow.h"
 #include "nsIURI.h"
 
 #include "nsContentUtils.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
@@ -372,34 +370,16 @@ GetDataStoreInfosEnumerator(const uint32
   DataStoreInfo* accessStore = data->mStores.AppendElement();
   accessStore->Init(aInfo->mName, aInfo->mOriginURL,
                     aInfo->mManifestURL, readOnly,
                     aInfo->mEnabled);
 
   return PL_DHASH_NEXT;
 }
 
-PLDHashOperator
-GetAppManifestURLsEnumerator(const uint32_t& aAppId,
-                             DataStoreInfo* aInfo,
-                             void* aUserData)
-{
-  AssertIsInMainProcess();
-  MOZ_ASSERT(NS_IsMainThread());
-
-  auto* manifestURLs = static_cast<nsIMutableArray*>(aUserData);
-  nsCOMPtr<nsISupportsString> manifestURL(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
-  if (manifestURL) {
-    manifestURL->SetData(aInfo->mManifestURL);
-    manifestURLs->AppendElement(manifestURL, false);
-  }
-
-  return PL_DHASH_NEXT;
-}
-
 // This class is useful to enumerate the add permissions for each app.
 class MOZ_STACK_CLASS AddPermissionsData
 {
 public:
   AddPermissionsData(const nsAString& aPermission, bool aReadOnly)
     : mPermission(aPermission)
     , mReadOnly(aReadOnly)
     , mResult(NS_OK)
@@ -1072,41 +1052,16 @@ DataStoreService::GetDataStoreInfos(cons
                 info->mEnabled);
   }
 
   GetDataStoreInfosData data(mAccessStores, aName, aOwner, aAppId, aStores);
   apps->EnumerateRead(GetDataStoreInfosEnumerator, &data);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-DataStoreService::GetAppManifestURLsForDataStore(const nsAString& aName,
-                                                 nsIArray** aManifestURLs)
-{
-  ASSERT_PARENT_PROCESS()
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsCOMPtr<nsIMutableArray> manifestURLs = do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!manifestURLs) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  HashApp* apps = nullptr;
-  if (mStores.Get(aName, &apps)) {
-    apps->EnumerateRead(GetAppManifestURLsEnumerator, manifestURLs.get());
-  }
-  if (mAccessStores.Get(aName, &apps)) {
-    apps->EnumerateRead(GetAppManifestURLsEnumerator, manifestURLs.get());
-  }
-
-  *aManifestURLs = manifestURLs;
-  NS_ADDREF(*aManifestURLs);
-  return NS_OK;
-}
-
 bool
 DataStoreService::CheckPermission(nsIPrincipal* aPrincipal)
 {
   // First of all, the general pref has to be turned on.
   bool enabled = false;
   Preferences::GetBool("dom.datastore.enabled", &enabled);
   if (!enabled) {
     return false;
--- a/dom/datastore/nsIDataStoreService.idl
+++ b/dom/datastore/nsIDataStoreService.idl
@@ -2,19 +2,18 @@
 /* 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"
 
 interface nsIDOMWindow;
 interface nsIPrincipal;
-interface nsIArray;
 
-[scriptable, uuid(79944b1c-187d-11e4-abb6-74d02b97e723)]
+[scriptable, uuid(9b59c49a-0cd7-11e4-b096-74d02b97e723)]
 interface nsIDataStoreService : nsISupports
 {
   void installDataStore(in unsigned long appId,
                         in DOMString name,
                         in DOMString originURL,
                         in DOMString manifestURL,
                         in boolean readOnly);
 
@@ -23,12 +22,10 @@ interface nsIDataStoreService : nsISuppo
                               in DOMString originURL,
                               in DOMString manifestURL,
                               in boolean readOnly);
 
   nsISupports getDataStores(in nsIDOMWindow window,
                             in DOMString name,
                             in DOMString owner);
 
-  nsIArray getAppManifestURLsForDataStore(in DOMString name);
-
   boolean checkPermission(in nsIPrincipal principal);
 };
deleted file mode 100644
--- a/dom/datastore/tests/file_notify_system_message.html
+++ /dev/null
@@ -1,120 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for DataStore - notify updates with system messages</title>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-  <script type="application/javascript;version=1.7">
-
-  var gStore;
-  var gChangeId = null;
-  var gChangeOperation = null;
-  var gIsSystemMessageFired = false;
-
-  function is(a, b, msg) {
-    alert((a === b ? 'OK' : 'KO') + ' ' + msg)
-  }
-
-  function ok(a, msg) {
-    alert((a ? 'OK' : 'KO')+ ' ' + msg)
-  }
-
-  function cbError() {
-    alert('KO error');
-  }
-
-  function finish() {
-    alert('DONE');
-  }
-
-  function testGetDataStores() {
-    navigator.getDataStores('foo').then(function(stores) {
-      is(stores.length, 1, "getDataStores('foo') returns 1 element");
-      is(stores[0].name, 'foo', 'The dataStore.name is foo');
-      is(stores[0].readOnly, false, 'The dataStore foo is not in readonly');
-
-      gStore = stores[0];
-      runTest();
-    }, cbError);
-  }
-
-  function testStoreAdd(value, expectedId) {
-    gStore.add(value).then(function(id) {
-      is(id, expectedId, "store.add() is called");
-    }, cbError);
-  }
-
-  function eventListener(evt) {
-    ok(evt instanceof DataStoreChangeEvent, "DataStoreChangeEvent has been received");
-    ok(evt, "OnChangeListener is called with data");
-    is(/[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}/.test(evt.revisionId), true, "event.revisionId returns something");
-    is(evt.id, gChangeId, "OnChangeListener is called with the right ID: " + evt.id);
-    is(evt.operation, gChangeOperation, "OnChangeListener is called with the right operation:" + evt.operation + " " + gChangeOperation);
-    runTest();
-  }
-
-  function onDatastoreUpdateFoo(message) {
-    gIsSystemMessageFired = true;
-    ok(true, "System message 'datastore-update-foo' has been received");
-    runTest();
-  }
-
-  var tests = [
-    // Test for GetDataStore.
-    testGetDataStores,
-
-    // Add onchange = function.
-    function() {
-      gStore.onchange = eventListener;
-      is(gStore.onchange, eventListener, "onChange is set");
-      runTest();
-    },
-
-    // Set system message handler.
-    function() {
-      navigator.mozSetMessageHandler('datastore-update-foo', onDatastoreUpdateFoo);
-      runTest();
-    },
-
-    // Add.
-    function() { gChangeId = 1; gChangeOperation = 'added';
-                 testStoreAdd({ number: 42 }, 1); },
-
-    // Remove event listener.
-    function() {
-      gStore.removeEventListener('change', eventListener);
-      runTest();
-    },
-
-    // Ensure the system message has fired and no more pending ones.
-    function() {
-      // Periodically check whether the system message has fired.
-      var timer = setInterval(function() {
-        if (gIsSystemMessageFired) {
-          clearInterval(timer);
-          ok(true, "The system message has fired");
-          ok(!navigator.mozHasPendingMessage('datastore-update-foo'), "No more pending system message");
-          finish();
-        }
-      }, 1000);
-    }
-  ];
-
-  function runTest() {
-    if (tests.length) {
-      var test = tests.shift();
-      test();
-    }
-  }
-
-  runTest();
-  </script>
-</pre>
-</body>
-</html>
--- a/dom/datastore/tests/mochitest.ini
+++ b/dom/datastore/tests/mochitest.ini
@@ -25,17 +25,16 @@ support-files =
   file_bug986056.template.webapp
   file_event_maker.html
   file_event_receiver.html
   file_transactions.html
   file_basic_common.js
   file_sync_common.js
   file_bug1008044.html
   file_bug957086.html
-  file_notify_system_message.html
 
 [test_app_install.html]
 [test_readonly.html]
 [test_basic.html]
 [test_basic_worker.html]
 [test_changes.html]
 [test_arrays.html]
 [test_oop.html]
@@ -46,10 +45,8 @@ support-files =
 [test_keys.html]
 [test_duplicate.html]
 [test_bug976311.html]
 [test_bug986056.html]
 [test_oop_events.html]
 [test_transactions.html]
 [test_bug1008044.html]
 [test_bug957086.html]
-[test_notify_system_message.html]
-skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || toolkit == 'win' #bug 1051164 - Timeout prone
--- a/dom/datastore/tests/test_app_install.html
+++ b/dom/datastore/tests/test_app_install.html
@@ -5,36 +5,34 @@
   <title>Test for DataStore - install/uninstall apps</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <div id="container"></div>
   <script type="application/javascript;version=1.7">
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
 
   var gBaseURL = 'http://test/tests/dom/datastore/tests/';
   var gHostedManifestURL = gBaseURL + 'file_app.sjs?testToken=file_app_install.html';
   var gGenerator = runTest();
 
   SpecialPowers.pushPermissions(
     [{ "type": "browser", "allow": 1, "context": document },
      { "type": "embed-apps", "allow": 1, "context": document },
      { "type": "webapps-manage", "allow": 1, "context": document }],
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, function() {
-
-        if (SpecialPowers.isMainProcess()) {
-          SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-        }
         gGenerator.next(); });
     });
 
   function continueTest() {
     try {
       gGenerator.next();
     } catch (e if e instanceof StopIteration) { }
   }
--- a/dom/datastore/tests/test_arrays.html
+++ b/dom/datastore/tests/test_arrays.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_basic.html
+++ b/dom/datastore/tests/test_basic.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_basic_worker.html
+++ b/dom/datastore/tests/test_basic_worker.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_bug1008044.html
+++ b/dom/datastore/tests/test_bug1008044.html
@@ -72,28 +72,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.ipc.browser_frames.oop_by_default", true],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -118,13 +112,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_bug924104.html
+++ b/dom/datastore/tests/test_bug924104.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_bug957086.html
+++ b/dom/datastore/tests/test_bug957086.html
@@ -76,28 +76,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.ipc.browser_frames.oop_by_default", true],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -125,13 +119,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_bug976311.html
+++ b/dom/datastore/tests/test_bug976311.html
@@ -77,27 +77,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -125,13 +119,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_bug986056.html
+++ b/dom/datastore/tests/test_bug986056.html
@@ -70,27 +70,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
+    // Enabling mozBrowser
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, runTest);
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
     },
@@ -134,14 +129,18 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </pre>
 </body>
 </html>
--- a/dom/datastore/tests/test_certifiedApp.html
+++ b/dom/datastore/tests/test_certifiedApp.html
@@ -72,34 +72,28 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", false]]}, runTest);
     },
 
     function() {
       ok(!("DataStore" in window), "DataStore is not an available interface");
       ok(!("DataStoreChangeEvent" in window), "DataStore is not an available interface");
       ok(!("getDataStores" in navigator), "getDataStores should not exist");
       runTest();
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -124,13 +118,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_changes.html
+++ b/dom/datastore/tests/test_changes.html
@@ -116,27 +116,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
+    // Enabling mozBrowser
     function() {
-   	  if (SpecialPowers.isMainProcess()) {
-   	    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-   	  }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, runTest);
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
     },
@@ -169,16 +164,20 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </pre>
 </body>
 </html>
 
 
--- a/dom/datastore/tests/test_duplicate.html
+++ b/dom/datastore/tests/test_duplicate.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_keys.html
+++ b/dom/datastore/tests/test_keys.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
deleted file mode 100644
--- a/dom/datastore/tests/test_notify_system_message.html
+++ /dev/null
@@ -1,138 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for DataStore - notify updates with system messages</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-
-  var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_notify_system_message.html';
-  var gHostedPageURL = 'http://mochi.test:8888/tests/dom/datastore/tests/file_notify_system_message.html';
-  var gApp;
-
-  function cbError() {
-    ok(false, "Error callback invoked");
-    finish();
-  }
-
-  function installApp() {
-    var request = navigator.mozApps.install(gHostedManifestURL);
-    request.onerror = cbError;
-    request.onsuccess = function() {
-      gApp = request.result;
-      runTest();
-    }
-  }
-
-  function uninstallApp() {
-    // Uninstall the app.
-    var request = navigator.mozApps.mgmt.uninstall(gApp);
-    request.onerror = cbError;
-    request.onsuccess = function() {
-      // All done.
-      info("All done");
-      runTest();
-    }
-  }
-
-  function testApp() {
-    var ifr = document.createElement('iframe');
-    ifr.setAttribute('mozbrowser', 'true');
-    ifr.setAttribute('mozapp', gApp.manifestURL);
-    ifr.setAttribute('src', gApp.manifest.launch_path);
-    var domParent = document.getElementById('container');
-
-    // Set us up to listen for messages from the app.
-    var listener = function(e) {
-      var message = e.detail.message;
-      if (/^OK/.exec(message)) {
-        ok(true, "Message from app: " + message);
-      } else if (/KO/.exec(message)) {
-        ok(false, "Message from app: " + message);
-      } else if (/DONE/.exec(message)) {
-        ok(true, "Messaging from app complete");
-        ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
-        domParent.removeChild(ifr);
-        runTest();
-      }
-    }
-
-    // This event is triggered when the app calls "alert".
-    ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
-    domParent.appendChild(ifr);
-  }
-
-  var tests = [
-    // Permissions.
-    function() {
-      SpecialPowers.pushPermissions(
-        [{ "type": "browser", "allow": 1, "context": document },
-         { "type": "embed-apps", "allow": 1, "context": document },
-         { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
-    },
-
-    // Preferences.
-    function() {
-      SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
-                                         ["dom.sysmsg.enabled", true],
-                                         ["dom.testing.ignore_ipc_principal", true],
-                                         ["dom.testing.datastore_enabled_for_hosted_apps", true],
-                                         ["dom.mozBrowserFramesEnabled", true]]}, runTest);
-    },
-
-    function() {
-      SpecialPowers.setAllAppsLaunchable(true);
-      // No confirmation needed when an app is installed.
-      SpecialPowers.autoConfirmAppInstall(runTest);
-    },
-
-    function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-        SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
-        var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
-                                     .getService(SpecialPowers.Ci.nsIIOService);
-        var systemMessenger = SpecialPowers.Cc["@mozilla.org/system-message-internal;1"]
-                              .getService(SpecialPowers.Ci.nsISystemMessagesInternal);
-        systemMessenger.registerPage("datastore-update-foo",
-                                     ioService.newURI(gHostedPageURL, null, null),
-                                     ioService.newURI(gHostedManifestURL, null, null));
-      }
-      runTest();
-    },
-
-    // Installing the app.
-    installApp,
-
-    // Run tests in app.
-    testApp,
-
-    // Uninstall the app.
-    uninstallApp
-  ];
-
-  function runTest() {
-    if (!tests.length) {
-      finish();
-      return;
-    }
-
-    var test = tests.shift();
-    test();
-  }
-
-  function finish() {
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  runTest();
-  </script>
-</body>
-</html>
--- a/dom/datastore/tests/test_oop.html
+++ b/dom/datastore/tests/test_oop.html
@@ -72,28 +72,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.ipc.browser_frames.oop_by_default", true],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -118,13 +112,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_oop_events.html
+++ b/dom/datastore/tests/test_oop_events.html
@@ -100,28 +100,22 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.ipc.browser_frames.oop_by_default", true],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -148,13 +142,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_readonly.html
+++ b/dom/datastore/tests/test_readonly.html
@@ -25,20 +25,16 @@
   }
 
   function cbError() {
     ok(false, "Error callback invoked");
     finish();
   }
 
   function runTest() {
-    if (SpecialPowers.isMainProcess()) {
-      SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-    }
-
     SpecialPowers.setAllAppsLaunchable(true);
     SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
 
     SpecialPowers.autoConfirmAppInstall(continueTest);
     yield undefined;
 
     var request = navigator.mozApps.install(gHostedManifestURL);
     request.onerror = cbError;
@@ -94,17 +90,19 @@
     domParent.appendChild(ifr);
   }
 
   function finish() {
     SpecialPowers.clearUserPref("dom.mozBrowserFramesEnabled");
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                     ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                     ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                      ["dom.testing.ignore_ipc_principal", true],
                                      ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_sync.html
+++ b/dom/datastore/tests/test_sync.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
     },
@@ -116,13 +110,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_sync_worker.html
+++ b/dom/datastore/tests/test_sync_worker.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
     },
@@ -116,13 +110,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/datastore/tests/test_transactions.html
+++ b/dom/datastore/tests/test_transactions.html
@@ -72,27 +72,21 @@
         [{ "type": "browser", "allow": 1, "context": document },
          { "type": "embed-apps", "allow": 1, "context": document },
          { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
     },
 
     // Preferences
     function() {
       SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
-                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
                                          ["dom.testing.ignore_ipc_principal", true],
                                          ["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
     },
 
     function() {
-      if (SpecialPowers.isMainProcess()) {
-        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-      }
-
       SpecialPowers.setAllAppsLaunchable(true);
       SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
       runTest();
     },
 
     // No confirmation needed when an app is installed
     function() {
       SpecialPowers.autoConfirmAppInstall(runTest);
@@ -117,13 +111,17 @@
     var test = tests.shift();
     test();
   }
 
   function finish() {
     SimpleTest.finish();
   }
 
+  if (SpecialPowers.isMainProcess()) {
+    SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>
--- a/dom/messages/SystemMessageInternal.js
+++ b/dom/messages/SystemMessageInternal.js
@@ -187,58 +187,41 @@ SystemMessageInternal.prototype = {
                                    extra: aExtra });
       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 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);
-        }
-      }
+    debug("Sending " + aType + " " + JSON.stringify(aMessage) +
+      " for " + aPageURI.spec + " @ " + aManifestURI.spec +
+      '; extra: ' + JSON.stringify(aExtra));
+
+    let result = this._sendMessageCommon(aType,
+                                         aMessage,
+                                         messageID,
+                                         aPageURI.spec,
+                                         aManifestURI.spec,
+                                         aExtra);
+    debug("Returned status of sending message: " + result);
+
+    // Don't need to open the pages and queue the system message
+    // which was not allowed to be sent.
+    if (result === MSG_SENT_FAILURE_PERM_DENIED) {
+      return;
     }
 
-    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);
+    let page = this._findPage(aType, aPageURI.spec, aManifestURI.spec);
+    if (page) {
+      // Queue this message in the corresponding pages.
+      this._queueMessage(page, aMessage, messageID);
 
-      // Don't need to open the pages and queue the system message
-      // which was not allowed to be sent.
-      if (result === MSG_SENT_FAILURE_PERM_DENIED) {
-        return;
-      }
-
-      let page = this._findPage(aType, aPageURL, manifestURL);
-      if (page) {
-        // Queue this message in the corresponding pages.
-        this._queueMessage(page, aMessage, messageID);
-
-        this._openAppPage(page, aMessage, aExtra, result);
-      }
-    }, this);
+      this._openAppPage(page, aMessage, aExtra, result);
+    }
   },
 
   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,
--- a/dom/messages/SystemMessagePermissionsChecker.jsm
+++ b/dom/messages/SystemMessagePermissionsChecker.jsm
@@ -10,18 +10,17 @@ 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",
-                         "SystemMessagePrefixPermissionsTable"];
+                         "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
@@ -118,28 +117,16 @@ this.SystemMessagePermissionsTable = {
     "settings": ["read", "write"]
   },
   "wifip2p-pairing-request": { },
   "first-run-with-sim": {
     "settings": ["read", "write"]
   }
 };
 
-// This table maps system message prefix to permission(s), indicating only
-// the system messages with specified prefixes 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.
-//
-// Note that this table is only used when the permission checker can't find a
-// match in SystemMessagePermissionsTable listed above.
-
-this.SystemMessagePrefixPermissionsTable = {
-  "datastore-update-": { },
-};
-
 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"], ... }.
@@ -148,44 +135,34 @@ this.SystemMessagePermissionsChecker = {
    *        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) {
-      // Try to look up in the prefix table.
-      for (let sysMsgPrefix in SystemMessagePrefixPermissionsTable) {
-        if (aSysMsgName.indexOf(sysMsgPrefix) === 0) {
-          permNames = SystemMessagePrefixPermissionsTable[sysMsgPrefix];
-          break;
-        }
-      }
-
-      if (permNames === undefined) {
-        debug("'" + aSysMsgName + "' is not associated with permissions. " +
-              "Please add them to the SystemMessage[Prefix]PermissionsTable.");
-        return null;
-      }
+      debug("'" + aSysMsgName + "' is not associated with permissions. " +
+            "Please add them to the SystemMessagePermissionsTable.");
+      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.");
+              "Please correct it in the SystemMessagePermissionsTable.");
         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.");
+              "Please correct it in the SystemMessagePermissionsTable.");
         return null;
       }
       object[permName] = appendAccessToPermName(permName, access);
     }
     return object
   },
 
   /**
--- a/dom/messages/interfaces/nsISystemMessagesInternal.idl
+++ b/dom/messages/interfaces/nsISystemMessagesInternal.idl
@@ -8,22 +8,20 @@ interface nsIURI;
 interface nsIDOMWindow;
 
 // Implemented by the contract id @mozilla.org/system-message-internal;1
 
 [scriptable, uuid(6296a314-2abf-4cd0-9097-5e81ee6832e2)]
 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.
+   * Allow any internal user to broadcast a message of a given type.
    * @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 pageURI     The URI of the page that will be opened.
    * @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.
    */
   void 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.