Bug 1131317 - Always unwrap objects before wrapping them in XPCWrappedJS (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Wed, 18 Feb 2015 10:42:28 -0800
changeset 229717 e3459498439288ad480a3fd15785c3713d24d580
parent 229716 b7d9158b53e746bb336a75aec3f22ad700028115
child 229718 4dfa3991e9ca81dbf19cb6c8a5ce2f1ab04e7d8e
push id28294
push userryanvm@gmail.com
push dateThu, 19 Feb 2015 01:30:38 +0000
treeherdermozilla-central@360b5f211180 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1131317
milestone38.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 1131317 - Always unwrap objects before wrapping them in XPCWrappedJS (r=mrbkap)
dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
js/xpconnect/loader/XPCOMUtils.jsm
js/xpconnect/src/XPCWrappedJSClass.cpp
--- a/dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
+++ b/dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
@@ -37,21 +37,21 @@ function finish() {
 
 if (OfflineTest.setup()) {
   obs.notifyObservers(updateService, "disk-space-watcher", "full");
 
   var updateObserver = {
     updateStateChanged: function (aUpdate, aState) {
       switch(aState) {
         case Ci.nsIOfflineCacheUpdateObserver.STATE_ERROR:
-          aUpdate.removeObserver(this);
           errorReceived = true;
           OfflineTest.ok(true, "Expected error. Update canceled");
         break;
         case Ci.nsIOfflineCacheUpdateObserver.STATE_FINISHED:
+          aUpdate.removeObserver(this);
           OfflineTest.ok(errorReceived,
                          "Finished after receiving the expected error");
           finish();
         break;
         case Ci.nsIOfflineCacheUpdateObserver.STATE_NOUPDATE:
           aUpdate.removeObserver(this);
           OfflineTest.ok(false, "No update");
           finish();
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -285,17 +285,18 @@ this.XPCOMUtils = {
   _getFactory: function XPCOMUtils__getFactory(component) {
     var factory = component.prototype._xpcom_factory;
     if (!factory) {
       factory = {
         createInstance: function(outer, iid) {
           if (outer)
             throw Cr.NS_ERROR_NO_AGGREGATION;
           return (new component()).QueryInterface(iid);
-        }
+        },
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
       }
     }
     return factory;
   },
 
   /**
    * Allows you to fake a relative import. Expects the global object from the
    * module that's calling us, and the relative filename that we wish to import.
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -587,17 +587,17 @@ nsXPCWrappedJSClass::DelegatedQueryInter
 
 JSObject*
 nsXPCWrappedJSClass::GetRootJSObject(JSContext* cx, JSObject* aJSObjArg)
 {
     RootedObject aJSObj(cx, aJSObjArg);
     JSObject* result = CallQueryInterfaceOnJSObject(cx, aJSObj,
                                                     NS_GET_IID(nsISupports));
     if (!result)
-        return aJSObj;
+        result = aJSObj;
     JSObject* inner = js::UncheckedUnwrap(result);
     if (inner)
         return inner;
     return result;
 }
 
 bool
 nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,