Backed out changeset 6da206d64b49 (bug 923625) for failing mochitest 3 on b2g ics
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Sat, 09 Nov 2013 10:06:10 +0100
changeset 154272 db2f368bf99991579f65e7494280d363d526ad90
parent 154271 e5f7246bf2158ac88b3e0727811925c467226d2e
child 154273 31d1b55d9c9bb6c309e2c83895b62c9401fb66a4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs923625
milestone28.0a1
backs out6da206d64b498094eabf05cb71140023ff843a52
Backed out changeset 6da206d64b49 (bug 923625) for failing mochitest 3 on b2g ics
dom/datastore/DataStoreService.js
dom/datastore/DataStoreServiceInternal.jsm
--- a/dom/datastore/DataStoreService.js
+++ b/dom/datastore/DataStoreService.js
@@ -231,21 +231,18 @@ DataStoreService.prototype = {
       // window, so we can skip the ipc communication.
       if (self.inParent) {
         let stores = self.getDataStoresInfo(aName, aWindow.document.nodePrincipal.appId);
         self.getDataStoreCreate(aWindow, resolve, stores);
       } else {
         // This method can be called in the child so we need to send a request
         // to the parent and create DataStore object here.
         new DataStoreServiceChild(aWindow, aName, function(aStores) {
-          debug("DataStoreServiceChild success callback!");
+          debug("DataStoreServiceChild callback!");
           self.getDataStoreCreate(aWindow, resolve, aStores);
-        }, function() {
-          debug("DataStoreServiceChild error callback!");
-          reject(new aWindow.DOMError("SecurityError", "Access denied"));
         });
       }
     });
   },
 
   getDataStoresInfo: function(aName, aAppId) {
     debug('GetDataStoresInfo');
 
@@ -423,45 +420,38 @@ DataStoreService.prototype = {
     contractID: '@mozilla.org/datastore-service;1',
     interfaces: [Ci.nsIDataStoreService, Ci.nsIObserver],
     flags: Ci.nsIClassInfo.SINGLETON
   })
 };
 
 /* DataStoreServiceChild */
 
-function DataStoreServiceChild(aWindow, aName, aSuccessCb, aErrorCb) {
+function DataStoreServiceChild(aWindow, aName, aCallback) {
   debug("DataStoreServiceChild created");
-  this.init(aWindow, aName, aSuccessCb, aErrorCb);
+  this.init(aWindow, aName, aCallback);
 }
 
 DataStoreServiceChild.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
-  init: function(aWindow, aName, aSuccessCb, aErrorCb) {
+  init: function(aWindow, aName, aCallback) {
     debug("DataStoreServiceChild init");
-    this._successCb = aSuccessCb;
-    this._errorCb = aErrorCb;
+    this._callback = aCallback;
 
-    this.initDOMRequestHelper(aWindow, [ "DataStore:Get:Return:OK",
-                                         "DataStore:Get:Return:KO" ]);
+    this.initDOMRequestHelper(aWindow, [ "DataStore:Get:Return" ]);
 
     // This is a security issue and it will be fixed by Bug 916091
     cpmm.sendAsyncMessage("DataStore:Get",
-                          { name: aName }, null, aWindow.document.nodePrincipal );
+                          { name: aName, appId: aWindow.document.nodePrincipal.appId });
   },
 
   receiveMessage: function(aMessage) {
     debug("DataStoreServiceChild receiveMessage");
+    if (aMessage.name != 'DataStore:Get:Return') {
+      return;
+    }
 
-    switch (aMessage.name) {
-      case 'DataStore:Get:Return:OK':
-        this._successCb(aMessage.data.stores);
-        break;
-
-      case 'DataStore:Get:Return:KO':
-        this._errorCb();
-        break;
-    }
+    this._callback(aMessage.data.stores);
   }
 }
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DataStoreService]);
--- a/dom/datastore/DataStoreServiceInternal.jsm
+++ b/dom/datastore/DataStoreServiceInternal.jsm
@@ -37,20 +37,15 @@ this.DataStoreServiceInternal = {
     debug("receiveMessage");
 
     if (aMessage.name != 'DataStore:Get') {
       return;
     }
 
     let msg = aMessage.data;
 
-    if (!aMessage.principal ||
-        aMessage.principal.appId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID) {
-      aMessage.target.sendAsyncMessage("DataStore:Get:Return:KO");
-      return;
-    }
-
-    msg.stores = dataStoreService.getDataStoresInfo(msg.name, aMessage.principal.appId);
-    aMessage.target.sendAsyncMessage("DataStore:Get:Return:OK", msg);
+    // This is a security issue and it will be fixed by Bug 916091
+    msg.stores = dataStoreService.getDataStoresInfo(msg.name, msg.appId);
+    aMessage.target.sendAsyncMessage("DataStore:Get:Return", msg);
   }
 }
 
 DataStoreServiceInternal.init();