Bug 1366896, part 2 - Add and use Cc.Initialize method. r=gabor draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 24 May 2017 14:12:11 -0700
changeset 650159 f8ccd8ffb5ed8504554cc2092f9c2066005c0a35
parent 650158 8111ff6edea5aef4525bc3a538c558a6f4a0cbaf
child 650160 2663d651c7556f5e9f4817630ba9266ddb3e6527
push id75288
push userbmo:continuation@gmail.com
push dateMon, 21 Aug 2017 22:42:18 +0000
reviewersgabor
bugs1366896
milestone57.0a1
Bug 1366896, part 2 - Add and use Cc.Initialize method. r=gabor MozReview-Commit-ID: Amqt9JsTMqG
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
testing/modules/AppInfo.jsm
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -39,16 +39,18 @@ interface nsIXPCComponents_Interfaces : 
 
 /**
 * interface of Components.classes
 * (interesting stuff only reflected into JavaScript)
 */
 [scriptable, uuid(978ff520-d26c-11d2-9842-006008962422)]
 interface nsIXPCComponents_Classes : nsISupports
 {
+  // Make it so that |cid| gets mapped to |idString|.
+  void initialize(in nsIJSCID cid, in string idString);
 };
 
 /**
 * interface of Components.classesByID
 * (interesting stuff only reflected into JavaScript)
 */
 [scriptable, uuid(336a9590-4d19-11d3-9893-006008962422)]
 interface nsIXPCComponents_ClassesByID : nsISupports
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -749,16 +749,24 @@ nsXPCComponents_Classes::Resolve(nsIXPCo
                                                      JSPROP_RESOLVING);
                 }
             }
         }
     }
     return NS_OK;
 }
 
+NS_IMETHODIMP
+nsXPCComponents_Classes::Initialize(nsIJSCID* cid,
+                                    const char* str)
+{
+    return cid->Initialize(str);
+}
+
+
 /***************************************************************************/
 /***************************************************************************/
 /***************************************************************************/
 
 class nsXPCComponents_ClassesByID final :
   public nsIXPCComponents_ClassesByID,
   public nsIXPCScriptable,
   public nsIClassInfo
--- a/testing/modules/AppInfo.jsm
+++ b/testing/modules/AppInfo.jsm
@@ -124,10 +124,15 @@ this.updateAppInfo = function(options) {
         throw Cr.NS_ERROR_NO_AGGREGATION;
       }
 
       return currentAppInfo.QueryInterface(iid);
     },
   };
 
   registrar.registerFactory(id, "XULAppInfo", cid, factory);
+
+  // Ensure that Cc actually maps cid to the new shim AppInfo. This is
+  // needed when JSM global sharing is enabled, because some prior
+  // code may already have looked up |Cc[cid]|.
+  Cc.initialize(Cc[cid], cid);
 };