Bug 1072152 - Change chrome.manifest read order. r=bsmedberg

In case of multiple "resource" manifest entries for the same keyword, the
last registered one now takes precedence, like any other chrome manifest
entry.
This commit is contained in:
Mike Hommey 2014-09-25 14:47:03 +09:00
parent f6e7817505
commit dc09a65056
4 changed files with 36 additions and 39 deletions

View File

@ -996,14 +996,6 @@ nsChromeRegistryChrome::ManifestResource(ManifestProcessingContext& cx, int line
nsCOMPtr<nsIResProtocolHandler> rph = do_QueryInterface(ph);
bool exists = false;
rv = rph->HasSubstitution(host, &exists);
if (exists) {
LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
"Duplicate resource declaration for '%s' ignored.", package);
return;
}
nsCOMPtr<nsIURI> resolved = cx.ResolveURI(uri);
if (!resolved) {
LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,

View File

@ -1,9 +1,6 @@
# Should work
resource test1 test1/
# Duplicates should be ignored
resource test1 foo/
# Mapping into jar files should work
resource test3 jar:test3.jar!/resources/

View File

@ -262,7 +262,7 @@ ComponentRegistrarInterposition.methods.registerFactory =
ComponentRegistrarInterposition.methods.unregisterFactory =
function(addon, target, class_, factory) {
AboutProtocolParent.tryUnregisterFactory(class_, factory);
AboutProtocolParent.unregisterFactory(class_, factory);
target.unregisterFactory(class_, factory);
};

View File

@ -374,25 +374,6 @@ nsComponentManagerImpl::Init()
GetLocationFromDirectoryService(NS_XPCOM_CURRENT_PROCESS_DIR);
InitializeStaticModules();
InitializeModuleLocations();
ComponentLocation* cl = sModuleLocations->InsertElementAt(0);
nsCOMPtr<nsIFile> lf = CloneAndAppend(appDir,
NS_LITERAL_CSTRING("chrome.manifest"));
cl->type = NS_COMPONENT_LOCATION;
cl->location.Init(lf);
bool equals = false;
appDir->Equals(greDir, &equals);
if (!equals) {
cl = sModuleLocations->InsertElementAt(0);
cl->type = NS_COMPONENT_LOCATION;
lf = CloneAndAppend(greDir, NS_LITERAL_CSTRING("chrome.manifest"));
cl->location.Init(lf);
}
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
("nsComponentManager: Initialized."));
nsresult rv = mNativeModuleLoader.Init();
if (NS_FAILED(rv)) {
@ -407,21 +388,45 @@ nsComponentManagerImpl::Init()
RegisterModule((*sStaticModules)[i], nullptr);
}
nsRefPtr<nsZipArchive> appOmnijar =
mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
if (appOmnijar) {
cl = sModuleLocations->InsertElementAt(1); // Insert after greDir
cl->type = NS_COMPONENT_LOCATION;
cl->location.Init(appOmnijar, "chrome.manifest");
}
// The overall order in which chrome.manifests are expected to be treated
// is the following:
// - greDir
// - greDir's omni.ja
// - appDir
// - appDir's omni.ja
InitializeModuleLocations();
ComponentLocation* cl = sModuleLocations->AppendElement();
nsCOMPtr<nsIFile> lf = CloneAndAppend(greDir,
NS_LITERAL_CSTRING("chrome.manifest"));
cl->type = NS_COMPONENT_LOCATION;
cl->location.Init(lf);
nsRefPtr<nsZipArchive> greOmnijar =
mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
if (greOmnijar) {
cl = sModuleLocations->InsertElementAt(0);
cl = sModuleLocations->AppendElement();
cl->type = NS_COMPONENT_LOCATION;
cl->location.Init(greOmnijar, "chrome.manifest");
}
bool equals = false;
appDir->Equals(greDir, &equals);
if (!equals) {
cl = sModuleLocations->AppendElement();
cl->type = NS_COMPONENT_LOCATION;
lf = CloneAndAppend(appDir, NS_LITERAL_CSTRING("chrome.manifest"));
cl->location.Init(lf);
}
nsRefPtr<nsZipArchive> appOmnijar =
mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
if (appOmnijar) {
cl = sModuleLocations->AppendElement();
cl->type = NS_COMPONENT_LOCATION;
cl->location.Init(appOmnijar, "chrome.manifest");
}
RereadChromeManifests(false);
nsCategoryManager::GetSingleton()->SuppressNotifications(false);
@ -434,6 +439,9 @@ nsComponentManagerImpl::Init()
// point. So we wait until now.
nsCategoryManager::GetSingleton()->InitMemoryReporter();
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
("nsComponentManager: Initialized."));
mStatus = NORMAL;
return NS_OK;