mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 570488 - Fix loading of XPTs nested in JARs [2/2] r=mwu
--HG-- extra : rebase_source : b97a591c0260daed1f2ef2eba69e60ff82acd18f
This commit is contained in:
parent
755c2ae337
commit
3fcaf094f4
@ -54,13 +54,11 @@
|
||||
#include "nsJAR.h"
|
||||
#include "nsIJARFactory.h"
|
||||
#include "nsRecyclingAllocator.h"
|
||||
#include "nsXPTZipLoader.h"
|
||||
#include "nsJARProtocolHandler.h"
|
||||
#include "nsJARURI.h"
|
||||
|
||||
extern nsRecyclingAllocator *gZlibAllocator;
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPTZipLoader)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler,
|
||||
@ -70,11 +68,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI)
|
||||
// The list of components we register
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "XPT Zip Reader",
|
||||
NS_XPTZIPREADER_CID,
|
||||
NS_XPTLOADER_CONTRACTID_PREFIX "zip",
|
||||
nsXPTZipLoaderConstructor
|
||||
},
|
||||
{ "Zip Reader",
|
||||
NS_ZIPREADER_CID,
|
||||
"@mozilla.org/libjar/zip-reader;1",
|
||||
|
@ -39,15 +39,10 @@
|
||||
|
||||
|
||||
#include "nsXPTZipLoader.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsJAR.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
|
||||
static const char gCacheContractID[] =
|
||||
"@mozilla.org/libjar/zip-reader-cache;1";
|
||||
static const PRUint32 gCacheSize = 1;
|
||||
|
||||
nsXPTZipLoader::nsXPTZipLoader() {
|
||||
}
|
||||
|
||||
@ -102,22 +97,15 @@ nsXPTZipLoader::EnumerateEntries(nsILocalFile* aFile,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIZipReader*
|
||||
already_AddRefed<nsIZipReader>
|
||||
nsXPTZipLoader::GetZipReader(nsILocalFile* file)
|
||||
{
|
||||
NS_ASSERTION(file, "bad file");
|
||||
|
||||
if(!mCache)
|
||||
{
|
||||
mCache = do_CreateInstance(gCacheContractID);
|
||||
if(!mCache || NS_FAILED(mCache->Init(gCacheSize)))
|
||||
return nsnull;
|
||||
}
|
||||
nsCOMPtr<nsIZipReader> reader = new nsJAR();
|
||||
nsresult rv = reader->Open(file);
|
||||
if (NS_FAILED(rv))
|
||||
return NULL;
|
||||
|
||||
nsIZipReader* reader = nsnull;
|
||||
|
||||
if(NS_FAILED(mCache->GetZip(file, &reader)))
|
||||
return nsnull;
|
||||
|
||||
return reader;
|
||||
return reader.forget();
|
||||
}
|
||||
|
@ -42,12 +42,6 @@
|
||||
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
// {0320E073-79C7-4dae-8055-81BED8B8DB96}
|
||||
#define NS_XPTZIPREADER_CID \
|
||||
{ 0x320e073, 0x79c7, 0x4dae, \
|
||||
{ 0x80, 0x55, 0x81, 0xbe, 0xd8, 0xb8, 0xdb, 0x96 } }
|
||||
|
||||
|
||||
class nsXPTZipLoader : public nsIXPTLoader
|
||||
{
|
||||
public:
|
||||
@ -58,7 +52,6 @@ class nsXPTZipLoader : public nsIXPTLoader
|
||||
NS_DECL_NSIXPTLOADER
|
||||
|
||||
private:
|
||||
nsIZipReader* GetZipReader(nsILocalFile* aFile);
|
||||
nsCOMPtr<nsIZipReaderCache> mCache;
|
||||
already_AddRefed<nsIZipReader> GetZipReader(nsILocalFile* aFile);
|
||||
};
|
||||
|
||||
|
@ -49,6 +49,7 @@ MODULES_LIBJAR_LCPPSRCS = \
|
||||
MODULES_LIBJAR_LEXPORTS = \
|
||||
zipstruct.h \
|
||||
nsZipArchive.h \
|
||||
nsXPTZipLoader.h \
|
||||
$(NULL)
|
||||
|
||||
MODULES_LIBJAR_LXPIDLSRCS = \
|
||||
|
@ -82,6 +82,10 @@ ifdef MOZ_CRASHREPORTER
|
||||
TEST_HARNESS_COMPONENTS += crashreporter_test.xpt
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
TEST_HARNESS_COMPONENTS += xpcom_typelib_test.jar
|
||||
endif
|
||||
|
||||
# Rules for staging the necessary harness bits for a test package
|
||||
PKG_STAGE = $(DIST)/test-package-stage
|
||||
|
||||
|
@ -696,18 +696,12 @@ NS_InitXPCOM3(nsIServiceManager* *result,
|
||||
|
||||
NS_TIME_FUNCTION_MARK("Next: interface info manager init");
|
||||
|
||||
// Pay the cost at startup time of starting this singleton.
|
||||
// The iimanager constructor searches and registers XPT files.
|
||||
nsIInterfaceInfoManager* iim =
|
||||
xptiInterfaceInfoManager::GetSingleton();
|
||||
|
||||
NS_TIME_FUNCTION_MARK("Next: try to load compreg.dat");
|
||||
|
||||
#if 0 // The constructor does this, don't do it twice!
|
||||
// If the component registry is out of date, malformed, or incomplete,
|
||||
// autoregister the default component directories.
|
||||
(void) iim->AutoRegisterInterfaces();
|
||||
#endif,
|
||||
|
||||
// "Re-register the world" if compreg.dat doesn't exist
|
||||
rv = nsComponentManagerImpl::gComponentManager->ReadPersistentRegistry();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "nsXPTZipLoader.h"
|
||||
|
||||
#define NS_ZIPLOADER_CONTRACTID NS_XPTLOADER_CONTRACTID_PREFIX "zip"
|
||||
|
||||
@ -296,14 +297,14 @@ xptiInterfaceInfoManager::RegisterFile(nsILocalFile* aFile, xptiFileType::Type a
|
||||
RegisterXPTHeader(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case xptiFileType::ZIP: {
|
||||
// XXX XPCOM registration ordering issue, use C++!
|
||||
nsCOMPtr<nsIXPTLoader> loader = do_GetService(NS_ZIPLOADER_CONTRACTID);
|
||||
if (!loader)
|
||||
return;
|
||||
|
||||
case xptiFileType::ZIP: {
|
||||
#ifndef MOZ_ENABLE_LIBXUL
|
||||
NS_WARNING("Trying to register XPTs in a JAR in a non-libxul build");
|
||||
#else
|
||||
nsCOMPtr<nsIXPTLoader> loader = new nsXPTZipLoader();
|
||||
loader->EnumerateEntries(aFile, this);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,11 @@ MOZILLA_INTERNAL_API = 1
|
||||
endif
|
||||
|
||||
DIRS = dynamic services external
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
DIRS += xptinfo
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += windows
|
||||
endif
|
||||
|
59
xpcom/tests/xptinfo/Makefile.in
Normal file
59
xpcom/tests/xptinfo/Makefile.in
Normal file
@ -0,0 +1,59 @@
|
||||
# ***** 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 Firefox.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# the Mozilla Foundation <http://www.mozilla.org>
|
||||
# Portions created by the Initial Developer are Copyright (C) 2010
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpcom
|
||||
XPIDL_MODULE = xpcom_typelib_testxpt
|
||||
NO_DIST_INSTALL = 1
|
||||
|
||||
XPIDLSRCS = xptiITestInterface.idl
|
||||
|
||||
XPCSHELL_TESTS = xptunit
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
xpcom_typelib_test.jar:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
|
||||
$(RM) -f $@
|
||||
cd $(XPIDL_GEN_DIR) && $(ZIP) -q ../$(@F) $(^F)
|
||||
|
||||
libs:: xpcom_typelib_test.jar
|
||||
$(INSTALL) $^ $(FINAL_TARGET)/components
|
47
xpcom/tests/xptinfo/xptiITestInterface.idl
Normal file
47
xpcom/tests/xptinfo/xptiITestInterface.idl
Normal file
@ -0,0 +1,47 @@
|
||||
/* ***** 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 Firefox.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation <http://www.mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* This interface is not implemented: it exists only for a test of whether
|
||||
* we load XPTs from JAR files correctly.
|
||||
*/
|
||||
[scriptable, uuid(13c9fc33-40e6-44dc-81e2-21e0dd41f232)]
|
||||
interface xptiITestInterface : nsISupports
|
||||
{
|
||||
void testMethod(in unsigned long testArg);
|
||||
};
|
7
xpcom/tests/xptinfo/xptunit/test_jar_xptloading.js
Normal file
7
xpcom/tests/xptinfo/xptunit/test_jar_xptloading.js
Normal file
@ -0,0 +1,7 @@
|
||||
const xptiITestInterface_IID = "{13c9fc33-40e6-44dc-81e2-21e0dd41f232}";
|
||||
|
||||
var id = Components.interfaces.xptiITestInterface;
|
||||
do_check_true(id, "xptiITestInterface not registered");
|
||||
|
||||
var id2 = Components.interfacesById[xptiITestInterface_IID];
|
||||
do_check_true(id === id2, "xptiITestInterface info doesn't match");
|
Loading…
Reference in New Issue
Block a user