author | Ehsan Akhgari <ehsan@mozilla.com> |
Fri, 22 Jul 2011 19:02:47 -0400 | |
changeset 74285 | 0017163dc00339fa2ff769d7650398c55f22c6f6 |
parent 74284 | 0a532134fdd64153c01c94e654ef86ff2b66293b |
child 74286 | 99f8219d08d36ce0965bfee2c78cbfd4c3afd825 |
push id | 67 |
push user | clegnitto@mozilla.com |
push date | Fri, 04 Nov 2011 22:39:41 +0000 |
treeherder | mozilla-release@04778346a3b0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 564667 |
milestone | 8.0a1 |
backs out | ed32cfcfd3f05aaf3af9079c368dd46826ad4b1d |
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
|
chrome/test/unit/data/test_bug564667.xpi | file | annotate | diff | comparison | revisions | |
chrome/test/unit/data/test_bug564667/chrome.manifest | file | annotate | diff | comparison | revisions | |
chrome/test/unit/data/test_bug564667/loaded.manifest | file | annotate | diff | comparison | revisions | |
chrome/test/unit/test_bug564667.js | file | annotate | diff | comparison | revisions | |
chrome/test/unit/xpcshell.ini | file | annotate | diff | comparison | revisions | |
xpcom/build/nsXULAppAPI.h | file | annotate | diff | comparison | revisions | |
xpcom/components/ManifestParser.cpp | file | annotate | diff | comparison | revisions | |
xpcom/components/nsComponentManager.cpp | file | annotate | diff | comparison | revisions | |
xpcom/components/nsComponentManager.h | file | annotate | diff | comparison | revisions | |
xpcom/components/nsIComponentManager.idl | file | annotate | diff | comparison | revisions |
deleted file mode 100644 index be1632d8ca90969c3835124b7d8308360d744cea..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch literal 0 Hc$@<O00001
deleted file mode 100644 --- a/chrome/test/unit/data/test_bug564667/chrome.manifest +++ /dev/null @@ -1,16 +0,0 @@ -# Locally defined URLs -content test1 test/ -locale test1 en-US test/ -skin test1 test test/ - -# Test Override -content testOverride test/ -override chrome://testOverride/content file:///test1/override - - -# Load external manifest -manifest loaded.manifest - -# Failure Cases -overlay chrome://test1/content/overlay.xul chrome://test1/content/test1.xul -style chrome://test1/content/style.xul chrome://test1/content/test1.css
deleted file mode 100644 --- a/chrome/test/unit/data/test_bug564667/loaded.manifest +++ /dev/null @@ -1,2 +0,0 @@ -content test2 test/ -locale test2 en-US test/
deleted file mode 100644 --- a/chrome/test/unit/test_bug564667.js +++ /dev/null @@ -1,155 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Hernan Rodriguez Colmeiro <colmeiro@gmail.com>. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** - */ - -const UNPACKAGED_ADDON = do_get_file("data/test_bug564667"); -const PACKAGED_ADDON = do_get_file("data/test_bug564667.xpi"); - -var gIOS = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - -var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"]. - getService(Ci.nsIChromeRegistry). - QueryInterface(Ci.nsIXULOverlayProvider); - -/* - * Checks that a mapping was added - */ -function test_mapping(chromeURL, target) { - var uri = gIOS.newURI(chromeURL, null, null); - - try { - var result = gCR.convertChromeURL(uri); - do_check_eq(result.spec, target); - } - catch (ex) { - do_throw(chromeURL + " not Registered"); - } -} - -/* - * Checks that a mapping was removed - */ -function test_removed_mapping(chromeURL, target) { - var uri = gIOS.newURI(chromeURL, null, null); - try { - var result = gCR.convertChromeURL(uri); - do_throw(chromeURL + " not removed"); - } - catch (ex) { - // This should throw - } -} - -/* - * Checks if any overlay was added after loading - * the manifest files - * - * @param type The type of overlay: overlay|style - */ -function test_no_overlays(chromeURL, target, type) { - var type = type || "overlay"; - var uri = gIOS.newURI(chromeURL, null, null); - var present = false, elem; - - var overlays = (type == "overlay") ? - gCR.getXULOverlays(uri) : gCR.getStyleOverlays(uri); - - // We shouldn't be allowed to register overlays nor styles - if (overlays.hasMoreElements()) { - if (type == "styles") - do_throw("Style Registered: " + chromeURL); - else - do_throw("Overlay Registered: " + chromeURL); - } -} - -function testManifest(manifestPath, baseURI) { - - // ------------------ Add manifest file ------------------------ - Components.manager.addBootstrappedManifestLocation(manifestPath); - - // Test Adding Content URL - test_mapping("chrome://test1/content", baseURI + "test/test1.xul"); - - // Test Adding Locale URL - test_mapping("chrome://test1/locale", baseURI + "test/test1.dtd"); - - // Test Adding Skin URL - test_mapping("chrome://test1/skin", baseURI + "test/test1.css"); - - // Test Adding Manifest URL - test_mapping("chrome://test2/content", baseURI + "test/test2.xul"); - test_mapping("chrome://test2/locale", baseURI + "test/test2.dtd"); - - // Test Adding Override - test_mapping("chrome://testOverride/content", 'file:///test1/override') - - // Test Not-Adding Overlays - test_no_overlays("chrome://test1/content/overlay.xul", - "chrome://test1/content/test1.xul"); - - // Test Not-Adding Styles - test_no_overlays("chrome://test1/content/style.xul", - "chrome://test1/content/test1.css", "styles"); - - - // ------------------ Remove manifest file ------------------------ - Components.manager.removeBootstrappedManifestLocation(manifestPath); - - // Test Removing Content URL - test_removed_mapping("chrome://test1/content", baseURI + "test/test1.xul"); - - // Test Removing Content URL - test_removed_mapping("chrome://test1/locale", baseURI + "test/test1.dtd"); - - // Test Removing Skin URL - test_removed_mapping("chrome://test1/skin", baseURI + "test/test1.css"); - - // Test Removing Manifest URL - test_removed_mapping("chrome://test2/content", baseURI + "test/test2.xul"); - test_removed_mapping("chrome://test2/locale", baseURI + "test/test2.dtd"); -} - -function run_test() { - // Test an unpackaged addon - testManifest(UNPACKAGED_ADDON, gIOS.newFileURI(UNPACKAGED_ADDON).spec); - - // Test a packaged addon - testManifest(PACKAGED_ADDON, "jar:" + gIOS.newFileURI(PACKAGED_ADDON).spec + "!/"); -}
--- a/chrome/test/unit/xpcshell.ini +++ b/chrome/test/unit/xpcshell.ini @@ -5,13 +5,12 @@ tail = [test_abi.js] [test_bug292789.js] [test_bug380398.js] [test_bug397073.js] [test_bug399707.js] [test_bug401153.js] [test_bug415367.js] [test_bug519468.js] -[test_bug564667.js] [test_crlf.js] [test_data_protocol_registration.js] [test_no_remote_registration.js] [test_resolve_uris.js]
--- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -368,18 +368,17 @@ XRE_API(nsresult, * components as well as component/chrome manifest files. * * NS_SKIN_LOCATION specifies a location to search for chrome manifest files * which are only allowed to register only skin packages and style overlays. */ enum NSLocationType { NS_COMPONENT_LOCATION, - NS_SKIN_LOCATION, - NS_BOOTSTRAPPED_LOCATION + NS_SKIN_LOCATION }; XRE_API(nsresult, XRE_AddManifestLocation, (NSLocationType aType, nsILocalFile* aLocation)) /** * Register XPCOM components found in a JAR.
--- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -71,59 +71,57 @@ struct ManifestDirective int argc; // Some directives should only be delivered for NS_COMPONENT_LOCATION // manifests. bool componentonly; bool ischrome; - bool allowbootstrap; - // The platform/contentaccessible flags only apply to content directives. bool contentflags; // Function to handle this directive. This isn't a union because C++ still // hasn't learned how to initialize unions in a sane way. void (nsComponentManagerImpl::*mgrfunc) (nsComponentManagerImpl::ManifestProcessingContext& cx, int lineno, char *const * argv); void (nsChromeRegistry::*regfunc) (nsChromeRegistry::ManifestProcessingContext& cx, int lineno, char *const *argv, bool platform, bool contentaccessible); bool isContract; }; static const ManifestDirective kParsingTable[] = { - { "manifest", 1, false, true, true, false, + { "manifest", 1, false, true, false, &nsComponentManagerImpl::ManifestManifest, NULL }, - { "binary-component", 1, true, false, false, false, + { "binary-component", 1, true, false, false, &nsComponentManagerImpl::ManifestBinaryComponent, NULL }, - { "interfaces", 1, true, false, false, false, + { "interfaces", 1, true, false, false, &nsComponentManagerImpl::ManifestXPT, NULL }, - { "component", 2, true, false, false, false, + { "component", 2, true, false, false, &nsComponentManagerImpl::ManifestComponent, NULL }, - { "contract", 2, true, false, false, false, + { "contract", 2, true, false, false, &nsComponentManagerImpl::ManifestContract, NULL, true}, - { "category", 3, true, false, false, false, + { "category", 3, true, false, false, &nsComponentManagerImpl::ManifestCategory, NULL }, - { "content", 2, true, true, true, true, + { "content", 2, true, true, true, NULL, &nsChromeRegistry::ManifestContent }, - { "locale", 3, true, true, true, false, + { "locale", 3, true, true, false, NULL, &nsChromeRegistry::ManifestLocale }, - { "skin", 3, false, true, true, false, + { "skin", 3, false, true, false, NULL, &nsChromeRegistry::ManifestSkin }, - { "overlay", 2, true, true, false, false, + { "overlay", 2, true, true, false, NULL, &nsChromeRegistry::ManifestOverlay }, - { "style", 2, false, true, false, false, + { "style", 2, false, true, false, NULL, &nsChromeRegistry::ManifestStyle }, - { "override", 2, true, true, true, false, + { "override", 2, true, true, false, NULL, &nsChromeRegistry::ManifestOverride }, - { "resource", 2, true, true, false, false, + { "resource", 2, true, true, false, NULL, &nsChromeRegistry::ManifestResource } }; static const char kWhitespace[] = "\t "; static bool IsNewline(char c) { return c == '\n' || c == '\r'; @@ -447,17 +445,17 @@ ParseManifestCommon(NSLocationType aType nsCAutoString s; rv = xapp->GetID(s); if (NS_SUCCEEDED(rv)) CopyUTF8toUTF16(s, appID); rv = xapp->GetVersion(s); if (NS_SUCCEEDED(rv)) CopyUTF8toUTF16(s, appVersion); - + nsCOMPtr<nsIXULRuntime> xruntime (do_QueryInterface(xapp)); if (xruntime) { rv = xruntime->GetOS(s); if (NS_SUCCEEDED(rv)) { ToLowerCase(s); CopyUTF8toUTF16(s, osTarget); } @@ -535,32 +533,23 @@ ParseManifestCommon(NSLocationType aType for (const ManifestDirective* d = kParsingTable; d < kParsingTable + NS_ARRAY_LENGTH(kParsingTable); ++d) { if (!strcmp(d->directive, token)) { directive = d; break; } } - if (!directive) { LogMessageWithContext(aFile, aPath, line, "Ignoring unrecognized chrome manifest directive '%s'.", token); continue; } - - if (!directive->allowbootstrap && NS_BOOTSTRAPPED_LOCATION == aType) { - LogMessageWithContext(aFile, aPath, line, - "Bootstrapped manifest not allowed to use '%s' directive.", - token); - continue; - } - - if (directive->componentonly && NS_SKIN_LOCATION == aType) { + if (directive->componentonly && NS_COMPONENT_LOCATION != aType) { LogMessageWithContext(aFile, aPath, line, "Skin manifest not allowed to use '%s' directive.", token); continue; } NS_ASSERTION(directive->argc < 4, "Need to reset argv array length"); char* argv[4];
--- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -84,17 +84,16 @@ #include "xptinfo.h" // this after nsISupports, to pick up IID so that xpt stuff doesn't try to define it itself... #include "nsThreadUtils.h" #include "prthread.h" #include "private/pprthred.h" #include "nsTArray.h" #include "prio.h" #include "mozilla/FunctionTimer.h" #include "ManifestParser.h" -#include "mozilla/Services.h" #include "nsManifestLineReader.h" #include "mozilla/GenericFactory.h" #include "nsSupportsPrimitives.h" #include "nsArrayEnumerator.h" #include "nsStringEnumerator.h" #include NEW_H // for placement new @@ -402,17 +401,17 @@ nsresult nsComponentManagerImpl::Init() if (!l.jar) { RegisterManifestFile(l.type, l.location, false); continue; } nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv); rv = reader->Open(l.location); if (NS_SUCCEEDED(rv)) - RegisterJarManifest(l.type, reader, "chrome.manifest", false); + RegisterJarManifest(reader, "chrome.manifest", false); } nsCategoryManager::GetSingleton()->SuppressNotifications(false); mStatus = NORMAL; return NS_OK; } @@ -538,17 +537,17 @@ LoadEntry(nsIZipReader* aReader, const c nsresult rv = aReader->GetInputStream(aName, getter_AddRefs(is)); if (NS_FAILED(rv)) return NULL; return is.forget(); } void -nsComponentManagerImpl::RegisterJarManifest(NSLocationType aType, nsIZipReader* aReader, +nsComponentManagerImpl::RegisterJarManifest(nsIZipReader* aReader, const char* aPath, bool aChromeOnly) { nsCOMPtr<nsIInputStream> is = LoadEntry(aReader, aPath); if (!is) { LogMessage("Could not find jar manifest entry '%s'.", aPath); return; } @@ -572,17 +571,17 @@ nsComponentManagerImpl::RegisterJarManif if (NS_FAILED(is->Read(whole + totalRead, avail, &read))) return; totalRead += read; } whole[flen] = '\0'; - ParseManifest(aType, aReader, aPath, + ParseManifest(NS_COMPONENT_LOCATION, aReader, aPath, whole, aChromeOnly); } namespace { struct AutoCloseFD { AutoCloseFD() : mFD(NULL) @@ -670,17 +669,17 @@ void nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& cx, int lineno, char *const * argv) { char* file = argv[0]; if (cx.mPath) { nsCAutoString manifest(cx.mPath); AppendFileToManifestPath(manifest, file); - RegisterJarManifest(cx.mType, cx.mReader, manifest.get(), cx.mChromeOnly); + RegisterJarManifest(cx.mReader, manifest.get(), cx.mChromeOnly); } else { #ifdef TRANSLATE_SLASHES TranslateSlashes(file); #endif nsCOMPtr<nsIFile> cfile; cx.mFile->GetParent(getter_AddRefs(cfile)); nsCOMPtr<nsILocalFile> clfile = do_QueryInterface(cfile); @@ -907,17 +906,17 @@ nsComponentManagerImpl::RereadChromeMani continue; } nsresult rv; nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv); if (NS_SUCCEEDED(rv)) rv = reader->Open(l.location); if (NS_SUCCEEDED(rv)) - RegisterJarManifest(l.type, reader, "chrome.manifest", true); + RegisterJarManifest(reader, "chrome.manifest", true); } } bool nsComponentManagerImpl::KnownModule::EnsureLoader() { if (!mLoader) { nsCString extension; @@ -2032,71 +2031,16 @@ XRE_AddStaticComponent(const mozilla::Mo if (nsComponentManagerImpl::gComponentManager && nsComponentManagerImpl::NORMAL == nsComponentManagerImpl::gComponentManager->mStatus) nsComponentManagerImpl::gComponentManager->RegisterModule(aComponent, NULL); return NS_OK; } -NS_IMETHODIMP -nsComponentManagerImpl::AddBootstrappedManifestLocation(nsILocalFile* aLocation) -{ - nsString path; - nsresult rv = aLocation->GetPath(path); - - if (NS_FAILED(rv)) - return rv; - - if (Substring(path, path.Length() - 4).Equals(NS_LITERAL_STRING(".xpi"))) { - return XRE_AddJarManifestLocation(NS_BOOTSTRAPPED_LOCATION, aLocation); - } - else { - nsCOMPtr<nsILocalFile> manifest = - CloneAndAppend(aLocation, NS_LITERAL_CSTRING("chrome.manifest")); - return XRE_AddManifestLocation(NS_BOOTSTRAPPED_LOCATION, manifest); - } -} - -NS_IMETHODIMP -nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsILocalFile* aLocation) -{ - nsCOMPtr<nsIChromeRegistry> cr = mozilla::services::GetChromeRegistryService(); - - if (!cr) - return NS_ERROR_FAILURE; - - PRBool isJar = PR_FALSE; - nsCOMPtr<nsILocalFile> manifest; - nsString path; - nsresult rv = aLocation->GetPath(path); - - if (NS_FAILED(rv)) - return rv; - - if (Substring(path, path.Length() - 4).Equals(NS_LITERAL_STRING(".xpi"))) { - isJar = PR_TRUE; - manifest = aLocation; - } else { - manifest = CloneAndAppend(aLocation, NS_LITERAL_CSTRING("chrome.manifest")); - } - - nsComponentManagerImpl::ComponentLocation elem = { - NS_BOOTSTRAPPED_LOCATION, - manifest, - isJar - }; - - //remove reference - nsComponentManagerImpl::sModuleLocations->RemoveElement(elem, ComponentLocationComparator()); - - rv = cr->CheckForNewChrome(); - return rv; -} - EXPORT_XPCOM_API(nsresult) XRE_AddManifestLocation(NSLocationType aType, nsILocalFile* aLocation) { nsComponentManagerImpl::InitializeModuleLocations(); nsComponentManagerImpl::ComponentLocation* c = nsComponentManagerImpl::sModuleLocations->AppendElement(); c->type = aType; c->location = aLocation; @@ -2124,13 +2068,13 @@ XRE_AddJarManifestLocation(NSLocationTyp return NS_OK; nsresult rv; nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = reader->Open(c->location); if (NS_SUCCEEDED(rv)) - nsComponentManagerImpl::gComponentManager->RegisterJarManifest(aType, reader, "chrome.manifest", false); + nsComponentManagerImpl::gComponentManager->RegisterJarManifest(reader, "chrome.manifest", false); return NS_OK; }
--- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -157,31 +157,16 @@ public: struct ComponentLocation { NSLocationType type; nsCOMPtr<nsILocalFile> location; bool jar; }; - class ComponentLocationComparator - { - public: - PRBool Equals(const ComponentLocation& a, const ComponentLocation& b) const { - PRBool res; - if (a.type == b.type && a.jar == b.jar) { - nsresult rv = a.location->Equals(b.location, &res); - NS_ASSERTION(NS_SUCCEEDED(rv), "Error comparing locations"); - return res; - } else { - return PR_FALSE; - } - } - }; - static nsTArray<const mozilla::Module*>* sStaticModules; static nsTArray<ComponentLocation>* sModuleLocations; static nsTArray<ComponentLocation>* sJarModuleLocations; nsNativeModuleLoader mNativeModuleLoader; class KnownModule { @@ -250,17 +235,17 @@ public: nsClassHashtable<nsCStringHashKey, KnownModule> mKnownJARModules; void RegisterModule(const mozilla::Module* aModule, nsILocalFile* aFile); void RegisterCIDEntry(const mozilla::Module::CIDEntry* aEntry, KnownModule* aModule); void RegisterContractID(const mozilla::Module::ContractIDEntry* aEntry); - void RegisterJarManifest(NSLocationType aType, nsIZipReader* aReader, + void RegisterJarManifest(nsIZipReader* aReader, const char* aPath, bool aChromeOnly); void RegisterManifestFile(NSLocationType aType, nsILocalFile* aFile, bool aChromeOnly); struct ManifestProcessingContext { ManifestProcessingContext(NSLocationType aType, nsILocalFile* aFile, bool aChromeOnly)
--- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -36,20 +36,19 @@ * ***** END LICENSE BLOCK ***** */ /** * The nsIComponentManager interface. */ #include "nsISupports.idl" -interface nsILocalFile; interface nsIFactory; -[scriptable, uuid(1d940426-5fe5-42c3-84ae-a300f2d9ebd5)] +[scriptable, uuid(a88e5a60-205a-4bb1-94e1-2628daf51eae)] interface nsIComponentManager : nsISupports { /** * getClassObject * * Returns the factory object that can be used to create instances of * CID aClass * @@ -95,37 +94,16 @@ interface nsIComponentManager : nsISuppo * @param aContractID : aContractID of object instance requested * @param aDelegate : Used for aggregation * @param aIID : IID of interface requested */ void createInstanceByContractID(in string aContractID, in nsISupports aDelegate, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); - - /** - * addBootstrappedManifestLocation - * - * Adds a bootstrapped manifest location on runtime. - * - * @param aLocation : A directory where chrome.manifest resides, - * or an XPI with it on the root. - */ - void addBootstrappedManifestLocation(in nsILocalFile aLocation); - - /** - * removeBootstrappedManifestLocation - * - * Removes a bootstrapped manifest location on runtime. - * - * @param aLocation : A directory where chrome.manifest resides, - * or an XPI with it on the root. - */ - void removeBootstrappedManifestLocation(in nsILocalFile aLocation); - }; %{ C++ #ifdef MOZILLA_INTERNAL_API #include "nsComponentManagerUtils.h" #endif %} C++