Bug 1363760 - Part 3 - In tests, install SpecialPowers and mochijar as non-temporary addons
This means they will be copied to $PROFILE/extensions, which the sandbox allows
access to; if they are installed as temporary addons, loading frame scripts in
the content process tries to read from wherever they happen to be on disk. This
breaks running tests with a packaged build once we have full read-restrictions
for the content process sandbox.
MozReview-Commit-ID: 7ZiiM9FMXfG
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -771,16 +771,27 @@ def parseKeyValue(strings, separator='='
missing = [string for string in strings if separator not in string]
if missing:
raise KeyValueParseError(
"Error: syntax error in %s" %
(context, ','.join(missing)), errors=missing)
return [string.split(separator, 1) for string in strings]
+def create_zip(path):
+ """
+ Takes a `path` on disk and creates a zipfile with its contents. Returns a
+ path to the location of the temporary zip file.
+ """
+ with tempfile.NamedTemporaryFile() as f:
+ # `shutil.make_archive` writes to "{f.name}.zip", so we're really just
+ # using `NamedTemporaryFile` as a way to get a random path.
+ return shutil.make_archive(f.name, "zip", path)
+
+
class MochitestDesktop(object):
"""
Mochitest class for desktop firefox.
"""
oldcwd = os.getcwd()
mochijar = os.path.join(SCRIPT_DIR, 'mochijar')
# Path to the test script on the server
@@ -2101,22 +2112,24 @@ toolbar#nav-bar {
self.message_logger.gecko_id = gecko_id
# start marionette and kick off the tests
marionette_args = marionette_args or {}
port_timeout = marionette_args.pop('port_timeout', 60)
self.marionette = Marionette(**marionette_args)
self.marionette.start_session(timeout=port_timeout)
- # install specialpowers and mochikit as temporary addons
+ # install specialpowers and mochikit addons
addons = Addons(self.marionette)
if mozinfo.info.get('toolkit') != 'gonk':
- addons.install(os.path.join(here, 'extensions', 'specialpowers'), temp=True)
- addons.install(self.mochijar, temp=True)
+ addons.install(create_zip(
+ os.path.join(here, 'extensions', 'specialpowers')
+ ))
+ addons.install(create_zip(self.mochijar))
self.execute_start_script()
# an open marionette session interacts badly with mochitest,
# delete it until we figure out why.
self.marionette.delete_session()
del self.marionette