[Pkg-mozext-commits] [adblock-plus] 253/464: Added support for multi-compartment builds (good for memory leak hunting)
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:22 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit c5179be07808eb634713b1616ab4b557c109ecee
Author: Wladimir Palant <trev at adblockplus.org>
Date: Thu Jun 28 11:01:21 2012 +0200
Added support for multi-compartment builds (good for memory leak hunting)
---
bootstrap.js.tmpl | 11 ++++++++++-
build.py | 14 ++++++++++++--
packager.py | 8 +++++---
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/bootstrap.js.tmpl b/bootstrap.js.tmpl
index 71071fb..546e8dc 100644
--- a/bootstrap.js.tmpl
+++ b/bootstrap.js.tmpl
@@ -141,6 +141,7 @@ function require(module)
else
{
{%- endif %}
+ let url = addonData.resourceURI.spec + "lib/" + module + ".js";
scopes[module] = {
Cc: Cc,
Ci: Ci,
@@ -151,7 +152,15 @@ function require(module)
onShutdown: onShutdown,
{% endif %}
exports: {}};
- Services.scriptloader.loadSubScript(addonData.resourceURI.spec + "lib/" + module + ".js", scopes[module]);
+ {%- if multicompartment %}
+ let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
+ scopes[module] = new Cu.Sandbox(principal, {
+ sandboxName: url,
+ sandboxPrototype: scopes[module],
+ wantXrays: false
+ });
+ {%- endif %}
+ Services.scriptloader.loadSubScript(url, scopes[module]);
{%- if 'info' in requires %}
}
{%- endif %}
diff --git a/build.py b/build.py
index bf89536..ed0e3a8 100644
--- a/build.py
+++ b/build.py
@@ -142,6 +142,7 @@ Options:
def runBuild(baseDir, scriptName, opts, args, type):
locales = None
buildNum = None
+ multicompartment = False
releaseBuild = False
keyFile = None
limitMetadata = False
@@ -152,6 +153,8 @@ def runBuild(baseDir, scriptName, opts, args, type):
buildNum = int(value)
elif option in ('-k', '--key'):
keyFile = value
+ elif option in ('-m', '--multi-compartment'):
+ multicompartment = True
elif option in ('-r', '--release'):
releaseBuild = True
elif option == '--babelzilla':
@@ -163,7 +166,7 @@ def runBuild(baseDir, scriptName, opts, args, type):
import buildtools.packager as packager
packager.createBuild(baseDir, outFile=outFile, locales=locales, buildNum=buildNum,
releaseBuild=releaseBuild, keyFile=keyFile,
- limitMetadata=limitMetadata)
+ limitMetadata=limitMetadata, multicompartment=multicompartment)
elif type == 'kmeleon':
import buildtools.packagerKMeleon as packagerKMeleon
packagerKMeleon.createBuild(baseDir, outFile=outFile, locales=locales,
@@ -175,13 +178,18 @@ def runAutoInstall(baseDir, scriptName, opts, args, type):
usage(scriptName, type, 'autoinstall')
return
+ multicompartment = False
+ for option, value in opts:
+ if option in ('-m', '--multi-compartment'):
+ multicompartment = True
+
if ':' in args[0]:
host, port = args[0].rsplit(':', 1)
else:
host, port = ('localhost', args[0])
import buildtools.packager as packager
- packager.autoInstall(baseDir, host, port)
+ packager.autoInstall(baseDir, host, port, multicompartment=multicompartment)
def showDescriptions(baseDir, scriptName, opts, args, type):
@@ -283,6 +291,7 @@ with addCommand(runBuild, 'build') as command:
command.addOption('Only include the given locales (if omitted: all locales not marked as incomplete)', short='l', long='locales', value='l1,l2,l3')
command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num')
command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file')
+ command.addOption('Create a build for leak testing', short='m', long='multi-compartment')
command.addOption('Create a release build', short='r', long='release')
command.addOption('Create a build for Babelzilla', long='babelzilla')
command.supportedTypes = ('gecko', 'kmeleon')
@@ -291,6 +300,7 @@ with addCommand(runAutoInstall, 'autoinstall') as command:
command.shortDescription = 'Install extension automatically'
command.description = 'Will automatically install the extension in a browser running Extension Auto-Installer. If host parameter is omitted assumes that the browser runs on localhost.'
command.params = '[<host>:]<port>'
+ command.addOption('Create a build for leak testing', short='m', long='multi-compartment')
command.supportedTypes = ('gecko')
with addCommand(showDescriptions, 'showdesc') as command:
diff --git a/packager.py b/packager.py
index 1e654d6..ecde259 100644
--- a/packager.py
+++ b/packager.py
@@ -232,6 +232,7 @@ def addMissingFiles(baseDir, params, files):
'chromeWindows': [],
'requires': {},
'metadata': params['metadata'],
+ 'multicompartment': params['multicompartment'],
'applications': dict((v, k) for k, v in KNOWN_APPS.iteritems()),
}
@@ -334,7 +335,7 @@ def writeXPI(files, outFile):
zip.writestr(name, files[name])
zip.close()
-def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild=False, keyFile=None, limitMetadata=False):
+def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild=False, keyFile=None, limitMetadata=False, multicompartment=False):
if buildNum == None:
buildNum = getBuildNum(baseDir)
if locales == None:
@@ -365,6 +366,7 @@ def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild
'metadata': metadata,
'limitMetadata': limitMetadata,
'contributors': contributors,
+ 'multicompartment': multicompartment,
}
files = {}
files['install.rdf'] = createManifest(baseDir, params)
@@ -380,7 +382,7 @@ def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild
signFiles(files, keyFile)
writeXPI(files, outFile)
-def autoInstall(baseDir, host, port):
+def autoInstall(baseDir, host, port, multicompartment=False):
fileBuffer = StringIO()
- createBuild(baseDir, outFile=fileBuffer)
+ createBuild(baseDir, outFile=fileBuffer, multicompartment=multicompartment)
urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue())
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list