Bug 899260 - System notifications are fired even if the message handler is not set in the manifest file of the app. r=gene
authorSean Lin <selin@mozilla.com>
Tue, 03 Jun 2014 18:27:12 +0800
changeset 205767 d8da0c9c67336d30be27ef1706e06e58e224d48d
parent 205766 29297cb8ce7012aef08f8dcb6dacd3a4df821356
child 205768 12f6d73e8fb1afc963343eaa3cc3794919ef52fb
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgene
bugs899260
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899260 - System notifications are fired even if the message handler is not set in the manifest file of the app. r=gene
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -659,41 +659,48 @@ this.DOMApplicationRegistry = {
     }
 
     if (!root.messages || !Array.isArray(root.messages) ||
         root.messages.length == 0) {
       return;
     }
 
     let manifest = new ManifestHelper(aManifest, aApp.origin);
-    let launchPath = Services.io.newURI(manifest.fullLaunchPath(aEntryPoint), null, null);
-    let manifestURL = Services.io.newURI(aApp.manifestURL, null, null);
+    let launchPathURI = Services.io.newURI(manifest.fullLaunchPath(aEntryPoint), null, null);
+    let manifestURI = Services.io.newURI(aApp.manifestURL, null, null);
     root.messages.forEach(function registerPages(aMessage) {
-      let href = launchPath;
+      let handlerPageURI = launchPathURI;
       let messageName;
       if (typeof(aMessage) === "object" && Object.keys(aMessage).length === 1) {
         messageName = Object.keys(aMessage)[0];
-        let uri;
+        let handlerPath = aMessage[messageName];
+        // Resolve the handler path from origin. If |handler_path| is absent,
+        // simply skip.
+        let fullHandlerPath;
         try {
-          uri = manifest.resolveFromOrigin(aMessage[messageName]);
+          if (handlerPath && handlerPath.trim()) {
+            fullHandlerPath = manifest.resolveFromOrigin(handlerPath);
+          } else {
+            throw new Error("Empty or blank handler path.");
+          }
         } catch(e) {
-          debug("system message url (" + aMessage[messageName] + ") is invalid, skipping. " +
-                "Error is: " + e);
+          debug("system message handler path (" + handlerPath + ") is " +
+                "invalid, skipping. Error is: " + e);
           return;
         }
-        href = Services.io.newURI(uri, null, null);
+        handlerPageURI = Services.io.newURI(fullHandlerPath, null, null);
       } else {
         messageName = aMessage;
       }
 
       if (SystemMessagePermissionsChecker
             .isSystemMessagePermittedToRegister(messageName,
                                                 aApp.origin,
                                                 aManifest)) {
-        msgmgr.registerPage(messageName, href, manifestURL);
+        msgmgr.registerPage(messageName, handlerPageURI, manifestURI);
       }
     });
   },
 
   // |aEntryPoint| is either the entry_point name or the null in which case we
   // use the root of the manifest.
   //
   // TODO Bug 908094 Refine _registerInterAppConnectionsForEntryPoint(...).
@@ -822,24 +829,24 @@ this.DOMApplicationRegistry = {
 
       if (aRunUpdate) {
         activitiesToRegister.push({ "manifest": aApp.manifestURL,
                                     "name": activity,
                                     "icon": manifest.iconURLForSize(128),
                                     "description": newDesc });
       }
 
-      let launchPath = Services.io.newURI(href, null, null);
-      let manifestURL = Services.io.newURI(aApp.manifestURL, null, null);
+      let launchPathURI = Services.io.newURI(href, null, null);
+      let manifestURI = Services.io.newURI(aApp.manifestURL, null, null);
 
       if (SystemMessagePermissionsChecker
             .isSystemMessagePermittedToRegister("activity",
                                                 aApp.origin,
                                                 aManifest)) {
-        msgmgr.registerPage("activity", launchPath, manifestURL);
+        msgmgr.registerPage("activity", launchPathURI, manifestURI);
       }
     }
     return activitiesToRegister;
   },
 
   // |aAppsToRegister| contains an array of apps to be registered, where
   // each element is an object in the format of {manifest: foo, app: bar}.
   _registerActivitiesForApps: function(aAppsToRegister, aRunUpdate) {