Skip to content

Commit

Permalink
Bug 1514936, part 1 - Remove the outer argument to nsIFactory::create…
Browse files Browse the repository at this point in the history
…Instance. r=xpcom-reviewers,preferences-reviewers,nika,Gijs

This patch won't actually build, because a few bits of code are used
for both nsIFactory::createInstance and static components, and static
components are not fixed until the next patch.

The first place is nsLoadGroupConstructor, which uses an nsIFactory
macro to create a static component constructor. (This could be worked
around by expanding the macro to the state before this patch.)

The other issue is that nsAppShellConstructor is used in an nsIFactory
on OSX, but as a static component on all other platforms. This could
be worked around by wrapping nsAppShellConstructor in an adaptor that
passes in the extra null argument to nsAppShellConstructor.

Differential Revision: https://phabricator.services.mozilla.com/D146456
  • Loading branch information
amccreight committed May 17, 2022
1 parent 02b1121 commit f62cc91
Show file tree
Hide file tree
Showing 80 changed files with 112 additions and 325 deletions.
2 changes: 1 addition & 1 deletion accessible/tests/mochitest/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ AutoCompleteSearch.prototype = {
]),

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions browser/base/content/test/general/browser_bug356571.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ const kPromptServiceFactory = Cm.getClassObject(
);

var fakePromptServiceFactory = {
createInstance(aOuter, aIid) {
if (aOuter != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIid) {
return promptService.QueryInterface(aIid);
},
};
Expand Down
5 changes: 1 addition & 4 deletions browser/base/content/test/tabs/browser_e10s_about_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ AboutModule.prototype = {
};

var AboutModuleFactory = {
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
return new AboutModule().QueryInterface(aIID);
},

Expand Down
2 changes: 1 addition & 1 deletion browser/components/enterprisepolicies/Policies.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,7 @@ let ChromeURLBlockPolicy = {
contractID: "@mozilla-org/policy-engine-content-policy-service;1",
classID: Components.ID("{ba7b9118-cabc-4845-8b26-4215d2a59ed7}"),
QueryInterface: ChromeUtils.generateQI(["nsIContentPolicy"]),
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ let WebsiteFilter = {
"nsIObserver",
"nsISupportsWeakReference",
]),
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},
isAllowed(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ const mockUpdateManager = {

QueryInterface: ChromeUtils.generateQI(["nsIUpdateManager"]),

createInstance(outer, iiD) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iiD) {
return this.QueryInterface(iiD);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ let TestAboutPage = {
return channel;
},

createInstance(outer, iid) {
if (outer != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions chrome/test/unit/test_data_protocol_registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function run_test() {
CID: uuidGenerator.generateUUID(),
scheme: "XULAppInfo",
contractID: XULAPPINFO_CONTRACTID,
createInstance(outer, iid) {
if (outer != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return XULAppInfo.QueryInterface(iid);
},
};
Expand Down
10 changes: 2 additions & 8 deletions chrome/test/unit/test_no_remote_registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ function run_test() {
CID: uuidGenerator.generateUUID(),
scheme: "XULAppInfo",
contractID: "@mozilla.org/xre/app-info;1",
createInstance(outer, iid) {
if (outer != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return XULAppInfo.QueryInterface(iid);
},
};
Expand All @@ -91,10 +88,7 @@ function run_test() {
CID: testProtocols[i].CID,
contractID:
"@mozilla.org/network/protocol;1?name=" + testProtocols[i].scheme,
createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
let handler = new ProtocolHandler(this.scheme, this.flags, this.CID);
return handler.QueryInterface(aIID);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
2 changes: 1 addition & 1 deletion dom/base/test/test_bug375314-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]),

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
2 changes: 1 addition & 1 deletion dom/base/test/test_bug375314.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
2 changes: 1 addition & 1 deletion dom/base/test/test_bug498897.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions dom/browser-element/BrowserElementPromptService.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,7 @@ var BrowserElementPromptService = {
var newInstance = new BrowserElementPromptFactory(oldInstance);

var newFactory = {
createInstance(outer, iid) {
if (outer != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return newInstance.QueryInterface(iid);
},
};
Expand Down
5 changes: 1 addition & 4 deletions dom/media/PeerConnection.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ setupPrototype(GlobalPCList, {
]),
classID: PC_MANAGER_CID,
_xpcom_factory: {
createInstance(outer, iid) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return _globalPCList.QueryInterface(iid);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance: function(aOuter, aIID) {
if (aOuter != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance: function(aIID) {
return this.QueryInterface(aIID);
}
};
Expand Down
5 changes: 1 addition & 4 deletions dom/notification/test/mochitest/MockServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ var MockServices = (function() {
throw SpecialPowers.Components.results.NS_ERROR_NO_INTERFACE;
},

createInstance(aOuter, aIID) {
if (aOuter != null) {
throw SpecialPowers.Components.results.NS_ERROR_NO_AGGREGATION;
}
createInstance(aIID) {
return this.QueryInterface(aIID);
},
};
Expand Down
5 changes: 1 addition & 4 deletions dom/notification/test/mochitest/test_notification_tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
return this.QueryInterface(aIID);
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]),

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions dom/serviceworkers/test/browser_userContextId_openWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ let mockAlertsService = {
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
return this.QueryInterface(aIID);
},
};
Expand Down
4 changes: 2 additions & 2 deletions dom/tests/mochitest/beacon/test_beaconContentPolicy.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
return this;
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
},

// nsIFactory implementation
createInstance(outer, iid) {
createInstance(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions dom/tests/unit/test_geolocation_reset_accuracy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var provider = {
"nsIFactory",
"nsIGeolocationProvider",
]),
createInstance: function eventsink_ci(outer, iid) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance: function eventsink_ci(iid) {
return this.QueryInterface(iid);
},
startup() {},
Expand Down
5 changes: 1 addition & 4 deletions dom/tests/unit/test_geolocation_reset_accuracy_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var provider = {
"nsIFactory",
"nsIGeolocationProvider",
]),
createInstance: function eventsink_ci(outer, iid) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance: function eventsink_ci(iid) {
return this.QueryInterface(iid);
},
startup() {},
Expand Down
9 changes: 2 additions & 7 deletions js/xpconnect/loader/ComponentUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ var ComponentUtils = {
var factory = component.prototype._xpcom_factory;
if (!factory) {
factory = {
createInstance: function(outer, iid) {
if (outer)
throw Cr.NS_ERROR_NO_AGGREGATION;
createInstance: function(iid) {
return (new component()).QueryInterface(iid);
},
QueryInterface: nsIFactoryQI
Expand All @@ -107,10 +105,7 @@ var ComponentUtils = {
function XPCOMUtils_generateSingletonFactory(aServiceConstructor) {
return {
_instance: null,
createInstance: function XPCU_SF_createInstance(aOuter, aIID) {
if (aOuter !== null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
createInstance: function XPCU_SF_createInstance(aIID) {
if (this._instance === null) {
this._instance = new aServiceConstructor();
}
Expand Down
4 changes: 1 addition & 3 deletions js/xpconnect/tests/unit/test_xpcomutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ add_test(function test_categoryRegistration()
platformVersion: "",
});
let XULAppInfoFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
createInstance: function (iid) {
return XULAppInfo.QueryInterface(iid);
}
};
Expand Down
5 changes: 1 addition & 4 deletions netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ CustomProtocolHandler.prototype = {
},

/** nsIFactory */
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
return this.QueryInterface(aIID);
},

Expand Down
5 changes: 1 addition & 4 deletions netwerk/test/unit/test_about_protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ var unsafeAboutModule = {
};

var factory = {
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(aIID) {
return unsafeAboutModule.QueryInterface(aIID);
},
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
Expand Down
8 changes: 1 addition & 7 deletions netwerk/test/unit/test_bug894586.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,7 @@ ProtocolHandler.prototype = {
Ci.nsIRequest.LOAD_BYPASS_CACHE,

/** nsIFactory */
createInstance(aOuter, aIID) {
if (aOuter) {
throw Components.Exception(
"createInstance no aggregation",
Cr.NS_ERROR_NO_AGGREGATION
);
}
createInstance(aIID) {
return this.QueryInterface(aIID);
},

Expand Down
5 changes: 1 addition & 4 deletions netwerk/test/unit/test_content_sniffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ var isNosniff = false;
*/
var sniffer = {
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIContentSniffer"]),
createInstance: function sniffer_ci(outer, iid) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance: function sniffer_ci(iid) {
return this.QueryInterface(iid);
},

Expand Down
5 changes: 1 addition & 4 deletions netwerk/test/unit/test_event_sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const categoryName = "net-channel-event-sinks";
*/
var eventsink = {
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIChannelEventSink"]),
createInstance: function eventsink_ci(outer, iid) {
if (outer) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance: function eventsink_ci(iid) {
return this.QueryInterface(iid);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TestProtocolHandler.prototype = {

function TestProtocolHandlerFactory() {}
TestProtocolHandlerFactory.prototype = {
createInstance(delegate, iid) {
createInstance(iid) {
return new TestProtocolHandler().QueryInterface(iid);
},
};
Expand Down
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_protocolproxyservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TestProtocolHandler.prototype = {

function TestProtocolHandlerFactory() {}
TestProtocolHandlerFactory.prototype = {
createInstance(delegate, iid) {
createInstance(iid) {
return new TestProtocolHandler().QueryInterface(iid);
},
};
Expand Down
5 changes: 1 addition & 4 deletions security/manager/ssl/tests/unit/test_pkcs11_safe_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ function run_test() {
};

let xulRuntimeFactory = {
createInstance(outer, iid) {
if (outer != null) {
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
createInstance(iid) {
return xulRuntime.QueryInterface(iid);
},
};
Expand Down
Loading

0 comments on commit f62cc91

Please sign in to comment.