本文整理汇总了Python中mozrunner.FirefoxRunner类的典型用法代码示例。如果您正苦于以下问题:Python FirefoxRunner类的具体用法?Python FirefoxRunner怎么用?Python FirefoxRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FirefoxRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FFRunner
class FFRunner():
# Calls FirefoxRunner with the right parameters
def __init__(self, name="firefox", installDir=os.path.join(os.path.expanduser("~"),"remotebisectorapp")):
self.name = name
platform=get_platform()
if platform['name'] == "Windows":
if platform['bits'] == '64':
print "No builds available for 64 bit Windows"
sys.exit()
self.buildRegex = ".*win32.zip"
self.processName = self.name + ".exe"
self.binary = os.path.join(installDir, self.name, self.name + ".exe")
elif platform['name'] == "Linux":
self.processName = self.name + "-bin"
self.binary = os.path.join(installDir, self.name, self.name)
if platform['bits'] == '64':
self.buildRegex = ".*linux-x86_64.tar.bz2"
else:
self.buildRegex = ".*linux-i686.tar.bz2"
elif platform['name'] == "Mac":
self.buildRegex = ".*mac.*\.dmg"
self.processName = self.name + "-bin"
self.binary = os.path.join(installDir, "Mozilla.app/Contents/MacOS", self.name + "-bin")
def run(self):
self.runner = FirefoxRunner(binary=self.binary)
self.runner.start()
示例2: run
def run(self, test, phase='phase1', ignore_unused_engines=True):
args = [
'-tps={}'.format(os.path.abspath(test)),
'-tpsphase={}'.format(phase),
'-marionette']
if ignore_unused_engines:
args.append('--ignore-unused-engines')
process_args = {'processOutputLine': [self._log]}
self.logger.info('Running: {} {}'.format(self.firefox, ' '.join(args)))
self.logger.info('Using profile at: {}'.format(self.profile.profile))
runner = FirefoxRunner(
binary=self.firefox,
cmdargs=args,
profile=self.profile,
process_args=process_args)
runner.start(timeout=TIMEOUT)
runner.wait(timeout=TIMEOUT)
self.firefox_log.close()
with open(self.tps_log) as f:
for line in f.readlines():
if 'CROSSWEAVE ERROR: ' in line:
raise TPSError(line.partition('CROSSWEAVE ERROR: ')[-1])
with open(self.tps_log) as f:
assert 'test phase {}: PASS'.format(phase) in f.read()
示例3: runprofile
def runprofile(binary, fileobj):
try:
runner = FirefoxRunner(binary=binary, profile=fileobj.profile)
runner.start()
runner.wait()
except KeyboardInterrupt:
pass
示例4: run
def run(self, test, phase='phase1', ignore_unused_engines=True):
self.profile.set_preferences({
'testing.tps.testFile': os.path.abspath(test),
'testing.tps.testPhase': phase,
'testing.tps.ignoreUnusedEngines': ignore_unused_engines,
})
args = ['-marionette']
process_args = {'processOutputLine': [self._log]}
self.logger.info('Running: {} {}'.format(self.firefox, ' '.join(args)))
self.logger.info('Using profile at: {}'.format(self.profile.profile))
runner = FirefoxRunner(
binary=self.firefox,
cmdargs=args,
profile=self.profile,
process_args=process_args)
runner.start(timeout=TIMEOUT)
runner.wait(timeout=TIMEOUT)
self.firefox_log.close()
with open(self.tps_log) as f:
for line in f.readlines():
if 'CROSSWEAVE ERROR: ' in line:
raise TPSError(line.partition('CROSSWEAVE ERROR: ')[-1])
with open(self.tps_log) as f:
assert 'test phase {}: PASS'.format(phase) in f.read()
示例5: start
def start(self):
self.marionette_port = get_free_port(2828, exclude=self.used_ports)
env = os.environ.copy()
env["MOZ_CRASHREPORTER"] = "1"
env["MOZ_CRASHREPORTER_SHUTDOWN"] = "1"
env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
locations = ServerLocations(filename=os.path.join(here, "server-locations.txt"))
preferences = self.load_prefs()
ports = {"http": "8000",
"https": "8443",
"ws": "8888"}
self.profile = FirefoxProfile(locations=locations,
proxy=ports,
preferences=preferences)
self.profile.set_preferences({"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": self.marionette_port,
"dom.disable_open_during_load": False})
self.runner = FirefoxRunner(profile=self.profile,
binary=self.binary,
cmdargs=[cmd_arg("marionette"), "about:blank"],
env=env,
process_class=ProcessHandler,
process_args={"processOutputLine": [self.on_output]})
self.logger.debug("Starting Firefox")
self.runner.start(debug_args=self.debug_args, interactive=self.interactive)
self.logger.debug("Firefox Started")
示例6: start
def start(self):
self.marionette_port = get_free_port(2828, exclude=self.used_ports)
env = os.environ.copy()
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
locations = ServerLocations(filename=os.path.join(here, "server-locations.txt"))
preferences = self.load_prefs()
self.profile = FirefoxProfile(locations=locations,
preferences=preferences)
self.profile.set_preferences({"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": self.marionette_port,
"dom.disable_open_during_load": False,
"network.dns.localDomains": ",".join(hostnames)})
if self.ca_certificate_path is not None:
self.setup_ssl()
debug_args, cmd = browser_command(self.binary, [cmd_arg("marionette"), "about:blank"],
self.debug_info)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd[0],
cmdargs=cmd[1:],
env=env,
process_class=ProcessHandler,
process_args={"processOutputLine": [self.on_output]})
self.logger.debug("Starting Firefox")
self.runner.start(debug_args=debug_args, interactive=self.debug_info and self.debug_info.interactive)
self.logger.debug("Firefox Started")
示例7: run
def run(self, profile=None, timeout=PROCESS_TIMEOUT, env=None, args=None):
"""Runs the given FirefoxRunner with the given Profile, waits
for completion, then returns the process exit code
"""
if profile is None:
profile = Profile()
self.profile = profile
if self.binary is None and self.url:
self.binary = self.download_build()
runner = FirefoxRunner(profile=self.profile, binary=self.binary,
env=env, cmdargs=args)
runner.start(timeout=timeout)
return runner.wait()
示例8: run
def run(self, profile=None, timeout=PROCESS_TIMEOUT, env=None, args=None):
"""Runs the given FirefoxRunner with the given Profile, waits
for completion, then returns the process exit code
"""
if profile is None:
profile = Profile()
self.profile = profile
if self.binary is None and self.url:
self.binary = self.download_build()
if self.runner is None:
self.runner = FirefoxRunner(self.profile, binary=self.binary)
self.runner.profile = self.profile
if env is not None:
self.runner.env.update(env)
if args is not None:
self.runner.cmdargs = copy.copy(args)
self.runner.start()
status = self.runner.process_handler.waitForFinish(timeout=timeout)
return status
示例9: start
def start(self, **kwargs):
if self.marionette_port is None:
self.marionette_port = get_free_port(2828, exclude=self.used_ports)
self.used_ports.add(self.marionette_port)
env = os.environ.copy()
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
env["STYLO_THREADS"] = str(self.stylo_threads)
locations = ServerLocations(filename=os.path.join(here, "server-locations.txt"))
preferences = self.load_prefs()
self.profile = FirefoxProfile(locations=locations,
preferences=preferences)
self.profile.set_preferences({"marionette.port": self.marionette_port,
"dom.disable_open_during_load": False,
"network.dns.localDomains": ",".join(hostnames),
"network.proxy.type": 0,
"places.history.enabled": False,
"dom.send_after_paint_to_content": True})
if self.e10s:
self.profile.set_preferences({"browser.tabs.remote.autostart": True})
if self.test_type == "reftest":
self.profile.set_preferences({"layout.interruptible-reflow.enabled": False})
if self.leak_check and kwargs.get("check_leaks", True):
self.leak_report_file = os.path.join(self.profile.profile, "runtests_leaks.log")
if os.path.exists(self.leak_report_file):
os.remove(self.leak_report_file)
env["XPCOM_MEM_BLOAT_LOG"] = self.leak_report_file
else:
self.leak_report_file = None
# Bug 1262954: winxp + e10s, disable hwaccel
if (self.e10s and platform.system() in ("Windows", "Microsoft") and
'5.1' in platform.version()):
self.profile.set_preferences({"layers.acceleration.disabled": True})
if self.ca_certificate_path is not None:
self.setup_ssl()
debug_args, cmd = browser_command(self.binary,
self.binary_args if self.binary_args else [] +
[cmd_arg("marionette"), "about:blank"],
self.debug_info)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd[0],
cmdargs=cmd[1:],
env=env,
process_class=ProcessHandler,
process_args={"processOutputLine": [self.on_output]})
self.logger.debug("Starting Firefox")
self.runner.start(debug_args=debug_args, interactive=self.debug_info and self.debug_info.interactive)
self.logger.debug("Firefox Started")
示例10: run
def run(self):
#Run the built binary if it exists. ONLY WORKS IF BUILD WAS CALLED!
if sys.platform == "darwin":
runner = FirefoxRunner.create(binary=os.path.join(self.shellCacheDir,"mozbuild-trunk","obj-ff-dbg","dist","NightlyDebug.app","Contents","MacOS")+"/firefox-bin")
runner.start()
runner.wait()
elif sys.platform == "linux2":
runner = FirefoxRunner.create(binary=os.path.join(self.shellCacheDir,"mozbuild-trunk","obj-ff-dbg","dist","bin") + "/firefox")
runner.start()
runner.wait()
elif sys.platform == "win32" or sys.platform == "cygwin":
runner = FirefoxRunner.create(binary=os.path.join(self.shellCacheDir,"mozbuild-trunk","obj-ff-dbg","dist","bin") + "/firefox.exe")
runner.start()
runner.wait()
else:
print "Your platform is not currently supported."
quit()
示例11: run_tests
def run_tests(self, tests, options):
manifests = self.resolver.resolveManifests(options, tests)
self.profile = self.create_profile(options, manifests,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
self._populate_logger(options)
outputHandler = OutputHandler(self.log, options.utilityPath, symbolsPath=options.symbolsPath)
kp_kwargs = { 'processOutputLine': [outputHandler],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
self.log.info("%s | Running tests: start." % os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize,
browser_arg=options.browser_arg)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
process_args=kp_kwargs,
symbols_path=options.symbolsPath)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
self.log.info("%s | Application pid: %d" % (
os.path.basename(__file__),
self.runner.process_handler.pid))
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
self.log.testFail("%s | application terminated with exit code %s" % (
self.last_test, status))
elif status < 0:
self.log.info("%s | application killed with signal %s" % (
self.last_test, -status))
self.log.info("%s | Running tests: end." % os.path.basename(__file__))
return status
示例12: run_tests
def run_tests(self, test_path, options):
reftestlist = self.getManifestPath(test_path)
if not reftestlist.startswith('file://'):
reftestlist = 'file://%s' % reftestlist
self.profile = self.create_profile(options, reftestlist,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
kp_kwargs = { 'processOutputLine': [self._on_output],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
log.info("%s | Running tests: start.", os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
symbols_path=options.symbolsPath,
kp_kwargs=kp_kwargs)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
log.info("%s | Application pid: %d",
os.path.basename(__file__),
self.runner.process_handler.pid)
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
log.testFail("%s | application terminated with exit code %s",
self.last_test, status)
elif status < 0:
log.info("%s | application killed with signal %s",
self.last_test, -status)
log.info("%s | Running tests: end.", os.path.basename(__file__))
return status
示例13: start
def start(self):
self.marionette_port = get_free_port(2828, exclude=self.used_ports)
self.used_ports.add(self.marionette_port)
env = os.environ.copy()
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
locations = ServerLocations(filename=os.path.join(here, "server-locations.txt"))
preferences = self.load_prefs()
self.profile = FirefoxProfile(locations=locations,
preferences=preferences)
self.profile.set_preferences({"marionette.enabled": True,
"marionette.port": self.marionette_port,
"dom.disable_open_during_load": False,
"network.dns.localDomains": ",".join(hostnames),
"network.proxy.type": 0,
"places.history.enabled": False})
if self.e10s:
self.profile.set_preferences({"browser.tabs.remote.autostart": True})
# Bug 1262954: winxp + e10s, disable hwaccel
if (self.e10s and platform.system() in ("Windows", "Microsoft") and
'5.1' in platform.version()):
self.profile.set_preferences({"layers.acceleration.disabled": True})
if self.ca_certificate_path is not None:
self.setup_ssl()
debug_args, cmd = browser_command(self.binary,
self.binary_args if self.binary_args else [] +
[cmd_arg("marionette"), "about:blank"],
self.debug_info)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd[0],
cmdargs=cmd[1:],
env=env,
process_class=ProcessHandler,
process_args={"processOutputLine": [self.on_output]})
self.logger.debug("Starting Firefox")
self.runner.start(debug_args=debug_args, interactive=self.debug_info and self.debug_info.interactive)
self.logger.debug("Firefox Started")
示例14: run
def run(self):
'''
Starts Firefox thread with Marionette turned on.
'''
self.profile = FirefoxProfile()
self.profile.set_preferences({"marionette.defaultPrefs.enabled" : True,
"marionette.defaultPrefs.port": 2828,
"browser.startup.page": 0,
"browser.startup.homepage": "about:blank",
})
self.runner = FirefoxRunner(profile = self.profile,
binary = self.binary,
kp_kwargs = {'processOutputLine' : [self.logger]})
self.runner.start()
self._firefoxRunningEvent.set()
self.runner.wait()
示例15: start_firefox
def start_firefox(self):
env = os.environ.copy()
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
profile = Profile()
profile.set_preferences({"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": self.marionette_port,
"dom.disable_open_during_load": False,
"dom.max_script_run_time": 0})
self.firefox_runner = FirefoxRunner(profile,
self.firefox_binary,
cmdargs=["--marionette"],
env=env,
kp_kwargs = {"processOutputLine":[self.on_output]},
process_class=self.process_cls)
self.logger.debug("Starting Firefox")
self.firefox_runner.start()
self.logger.debug("Firefox Started")