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
Родитель c8ae3e0b2f
Коммит 11e51cf582
4 изменённых файлов: 36 добавлений и 39 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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/

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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;