diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 0080a4bf21d3..9e46b6dcc3eb 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -886,10 +886,6 @@ 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); diff --git a/dom/datastore/DataStoreChangeNotifier.jsm b/dom/datastore/DataStoreChangeNotifier.jsm index bbf44a1f7ced..64951f3ca43c 100644 --- a/dom/datastore/DataStoreChangeNotifier.jsm +++ b/dom/datastore/DataStoreChangeNotifier.jsm @@ -23,33 +23,12 @@ 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"); @@ -80,8 +59,7 @@ this.DataStoreChangeNotifier = { }, 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); @@ -89,69 +67,6 @@ this.DataStoreChangeNotifier = { }); }, - 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 "); @@ -174,7 +89,6 @@ this.DataStoreChangeNotifier = { switch (aMessage.name) { case "DataStore:Changed": this.broadcastMessage(aMessage.data); - this.setSystemMessageTimeout(aMessage.data.store, aMessage.data.owner); break; case "DataStore:RegisterForMessages": diff --git a/dom/datastore/DataStoreService.cpp b/dom/datastore/DataStoreService.cpp index 580246bc54be..a30a513a8d79 100644 --- a/dom/datastore/DataStoreService.cpp +++ b/dom/datastore/DataStoreService.cpp @@ -33,11 +33,9 @@ #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" @@ -377,24 +375,6 @@ GetDataStoreInfosEnumerator(const uint32_t& aAppId, return PL_DHASH_NEXT; } -PLDHashOperator -GetAppManifestURLsEnumerator(const uint32_t& aAppId, - DataStoreInfo* aInfo, - void* aUserData) -{ - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); - - auto* manifestURLs = static_cast(aUserData); - nsCOMPtr 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 { @@ -1077,31 +1057,6 @@ DataStoreService::GetDataStoreInfos(const nsAString& aName, return NS_OK; } -NS_IMETHODIMP -DataStoreService::GetAppManifestURLsForDataStore(const nsAString& aName, - nsIArray** aManifestURLs) -{ - ASSERT_PARENT_PROCESS() - MOZ_ASSERT(NS_IsMainThread()); - - nsCOMPtr 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) { diff --git a/dom/datastore/nsIDataStoreService.idl b/dom/datastore/nsIDataStoreService.idl index adb2b2f50ff7..b2b3d658630c 100644 --- a/dom/datastore/nsIDataStoreService.idl +++ b/dom/datastore/nsIDataStoreService.idl @@ -7,9 +7,8 @@ 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, @@ -28,7 +27,5 @@ interface nsIDataStoreService : nsISupports in DOMString name, in DOMString owner); - nsIArray getAppManifestURLsForDataStore(in DOMString name); - boolean checkPermission(in nsIPrincipal principal); }; diff --git a/dom/datastore/tests/file_notify_system_message.html b/dom/datastore/tests/file_notify_system_message.html deleted file mode 100644 index 05e9153cd07d..000000000000 --- a/dom/datastore/tests/file_notify_system_message.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - Test for DataStore - notify updates with system messages - - -

- -
-  
-
- - diff --git a/dom/datastore/tests/mochitest.ini b/dom/datastore/tests/mochitest.ini index e1ca2818206b..fd3972597dbe 100644 --- a/dom/datastore/tests/mochitest.ini +++ b/dom/datastore/tests/mochitest.ini @@ -30,7 +30,6 @@ support-files = file_sync_common.js file_bug1008044.html file_bug957086.html - file_notify_system_message.html [test_app_install.html] [test_readonly.html] @@ -51,5 +50,3 @@ support-files = [test_transactions.html] [test_bug1008044.html] [test_bug957086.html] -[test_notify_system_message.html] -skip-if = toolkit == 'gonk' # b2g diff --git a/dom/datastore/tests/test_app_install.html b/dom/datastore/tests/test_app_install.html index 8c326d337048..c03f249326d0 100644 --- a/dom/datastore/tests/test_app_install.html +++ b/dom/datastore/tests/test_app_install.html @@ -10,6 +10,10 @@
diff --git a/dom/datastore/tests/test_basic.html b/dom/datastore/tests/test_basic.html index c774b146c9f9..25d6637ef505 100644 --- a/dom/datastore/tests/test_basic.html +++ b/dom/datastore/tests/test_basic.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_basic_worker.html b/dom/datastore/tests/test_basic_worker.html index 70fadecd8fa1..be940e8771b1 100644 --- a/dom/datastore/tests/test_basic_worker.html +++ b/dom/datastore/tests/test_basic_worker.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_bug1008044.html b/dom/datastore/tests/test_bug1008044.html index c22131f2379c..97164c396cad 100644 --- a/dom/datastore/tests/test_bug1008044.html +++ b/dom/datastore/tests/test_bug1008044.html @@ -77,18 +77,12 @@ // 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(); @@ -123,6 +117,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_bug924104.html b/dom/datastore/tests/test_bug924104.html index 3896a108b302..5b22acf11dbd 100644 --- a/dom/datastore/tests/test_bug924104.html +++ b/dom/datastore/tests/test_bug924104.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_bug957086.html b/dom/datastore/tests/test_bug957086.html index ac8f31ee09b1..1abb1f4c1538 100644 --- a/dom/datastore/tests/test_bug957086.html +++ b/dom/datastore/tests/test_bug957086.html @@ -81,18 +81,12 @@ // 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(); @@ -130,6 +124,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_bug976311.html b/dom/datastore/tests/test_bug976311.html index 35f9aba480a5..4922dd2db350 100644 --- a/dom/datastore/tests/test_bug976311.html +++ b/dom/datastore/tests/test_bug976311.html @@ -82,17 +82,11 @@ // 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(); @@ -130,6 +124,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_bug986056.html b/dom/datastore/tests/test_bug986056.html index 3d14cb666c5d..2376f71483ce 100644 --- a/dom/datastore/tests/test_bug986056.html +++ b/dom/datastore/tests/test_bug986056.html @@ -75,17 +75,12 @@ // 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); }, @@ -139,6 +134,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_certifiedApp.html b/dom/datastore/tests/test_certifiedApp.html index e4a328c2d0d9..0b78ccbc8146 100644 --- a/dom/datastore/tests/test_certifiedApp.html +++ b/dom/datastore/tests/test_certifiedApp.html @@ -77,8 +77,6 @@ // 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); }, @@ -91,10 +89,6 @@ }, function() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); - } - SpecialPowers.setAllAppsLaunchable(true); SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); runTest(); @@ -129,6 +123,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_changes.html b/dom/datastore/tests/test_changes.html index c2a67b1addd2..434c4c0f4c7f 100644 --- a/dom/datastore/tests/test_changes.html +++ b/dom/datastore/tests/test_changes.html @@ -121,17 +121,12 @@ // 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); }, @@ -174,6 +169,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_duplicate.html b/dom/datastore/tests/test_duplicate.html index 8589d4408261..e9ecca2ab9a4 100644 --- a/dom/datastore/tests/test_duplicate.html +++ b/dom/datastore/tests/test_duplicate.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_keys.html b/dom/datastore/tests/test_keys.html index 9bc2ac2b88b8..dced0354ef3b 100644 --- a/dom/datastore/tests/test_keys.html +++ b/dom/datastore/tests/test_keys.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_notify_system_message.html b/dom/datastore/tests/test_notify_system_message.html deleted file mode 100644 index dc32f79f5a5f..000000000000 --- a/dom/datastore/tests/test_notify_system_message.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - Test for DataStore - notify updates with system messages - - - - -
- - - diff --git a/dom/datastore/tests/test_oop.html b/dom/datastore/tests/test_oop.html index e275b2d1b3d1..989904341e67 100644 --- a/dom/datastore/tests/test_oop.html +++ b/dom/datastore/tests/test_oop.html @@ -77,18 +77,12 @@ // 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(); @@ -123,6 +117,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_oop_events.html b/dom/datastore/tests/test_oop_events.html index c57f93de6572..d97d674c8a91 100644 --- a/dom/datastore/tests/test_oop_events.html +++ b/dom/datastore/tests/test_oop_events.html @@ -105,18 +105,12 @@ // 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(); @@ -153,6 +147,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_readonly.html b/dom/datastore/tests/test_readonly.html index 52541cd26186..559b8d0f3eb6 100644 --- a/dom/datastore/tests/test_readonly.html +++ b/dom/datastore/tests/test_readonly.html @@ -30,10 +30,6 @@ } function runTest() { - if (SpecialPowers.isMainProcess()) { - SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); - } - SpecialPowers.setAllAppsLaunchable(true); SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); @@ -99,10 +95,12 @@ 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); diff --git a/dom/datastore/tests/test_sync.html b/dom/datastore/tests/test_sync.html index 15ab46c910c5..b45472c88ba2 100644 --- a/dom/datastore/tests/test_sync.html +++ b/dom/datastore/tests/test_sync.html @@ -77,17 +77,11 @@ // 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(); }, @@ -121,6 +115,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_sync_worker.html b/dom/datastore/tests/test_sync_worker.html index 4e1d5d0507f3..904edea96e8f 100644 --- a/dom/datastore/tests/test_sync_worker.html +++ b/dom/datastore/tests/test_sync_worker.html @@ -77,17 +77,11 @@ // 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(); }, @@ -121,6 +115,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/datastore/tests/test_transactions.html b/dom/datastore/tests/test_transactions.html index 26d974aa1cb1..7607b11fa5c3 100644 --- a/dom/datastore/tests/test_transactions.html +++ b/dom/datastore/tests/test_transactions.html @@ -77,17 +77,11 @@ // 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(); @@ -122,6 +116,10 @@ SimpleTest.finish(); } + if (SpecialPowers.isMainProcess()) { + SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm"); + } + SimpleTest.waitForExplicitFinish(); runTest(); diff --git a/dom/messages/SystemMessageInternal.js b/dom/messages/SystemMessageInternal.js index 74e24e38129d..727086896264 100644 --- a/dom/messages/SystemMessageInternal.js +++ b/dom/messages/SystemMessageInternal.js @@ -192,48 +192,31 @@ SystemMessageInternal.prototype = { // 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 page = this._findPage(aType, aPageURI.spec, aManifestURI.spec); + if (page) { + // Queue this message in the corresponding pages. + this._queueMessage(page, aMessage, messageID); - let result = this._sendMessageCommon(aType, - aMessage, - messageID, - aPageURL, - manifestURL, - 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; - } - - 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) { diff --git a/dom/messages/SystemMessagePermissionsChecker.jsm b/dom/messages/SystemMessagePermissionsChecker.jsm index 89bcf6757349..433c87598754 100644 --- a/dom/messages/SystemMessagePermissionsChecker.jsm +++ b/dom/messages/SystemMessagePermissionsChecker.jsm @@ -15,8 +15,7 @@ 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"); @@ -123,18 +122,6 @@ this.SystemMessagePermissionsTable = { } }; -// 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. @@ -153,26 +140,16 @@ this.SystemMessagePermissionsChecker = { 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; } @@ -180,7 +157,7 @@ this.SystemMessagePermissionsChecker = { 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); diff --git a/dom/messages/interfaces/nsISystemMessagesInternal.idl b/dom/messages/interfaces/nsISystemMessagesInternal.idl index 450206b2ba55..8df78278f076 100644 --- a/dom/messages/interfaces/nsISystemMessagesInternal.idl +++ b/dom/messages/interfaces/nsISystemMessagesInternal.idl @@ -13,12 +13,10 @@ interface nsIDOMWindow; 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.