Fix contracts which were not registered correctly: nsPlacesAutoComplete.js was completely missing, and the nsINIParserFactory contract was missing. Fixes test_pref_interval.js to register/unregister its mock objects correctly.

This commit is contained in:
Benjamin Smedberg 2010-06-25 22:17:31 -04:00
parent 78a9ee8d61
commit bbefdf1c37
6 changed files with 27 additions and 27 deletions

View File

@ -87,7 +87,7 @@ EXTRA_COMPONENTS = \
$(NULL)
ifdef MOZ_XUL
EXTRA_COMPONENTS += nsPlacesAutoComplete.js
EXTRA_COMPONENTS += nsPlacesAutoComplete.js nsPlacesAutoComplete.manifest
endif
EXTRA_JS_MODULES = \

View File

@ -1072,9 +1072,7 @@ nsPlacesAutoComplete.prototype = {
//////////////////////////////////////////////////////////////////////////////
//// nsISupports
classDescription: "AutoComplete result generator for Places.",
classID: Components.ID("d0272978-beab-4adc-a3d4-04b76acfa4e7"),
contractID: "@mozilla.org/autocomplete/search;1?name=history",
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIAutoCompleteSearch,
@ -1084,11 +1082,5 @@ nsPlacesAutoComplete.prototype = {
])
};
////////////////////////////////////////////////////////////////////////////////
//// Module Registration
let components = [nsPlacesAutoComplete];
function NSGetModule(compMgr, fileSpec)
{
return XPCOMUtils.generateModule(components);
}
const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

View File

@ -0,0 +1,2 @@
component {d0272978-beab-4adc-a3d4-04b76acfa4e7} nsPlacesAutoComplete.js
contract @mozilla.org/autocomplete/search;1?name=history {d0272978-beab-4adc-a3d4-04b76acfa4e7}

View File

@ -1,16 +1,25 @@
# nsLivemarkService.js
component {dca61eb5-c7cd-4df1-b0fb-d0722baba251} nsLivemarkService.js
contract @mozilla.org/browser/livemark-service;2 {dca61eb5-c7cd-4df1-b0fb-d0722baba251}
# nsTaggingService.js
component {bbc23860-2553-479d-8b78-94d9038334f7} nsTaggingService.js
contract @mozilla.org/browser/tagging-service;1 {bbc23860-2553-479d-8b78-94d9038334f7}
component {1dcc23b0-d4cb-11dc-9ad6-479d56d89593 nsTaggingService.js
contract @mozilla.org/autocomplete/search;1?name=places-tag-autocomplete {1dcc23b0-d4cb-11dc-9ad6-479d56d89593
# nsPlacesDBFlush.js
component {c1751cfc-e8f1-4ade-b0bb-f74edfb8ef6a} nsPlacesDBFlush.js
contract @mozilla.org/places/sync;1 {c1751cfc-e8f1-4ade-b0bb-f74edfb8ef6a}
category bookmark-observers nsPlacesDBFlush @mozilla.org/places/sync;1
category history-observers nsPlacesDBFlush @mozilla.org/places/sync;1
# nsPlacesExpiration.js
component {705a423f-2f69-42f3-b9fe-1517e0dee56f} nsPlacesExpiration.js
contract @mozilla.org/places/expiration;1 {705a423f-2f69-42f3-b9fe-1517e0dee56f}
category history-observers nsPlacesExpiration @mozilla.org/places/expiration;1
# nsMicrosummaryService.js
component {460a9792-b154-4f26-a922-0f653e2c8f91} nsMicrosummaryService.js
contract @mozilla.org/microsummary/service;1 {460a9792-b154-4f26-a922-0f653e2c8f91}
# How often to check for generator updates, in seconds 7 * 86400 == 1 week

View File

@ -54,12 +54,12 @@ const DEFAULT_TIMER_DELAY_SECONDS = 3 * 60;
// Provide a mock timer implementation, so there is no need to wait seconds to
// achieve test results.
const Cm = Components.manager;
const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
const TIMER_CONTRACT_ID = "@mozilla.org/timer;1";
const kMockCID = Components.ID("52bdf457-4de3-48ae-bbbb-f3cbcbcad05f");
// Used to preserve the original timer factory.
let gOriginalFactory = Cm.getClassObjectByContractID(TIMER_CONTRACT_ID,
Ci.nsIFactory);
let gOriginalCID = Cm.contractIDToCID(TIMER_CONTRACT_ID);
// The mock timer factory.
let gMockTimerFactory = {
@ -94,12 +94,10 @@ let mockTimerImpl = {
}
function replace_timer_factory() {
let classInfo = gOriginalFactory.QueryInterface(Ci.nsIClassInfo);
let componentRegistrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
componentRegistrar.registerFactory(classInfo.classID,
"Mock " + classInfo.classDescription,
TIMER_CONTRACT_ID,
gMockTimerFactory);
Cm.registerFactory(kMockCID,
"Mock timer",
TIMER_CONTRACT_ID,
gMockTimerFactory);
}
do_register_cleanup(function() {
@ -108,14 +106,12 @@ do_register_cleanup(function() {
shutdownExpiration();
// Restore original timer factory.
let classInfo = gOriginalFactory.QueryInterface(Ci.nsIClassInfo);
let componentRegistrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
componentRegistrar.unregisterFactory(classInfo.classID,
gMockTimerFactory);
componentRegistrar.registerFactory(classInfo.classID,
classInfo.classDescription,
TIMER_CONTRACT_ID,
gOriginalFactory);
Cm.unregisterFactory(kMockCID,
gMockTimerFactory);
Cm.registerFactory(gOriginalCID,
"",
TIMER_CONTRACT_ID,
null);
});

View File

@ -313,6 +313,7 @@ const mozilla::Module::ContractIDEntry kXPCOMContracts[] = {
#include "XPCOMModule.inc"
{ NS_CHROMEREGISTRY_CONTRACTID, &kNS_CHROMEREGISTRY_CID },
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome", &kNS_CHROMEPROTOCOLHANDLER_CID },
{ NS_INIPARSERFACTORY_CONTRACTID, &kINIParserFactoryCID },
{ NULL }
};
#undef COMPONENT