зеркало из https://github.com/mozilla/gecko-dev.git
Bug 647414 - Distributed extensions should be automatically installed into temporary testing profile; (Av2) Improve addChromeToProfile() and related.
r=jmaher.
This commit is contained in:
Родитель
ead815faaf
Коммит
1f85231808
|
@ -168,11 +168,14 @@ class RefTest(object):
|
|||
"Copy extra files or dirs specified on the command line to the testing profile."
|
||||
for f in options.extraProfileFiles:
|
||||
abspath = self.getFullPath(f)
|
||||
if os.path.isfile(abspath):
|
||||
shutil.copy2(abspath, profileDir)
|
||||
elif os.path.isdir(abspath):
|
||||
dest = os.path.join(profileDir, os.path.basename(abspath))
|
||||
if os.path.isdir(abspath):
|
||||
shutil.copytree(abspath, dest)
|
||||
else:
|
||||
shutil.copy(abspath, dest)
|
||||
self.automation.log.warning("WARNING | runreftest.py | Failed to copy %s to profile", abspath)
|
||||
continue
|
||||
|
||||
def installExtensionsToProfile(self, options, profileDir):
|
||||
"Install the specified extensions on the command line to the testing profile."
|
||||
|
|
|
@ -351,9 +351,8 @@ class MochitestServer:
|
|||
|
||||
def stop(self):
|
||||
try:
|
||||
c = urllib2.urlopen(self.shutdownURL)
|
||||
with urllib2.urlopen(self.shutdownURL) as c:
|
||||
c.read()
|
||||
c.close()
|
||||
|
||||
rtncode = self._process.poll()
|
||||
if rtncode is None:
|
||||
|
@ -681,17 +680,17 @@ class Mochitest(object):
|
|||
"logPath": logFile,
|
||||
"testPath": testPath}
|
||||
|
||||
config = open(os.path.join(options.profilePath, "testConfig.js"), "w")
|
||||
with open(os.path.join(options.profilePath, "testConfig.js"), "w") as config:
|
||||
config.write(content)
|
||||
config.close()
|
||||
|
||||
|
||||
def addChromeToProfile(self, options):
|
||||
"Adds MochiKit chrome tests to the profile."
|
||||
|
||||
# Create (empty) chrome directory.
|
||||
chromedir = os.path.join(options.profilePath, "chrome")
|
||||
os.mkdir(chromedir)
|
||||
|
||||
# Write userChrome.css.
|
||||
chrome = """
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
|
||||
toolbar,
|
||||
|
@ -702,19 +701,27 @@ toolbar#nav-bar {
|
|||
background-image: none !important;
|
||||
}
|
||||
"""
|
||||
|
||||
# write userChrome.css
|
||||
chromeFile = open(os.path.join(options.profilePath, "userChrome.css"), "a")
|
||||
with open(os.path.join(options.profilePath, "userChrome.css"), "a") as chromeFile:
|
||||
chromeFile.write(chrome)
|
||||
chromeFile.close()
|
||||
|
||||
|
||||
# register our chrome dir
|
||||
# Call copyTestsJarToProfile(), Write tests.manifest.
|
||||
manifest = os.path.join(options.profilePath, "tests.manifest")
|
||||
with open(manifest, "w") as manifestFile:
|
||||
if self.copyTestsJarToProfile(options):
|
||||
# Register tests.jar.
|
||||
manifestFile.write("content mochitests jar:tests.jar!/content/\n");
|
||||
else:
|
||||
# Register chrome directory.
|
||||
chrometestDir = os.path.abspath(".") + "/"
|
||||
if self.automation.IS_WIN32:
|
||||
chrometestDir = "file:///" + chrometestDir.replace("\\", "/")
|
||||
manifestFile.write("content mochitests %s contentaccessible=yes\n" % chrometestDir)
|
||||
|
||||
manifest = os.path.join(options.profilePath, 'tests.manifest')
|
||||
# Call installChromeJar().
|
||||
jarDir = "mochijar"
|
||||
if not os.path.isdir(os.path.join(self.SCRIPT_DIRECTORY, jarDir)):
|
||||
self.automation.log.warning("TEST-UNEXPECTED-FAIL | invalid setup: missing mochikit extension")
|
||||
return None
|
||||
|
||||
browser_chrome = ""
|
||||
if options.browserChrome:
|
||||
|
@ -726,48 +733,42 @@ overlay chrome://browser/content/browser.xul chrome://mochikit/content/browser-t
|
|||
#Currently there are focus issues in chrome tests and issues with new windows and dialogs when using ipc
|
||||
browser_chrome += "overlay chrome://browser/content/browser.xul chrome://mochikit/content/ipc-overlay.xul\n"
|
||||
|
||||
jarDir = 'mochijar'
|
||||
if not os.path.exists(os.path.join(self.SCRIPT_DIRECTORY, jarDir)):
|
||||
print "TEST-UNEXPECTED-FAIL | invalid setup: missing mochikit extension"
|
||||
return None
|
||||
|
||||
manifestFile = open(manifest, "w")
|
||||
if self.installTestsJar(options):
|
||||
manifestFile.write("content mochitests jar:tests.jar!/content/\n");
|
||||
else:
|
||||
manifestFile.write("content mochitests %s contentaccessible=yes\n" % chrometestDir)
|
||||
manifestFile.close()
|
||||
|
||||
self.installChromeJar(jarDir, browser_chrome, options)
|
||||
|
||||
return manifest
|
||||
|
||||
def installChromeJar(self, jarDirName, browser_chrome, options):
|
||||
"""
|
||||
copy mochijar directory to profile as an extension so we have chrome://mochikit for all harness code
|
||||
"""
|
||||
jarDir = os.path.join(options.profilePath, 'extensions', 'mochikit@mozilla.org')
|
||||
shutil.copytree(os.path.join(self.SCRIPT_DIRECTORY, jarDirName), jarDir)
|
||||
with open(os.path.join(jarDir, "chrome.manifest"), 'a') as mfile:
|
||||
self.automation.installExtension(os.path.join(self.SCRIPT_DIRECTORY, jarDirName), \
|
||||
options.profilePath, "mochikit@mozilla.org")
|
||||
|
||||
# Write chrome.manifest.
|
||||
with open(os.path.join(options.profilePath, "extensions", "mochikit@mozilla.org", "chrome.manifest"), "a") as mfile:
|
||||
mfile.write(browser_chrome)
|
||||
|
||||
return jarDir
|
||||
|
||||
def installTestsJar(self, options):
|
||||
def copyTestsJarToProfile(self, options):
|
||||
""" copy tests.jar to the profile directory so we can auto register it in the .xul harness """
|
||||
if os.path.exists(os.path.join(self.SCRIPT_DIRECTORY, 'tests.jar')):
|
||||
shutil.copy(os.path.join(self.SCRIPT_DIRECTORY, 'tests.jar'), options.profilePath)
|
||||
return True
|
||||
testsJarFile = os.path.join(self.SCRIPT_DIRECTORY, "tests.jar")
|
||||
if not os.path.isfile(testsJarFile):
|
||||
return False
|
||||
|
||||
shutil.copy2(testsJarFile, options.profilePath)
|
||||
return True
|
||||
|
||||
def copyExtraFilesToProfile(self, options):
|
||||
"Copy extra files or dirs specified on the command line to the testing profile."
|
||||
for f in options.extraProfileFiles:
|
||||
abspath = self.getFullPath(f)
|
||||
if os.path.isfile(abspath):
|
||||
shutil.copy2(abspath, options.profilePath)
|
||||
elif os.path.isdir(abspath):
|
||||
dest = os.path.join(options.profilePath, os.path.basename(abspath))
|
||||
if os.path.isdir(abspath):
|
||||
shutil.copytree(abspath, dest)
|
||||
else:
|
||||
shutil.copy(abspath, dest)
|
||||
self.automation.log.warning("WARNING | runtests.py | Failed to copy %s to profile", abspath)
|
||||
continue
|
||||
|
||||
def installExtensionsToProfile(self, options):
|
||||
"Install the specified extensions on the command line to the testing profile."
|
||||
|
|
Загрузка…
Ссылка в новой задаче