Bug 1363760 - Part 3 - In tests, install SpecialPowers and mochijar as non-temporary addons r=ahal
authorAlex Gaynor <agaynor@mozilla.com>
Tue, 30 May 2017 10:09:57 -0400
changeset 361850 71e0ff5a6c76
parent 361849 0205cdd17a67
child 361851 665f1887a112
push id43901
push userryanvm@gmail.com
push dateThu, 01 Jun 2017 17:04:56 +0000
treeherderautoland@71e0ff5a6c76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1363760
milestone55.0a1
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
Bug 1363760 - Part 3 - In tests, install SpecialPowers and mochijar as non-temporary addons r=ahal 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
testing/mochitest/runtests.py
--- 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