code: def _install_extension(self, addon, unpack=True):
          
          if addon == WEBDRIVER_EXT:
              addon = os.path.join(os.path.dirname(__file__), WEBDRIVER_EXT)
  
          tmpdir = None
          xpifile = None
          if addon.endswith('.xpi'):
              tmpdir = tempfile.mkdtemp(suffix='.' + os.path.split(addon)[-1])
              compressed_file = zipfile.ZipFile(addon, 'r')
              for name in compressed_file.namelist():
                  if name.endswith('/'):
                      if not os.path.isdir(os.path.join(tmpdir, name)):
                          os.makedirs(os.path.join(tmpdir, name))
                  else:
                      if not os.path.isdir(os.path.dirname(os.path.join(tmpdir, name))):
                          os.makedirs(os.path.dirname(os.path.join(tmpdir, name)))
                      data = compressed_file.read(name)
                      with open(os.path.join(tmpdir, name), 'wb') as f:
                          f.write(data)
              xpifile = addon
              addon = tmpdir
  
          # determine the addon id
          addon_details = self._addon_details(addon)
          addon_id = addon_details.get('id')
          assert addon_id, 'The addon id could not be found: %s' % addon
  
          # copy the addon to the profile
          addon_path = os.path.join(self.extensionsDir, addon_id)
          if not unpack and not addon_details['unpack'] and xpifile:
              if not os.path.exists(self.extensionsDir):
                  os.makedirs(self.extensionsDir)
                  os.chmod(self.extensionsDir, 0o755)
              shutil.copy(xpifile, addon_path + '.xpi')
          else:
              if not os.path.exists(addon_path):
                  shutil.copytree(addon, addon_path, symlinks=True)
  
          # remove the temporary directory, if any
          if tmpdir:
              shutil.rmtree(tmpdir)
docs: Installs addon from a filepath, url
              or directory of addons in the profile.
              - path: url, absolute path to .xpi, or directory of addons
              - unpack: whether to unpack unless specified otherwise in the install.rdf