Bug 1171915 - about:serviceworkers in b2g should use originAttributes when calling ServiceWorkerManager. r=baku,fabrice
authorJose Antonio Olivera Ortega <jaoo@jaoo.es>
Thu, 25 Jun 2015 13:14:33 -0700
changeset 268284 56b26cd91e76a3a220acf7730613e5f55142987d
parent 268283 650bc9b85a143cb58b8dd2ea07464dff048b4623
child 268285 87596dc882dc29cec72e50d0b50a0d8b148a0971
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, fabrice
bugs1171915
milestone41.0a1
Bug 1171915 - about:serviceworkers in b2g should use originAttributes when calling ServiceWorkerManager. r=baku,fabrice
b2g/components/AboutServiceWorkers.jsm
--- a/b2g/components/AboutServiceWorkers.jsm
+++ b/b2g/components/AboutServiceWorkers.jsm
@@ -14,35 +14,34 @@ Cu.import("resource://gre/modules/XPCOMU
 XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
                                   "resource://gre/modules/SystemAppProxy.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gServiceWorkerManager",
                                   "@mozilla.org/serviceworkers/manager;1",
                                   "nsIServiceWorkerManager");
 
 function debug(aMsg) {
-  //dump("AboutServiceWorkers - " + aMsg + "\n");
+  // dump("AboutServiceWorkers - " + aMsg + "\n");
 }
 
 function serializeServiceWorkerInfo(aServiceWorkerInfo) {
   if (!aServiceWorkerInfo) {
     throw new Error("Invalid service worker information");
   }
 
   let result = {};
 
   Object.keys(aServiceWorkerInfo).forEach(property => {
     if (typeof aServiceWorkerInfo[property] == "function") {
       return;
     }
     if (property === "principal") {
       result.principal = {
         origin: aServiceWorkerInfo.principal.origin,
-        appId: aServiceWorkerInfo.principal.appId,
-        isInBrowser: aServiceWorkerInfo.principal.isInBrowser
+        originAttributes: aServiceWorkerInfo.principal.originAttributes
       };
       return;
     }
     result[property] = aServiceWorkerInfo[property];
   });
 
   return result;
 }
@@ -128,42 +127,46 @@ this.AboutServiceWorkers = {
       case "update":
         if (!message.scope) {
           self.sendError(message.id, "MissingScope");
           return;
         }
 
         if (!message.principal ||
             !message.principal.originAttributes) {
-          // XXX This will always error until bug 1171915 is fixed.
           self.sendError(message.id, "MissingOriginAttributes");
           return;
         }
 
-        gServiceWorkerManager.propagateSoftUpdate({},
-                                                  message.scope);
+        gServiceWorkerManager.propagateSoftUpdate(
+          message.principal.originAttributes,
+          message.scope
+        );
+
         self.sendResult(message.id, true);
         break;
 
       case "unregister":
         if (!message.principal ||
             !message.principal.origin ||
-            !message.principal.appId) {
-          self.sendError("MissingPrincipal");
+            !message.principal.originAttributes ||
+            !message.principal.originAttributes.appId ||
+            !message.principal.originAttributes.isInBrowser) {
+          self.sendError(message.id, "MissingPrincipal");
           return;
         }
 
         let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
           Services.io.newURI(message.principal.origin, null, null),
-          message.principal.appId,
-          message.principal.isInBrowser
+          message.principal.originAttributes.appId,
+          message.principal.originAttributes.isInBrowser
         );
 
         if (!message.scope) {
-          self.sendError("MissingScope");
+          self.sendError(message.id, "MissingScope");
           return;
         }
 
         let serviceWorkerUnregisterCallback = {
           unregisterSucceeded: function() {
             self.sendResult(message.id, true);
           },