Bug 1308202 - Remove all b2g and mulet related code from testing/mochitest, r=jmaher

MozReview-Commit-ID: BfIJLp6oGHO

--HG--
extra : rebase_source : 7202f2a6026a4082f0561045dd8e2f4da0baa424
This commit is contained in:
Andrew Halberstadt 2016-10-06 10:05:27 -04:00
Родитель 620c688a3f
Коммит 5ca5caf353
15 изменённых файлов: 22 добавлений и 905 удалений

Просмотреть файл

@ -30,15 +30,6 @@ if (Services.appinfo.OS == 'Android') {
setTimeout(testInit, 0);
}
function b2gStart() {
let homescreen = document.getElementById('systemapp');
var webNav = homescreen.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
var url = "chrome://mochikit/content/harness.xul?manifestFile=tests.json";
webNav.loadURI(url, null, null, null, null);
}
var TabDestroyObserver = {
outstanding: new Set(),
promiseResolver: null,

Просмотреть файл

@ -1,13 +1,11 @@
[DEFAULT]
skip-if = buildapp == 'b2g' || os == 'android'
skip-if = os == 'android'
support-files = test-dir/test-file
[test_sample.xul]
[test_sanityAddTask.xul]
[test_sanityEventUtils.xul]
skip-if = buildapp == 'mulet'
[test_sanityPluginUtils.html]
skip-if = buildapp == 'mulet'
[test_sanityException.xul]
[test_sanityException2.xul]
[test_sanityManifest.xul]

Просмотреть файл

@ -23,7 +23,6 @@ from mach.decorators import (
CommandProvider,
Command,
)
import mozpack.path as mozpath
here = os.path.abspath(os.path.dirname(__file__))
@ -82,7 +81,7 @@ ALL_FLAVORS = {
'mochitest': {
'suite': 'plain',
'aliases': ('plain', 'mochitest'),
'enabled_apps': ('firefox', 'b2g', 'android', 'mulet'),
'enabled_apps': ('firefox', 'android'),
'extra_args': {
'flavor': 'plain',
}
@ -90,7 +89,7 @@ ALL_FLAVORS = {
'chrome': {
'suite': 'chrome',
'aliases': ('chrome', 'mochitest-chrome'),
'enabled_apps': ('firefox', 'mulet', 'b2g', 'android'),
'enabled_apps': ('firefox', 'android'),
'extra_args': {
'flavor': 'chrome',
}
@ -129,7 +128,7 @@ ALL_FLAVORS = {
},
}
SUPPORTED_APPS = ['firefox', 'b2g', 'android', 'mulet']
SUPPORTED_APPS = ['firefox', 'android']
SUPPORTED_FLAVORS = list(chain.from_iterable([f['aliases'] for f in ALL_FLAVORS.values()]))
CANONICAL_FLAVORS = sorted([f['aliases'][0] for f in ALL_FLAVORS.values()])
@ -168,41 +167,6 @@ class MochitestRunner(MozbuildObject):
tests = list(resolver.resolve_tests(paths=test_paths, cwd=cwd))
return tests
def run_b2g_test(self, context, tests=None, suite='mochitest', **kwargs):
"""Runs a b2g mochitest."""
if context.target_out:
host_webapps_dir = os.path.join(context.target_out, 'data', 'local', 'webapps')
if not os.path.isdir(os.path.join(
host_webapps_dir, 'test-container.gaiamobile.org')):
print(ENG_BUILD_REQUIRED.format(host_webapps_dir))
sys.exit(1)
# TODO without os.chdir, chained imports fail below
os.chdir(self.mochitest_dir)
# The imp module can spew warnings if the modules below have
# already been imported, ignore them.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import imp
path = os.path.join(self.mochitest_dir, 'runtestsb2g.py')
with open(path, 'r') as fh:
imp.load_module('mochitest', fh, path,
('.py', 'r', imp.PY_SOURCE))
import mochitest
options = Namespace(**kwargs)
from manifestparser import TestManifest
if tests and not options.manifestFile:
manifest = TestManifest()
manifest.tests.extend(tests)
options.manifestFile = manifest
return mochitest.run_test_harness(parser, options)
def run_desktop_test(self, context, tests=None, suite=None, **kwargs):
"""Runs a mochitest.
@ -395,20 +359,6 @@ class MachCommands(MachCommandBase):
test_paths = kwargs['test_paths']
kwargs['test_paths'] = []
if test_paths and buildapp == 'b2g':
# In B2G there is often a 'gecko' directory, though topsrcdir is actually
# elsewhere. This little hack makes test paths like 'gecko/dom' work, even if
# GECKO_PATH is set in the .userconfig
gecko_path = mozpath.abspath(mozpath.join(kwargs['b2gPath'], 'gecko'))
if gecko_path != self.topsrcdir:
new_paths = []
for tp in test_paths:
if mozpath.abspath(tp).startswith(gecko_path):
new_paths.append(mozpath.relpath(tp, gecko_path))
else:
new_paths.append(tp)
test_paths = new_paths
mochitest = self._spawn(MochitestRunner)
tests = []
if resolve_tests:
@ -476,9 +426,7 @@ class MachCommands(MachCommandBase):
buildapp, '\n'.join(sorted(msg))))
return 1
if buildapp in ('b2g',):
run_mochitest = mochitest.run_b2g_test
elif buildapp == 'android':
if buildapp == 'android':
from mozrunner.devices.android_device import grant_runtime_permissions
grant_runtime_permissions(self)
run_mochitest = mochitest.run_android_test

Просмотреть файл

@ -8,7 +8,7 @@ function parseTestManifest(testManifest, params, callback) {
var links = {};
var paths = [];
// Support --test-manifest format for mobile/b2g
// Support --test-manifest format for mobile
if ("runtests" in testManifest || "excludetests" in testManifest) {
callback(testManifest);
return;

Просмотреть файл

@ -566,8 +566,8 @@ class MochitestArguments(ArgumentContainer):
# for test manifest parsing.
mozinfo.update({"nested_oop": options.nested_oop})
# b2g and android don't use 'app' the same way, so skip validation
if parser.app not in ('b2g', 'android'):
# and android doesn't use 'app' the same way, so skip validation
if parser.app != 'android':
if options.app is None:
if build_obj:
options.app = build_obj.get_binary_path()
@ -789,179 +789,6 @@ class MochitestArguments(ArgumentContainer):
return options
class B2GArguments(ArgumentContainer):
"""B2G specific arguments."""
args = [
[["--b2gpath"],
{"dest": "b2gPath",
"default": None,
"help": "Path to B2G repo or QEMU directory.",
"suppress": True,
}],
[["--emulator"],
{"default": None,
"help": "Architecture of emulator to use, x86 or arm",
"suppress": True,
}],
[["--wifi"],
{"default": False,
"help": "Devine wifi configuration for on device mochitest",
"suppress": True,
}],
[["--sdcard"],
{"default": "10MB",
"help": "Define size of sdcard: 1MB, 50MB...etc",
}],
[["--no-window"],
{"action": "store_true",
"dest": "noWindow",
"default": False,
"help": "Pass --no-window to the emulator",
}],
[["--adbpath"],
{"dest": "adbPath",
"default": None,
"help": "Path to adb binary.",
"suppress": True,
}],
[["--deviceIP"],
{"dest": "deviceIP",
"default": None,
"help": "IP address of remote device to test.",
"suppress": True,
}],
[["--devicePort"],
{"default": 20701,
"help": "port of remote device to test",
"suppress": True,
}],
[["--remote-logfile"],
{"dest": "remoteLogFile",
"default": None,
"help": "Name of log file on the device relative to the device root. "
"PLEASE ONLY USE A FILENAME.",
"suppress": True,
}],
[["--remote-webserver"],
{"dest": "remoteWebServer",
"default": None,
"help": "IP address where the remote web server is hosted.",
"suppress": True,
}],
[["--http-port"],
{"dest": "httpPort",
"default": DEFAULT_PORTS['http'],
"help": "Port used for http on the remote web server.",
"suppress": True,
}],
[["--ssl-port"],
{"dest": "sslPort",
"default": DEFAULT_PORTS['https'],
"help": "Port used for https on the remote web server.",
"suppress": True,
}],
[["--gecko-path"],
{"dest": "geckoPath",
"default": None,
"help": "The path to a gecko distribution that should be installed on the emulator "
"prior to test.",
"suppress": True,
}],
[["--logdir"],
{"dest": "logdir",
"default": None,
"help": "Directory to store log files.",
}],
[['--busybox'],
{"dest": 'busybox',
"default": None,
"help": "Path to busybox binary to install on device.",
}],
[['--profile-data-dir'],
{"dest": 'profile_data_dir',
"default": os.path.join(here, 'profile_data'),
"help": "Path to a directory containing preference and other data to be installed "
"into the profile.",
"suppress": True,
}],
]
defaults = {
'logFile': 'mochitest.log',
# Specialpowers is integrated with marionette for b2g,
# see marionette's jar.mn.
'extensionsToExclude': ['specialpowers'],
# mochijar doesn't get installed via marionette on android
'extensionsToInstall': [os.path.join(here, 'mochijar')],
# See dependencies of bug 1038943.
'defaultLeakThreshold': 5536,
}
def validate(self, parser, options, context):
"""Validate b2g options."""
if options.remoteWebServer is None:
if os.name != "nt":
options.remoteWebServer = moznetwork.get_ip()
else:
parser.error(
"You must specify a --remote-webserver=<ip address>")
options.webServer = options.remoteWebServer
if not options.b2gPath and hasattr(context, 'b2g_home'):
options.b2gPath = context.b2g_home
if hasattr(context, 'device_name') and not options.emulator:
if context.device_name.startswith('emulator'):
options.emulator = 'x86' if 'x86' in context.device_name else 'arm'
if options.geckoPath and not options.emulator:
parser.error(
"You must specify --emulator if you specify --gecko-path")
if options.logdir and not options.emulator:
parser.error("You must specify --emulator if you specify --logdir")
elif not options.logdir and options.emulator and build_obj:
options.logdir = os.path.join(
build_obj.topobjdir, '_tests', 'testing', 'mochitest')
if hasattr(context, 'xre_path'):
options.xrePath = context.xre_path
if not os.path.isdir(options.xrePath):
parser.error("--xre-path '%s' is not a directory" % options.xrePath)
xpcshell = os.path.join(options.xrePath, 'xpcshell')
if not os.access(xpcshell, os.F_OK):
parser.error('xpcshell not found at %s' % xpcshell)
if self.elf_arm(xpcshell):
parser.error('--xre-path points to an ARM version of xpcshell; it '
'should instead point to a version that can run on '
'your desktop')
if not options.httpdPath and build_obj:
options.httpdPath = os.path.join(
build_obj.topobjdir, '_tests', 'testing', 'mochitest')
# Bug 1071866 - B2G Mochitests do not always produce a leak log.
options.ignoreMissingLeaks.append("default")
# Bug 1070068 - Leak logging does not work for tab processes on B2G.
options.ignoreMissingLeaks.append("tab")
if options.pidFile != "":
f = open(options.pidFile, 'w')
f.write("%s" % os.getpid())
f.close()
return options
def elf_arm(self, filename):
data = open(filename, 'rb').read(20)
return data[:4] == "\x7fELF" and ord(data[18]) == 40 # EM_ARM
class AndroidArguments(ArgumentContainer):
"""Android specific arguments."""
@ -1160,7 +987,6 @@ class AndroidArguments(ArgumentContainer):
container_map = {
'generic': [MochitestArguments],
'b2g': [MochitestArguments, B2GArguments],
'android': [MochitestArguments, AndroidArguments],
}
@ -1179,8 +1005,6 @@ class MochitestArgumentParser(ArgumentParser):
if not self.app and build_obj:
if conditions.is_android(build_obj):
self.app = 'android'
elif conditions.is_b2g(build_obj):
self.app = 'b2g'
if not self.app:
# platform can't be determined and app wasn't specified explicitly,
# so just use generic arguments and hope for the best

Просмотреть файл

@ -63,10 +63,8 @@ TEST_HARNESS_FILES.testing.mochitest += [
'redirect.html',
'runrobocop.py',
'runtests.py',
'runtestsb2g.py',
'runtestsremote.py',
'server.js',
'start_b2g.js',
'start_desktop.js',
]

Просмотреть файл

@ -519,7 +519,7 @@ class WebSocketServer(object):
class MochitestBase(object):
"""
Base mochitest class for both desktop and b2g.
Base mochitest class for desktop.
"""
oldcwd = os.getcwd()
@ -1519,7 +1519,7 @@ def parseKeyValue(strings, separator='=', context='key, value: '):
class MochitestDesktop(MochitestBase):
"""
Mochitest class for desktop firefox and mulet.
Mochitest class for desktop firefox.
"""
certdbNew = False
sslTunnel = None
@ -1584,7 +1584,7 @@ class MochitestDesktop(MochitestBase):
toolsEnv["TSAN_OPTIONS"] = "report_bugs=0"
if self.certdbNew:
# android and b2g use the new DB formats exclusively
# android uses the new DB formats exclusively
certdbPath = "sql:" + options.profilePath
else:
# desktop seems to use the old
@ -1661,12 +1661,6 @@ class MochitestDesktop(MochitestBase):
'profile_data',
'prefs_general.js')]
# TODO: Let's include those prefs until bug 1072443 is fixed
if mozinfo.info.get('buildapp') == 'mulet':
preferences += [os.path.join(SCRIPT_DIR,
'profile_data',
'prefs_b2g_unittest.js')]
prefs = {}
for path in preferences:
prefs.update(Preferences.read_prefs(path))
@ -1683,10 +1677,6 @@ class MochitestDesktop(MochitestBase):
"server": "%s:%s" %
(options.webServer, options.httpPort)}
# TODO: Remove OOP once bug 1072443 is fixed
if mozinfo.info.get('buildapp') == 'mulet':
interpolation["OOP"] = "false"
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
@ -1998,17 +1988,11 @@ class MochitestDesktop(MochitestBase):
self.lastTestSeen = self.test_name
startTime = datetime.now()
# b2g desktop requires Runner even though appname is b2g
if mozinfo.info.get('appname') == 'b2g' and mozinfo.info.get(
'toolkit') != 'gonk':
runner_cls = mozrunner.Runner
else:
runner_cls = mozrunner.runners.get(
mozinfo.info.get(
'appname',
'firefox'),
mozrunner.Runner)
runner_cls = mozrunner.runners.get(
mozinfo.info.get(
'appname',
'firefox'),
mozrunner.Runner)
runner = runner_cls(profile=self.profile,
binary=cmd,
cmdargs=args,
@ -2326,14 +2310,6 @@ class MochitestDesktop(MochitestBase):
options,
debuggerInfo is not None)
# If there are any Mulet-specific tests doing remote network access,
# we will not be aware since we are explicitely allowing this, as for
# B2G
if 'MOZ_DISABLE_NONLOCAL_CONNECTIONS' in self.browserEnv:
if mozinfo.info.get('buildapp') == 'mulet':
del self.browserEnv['MOZ_DISABLE_NONLOCAL_CONNECTIONS']
os.environ["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "0"
if self.browserEnv is None:
return 1
@ -2694,9 +2670,6 @@ def run_test_harness(parser, options):
if options.flavor in ('plain', 'browser', 'chrome'):
options.runByDir = True
if mozinfo.info.get('buildapp') == 'mulet':
options.runByDir = False
result = runner.runTests(options)
if runner.mozLogs:

Просмотреть файл

@ -1,423 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import json
import os
import posixpath
import sys
import tempfile
import traceback
here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, here)
from runtests import MochitestBase
from mochitest_options import MochitestArgumentParser
from marionette import Marionette
from mozprofile import Profile, Preferences
from mozrunner.utils import get_stack_fixer_function
import mozinfo
import mozleak
class MochitestB2G(MochitestBase):
"""
Mochitest class for b2g emulators and devices.
"""
marionette = None
remote_log = None
def __init__(self, marionette_args,
logger_options,
profile_data_dir,
local_binary_dir,
locations=os.path.join(here, 'server-locations.txt'),
out_of_process=True,
remote_test_root=None,
remote_log_file=None):
MochitestBase.__init__(self, logger_options)
self.marionette_args = marionette_args
self.out_of_process = out_of_process
self.locations_file = locations
self.preferences = []
self.webapps = None
self.start_script = os.path.join(here, 'start_b2g.js')
self.start_script_args = [self.out_of_process]
self.product = 'b2g'
self.remote_chrome_test_dir = None
self.local_log = None
self.local_binary_dir = local_binary_dir
self.preferences = [
os.path.join(
profile_data_dir,
f) for f in os.listdir(profile_data_dir) if f.startswith('pref')]
self.webapps = [
os.path.join(
profile_data_dir,
f) for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
# mozinfo is populated by the parent class
if mozinfo.info['debug']:
self.SERVER_STARTUP_TIMEOUT = 180
else:
self.SERVER_STARTUP_TIMEOUT = 90
def buildTestPath(self, options, testsToFilter=None):
if options.manifestFile != 'tests.json':
MochitestBase.buildTestPath(self, options, testsToFilter, disabled=False)
return self.buildTestURL(options)
def build_profile(self, options):
# preferences
prefs = {}
for path in self.preferences:
prefs.update(Preferences.read_prefs(path))
for v in options.extraPrefs:
thispref = v.split("=", 1)
if len(thispref) < 2:
print "Error: syntax error in --setpref=" + v
sys.exit(1)
prefs[thispref[0]] = thispref[1]
# interpolate the preferences
interpolation = {
"server": "%s:%s" %
(options.webServer,
options.httpPort),
"OOP": "true" if self.out_of_process else "false"}
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
kwargs = {
'addons': self.getExtensionsToInstall(options),
'apps': self.webapps,
'locations': self.locations_file,
'preferences': prefs,
'proxy': {"remote": options.webServer}
}
self.profile = Profile(**kwargs)
options.profilePath = self.profile.profile
# TODO bug 839108 - mozprofile should probably handle this
manifest = self.addChromeToProfile(options)
self.copyExtraFilesToProfile(options)
return manifest
def run_tests(self, options):
""" Prepare, configure, run tests and cleanup """
self.setTestRoot(options)
manifest = self.build_profile(options)
self.logPreamble(self.getActiveTests(options))
# configuring the message logger's buffering
self.message_logger.buffering = options.quiet
if options.debugger or not options.autorun:
timeout = None
else:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
timeout = options.timeout + 30.0
self.log.info("runtestsb2g.py | Running tests: start.")
status = 0
try:
def on_output(line):
messages = self.message_logger.write(line)
for message in messages:
if message['action'] == 'test_start':
self.runner.last_test = message['test']
# The logging will be handled by on_output, so we set the stream to
# None
process_args = {'processOutputLine': on_output,
'stream': None}
self.marionette_args['process_args'] = process_args
self.marionette_args['profile'] = self.profile
# Increase the timeout to fix bug 1208725
self.marionette_args['socket_timeout'] = 720
self.marionette = Marionette(**self.marionette_args)
self.runner = self.marionette.runner
self.app_ctx = self.runner.app_ctx
self.remote_log = posixpath.join(self.app_ctx.remote_test_root,
'log', 'mochitest.log')
if not self.app_ctx.dm.dirExists(
posixpath.dirname(
self.remote_log)):
self.app_ctx.dm.mkDirs(self.remote_log)
if options.flavor == 'chrome':
# Update chrome manifest file in profile with correct path.
self.writeChromeManifest(options)
self.leak_report_file = posixpath.join(
self.app_ctx.remote_test_root,
'log',
'runtests_leaks.log')
# We don't want to copy the host env onto the device, so pass in an
# empty env.
self.browserEnv = self.buildBrowserEnv(options, env={})
# B2G emulator debug tests still make external connections, so don't
# pass MOZ_DISABLE_NONLOCAL_CONNECTIONS to them for now (bug
# 1039019).
if mozinfo.info[
'debug'] and 'MOZ_DISABLE_NONLOCAL_CONNECTIONS' in self.browserEnv:
del self.browserEnv['MOZ_DISABLE_NONLOCAL_CONNECTIONS']
self.runner.env.update(self.browserEnv)
# Despite our efforts to clean up servers started by this script, in practice
# we still see infrequent cases where a process is orphaned and interferes
# with future tests, typically because the old server is keeping the port in use.
# Try to avoid those failures by checking for and killing orphan servers before
# trying to start new ones.
self.killNamedOrphans('ssltunnel')
self.killNamedOrphans('xpcshell')
self.startServers(options, None)
# In desktop mochitests buildTestPath is called before buildURLOptions. This
# means options.manifestFile has already been converted to the proper json
# style manifest. Not so with B2G, that conversion along with updating the URL
# option will happen later. So backup and restore options.manifestFile to
# prevent us from trying to pass in an instance of TestManifest via url param.
manifestFile = options.manifestFile
options.manifestFile = None
self.buildURLOptions(options, {'MOZ_HIDE_RESULTS_TABLE': '1'})
options.manifestFile = manifestFile
self.start_script_args.append(not options.emulator)
self.start_script_args.append(options.wifi)
self.start_script_args.append(options.flavor == 'chrome')
self.runner.start(outputTimeout=timeout)
self.marionette.wait_for_port()
self.marionette.start_session()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
# Disable offline status management (bug 777145), otherwise the network
# will be 'offline' when the mochitests start. Presumably, the network
# won't be offline on a real device, so we only do this for
# emulators.
self.marionette.execute_script("""
Components.utils.import("resource://gre/modules/Services.jsm");
Services.io.manageOfflineStatus = false;
Services.io.offline = false;
""")
self.marionette.execute_script("""
let SECURITY_PREF = "security.turn_off_all_security_" +
"so_that_viruses_can_take_over_this_computer";
Services.prefs.setBoolPref(SECURITY_PREF, true);
if (!testUtils.hasOwnProperty("specialPowersObserver")) {
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.jsm",
testUtils);
testUtils.specialPowersObserver = new testUtils.SpecialPowersObserver();
testUtils.specialPowersObserver.init();
}
""")
if options.flavor == 'chrome':
self.app_ctx.dm.removeDir(self.remote_chrome_test_dir)
self.app_ctx.dm.mkDir(self.remote_chrome_test_dir)
local = MochitestBase.getChromeTestDir(self, options)
local = os.path.join(local, "chrome")
remote = self.remote_chrome_test_dir
self.log.info(
"pushing %s to %s on device..." %
(local, remote))
self.app_ctx.dm.pushDir(local, remote)
self.execute_start_script()
status = self.runner.wait()
if status is None:
# the runner has timed out
status = 124
local_leak_file = tempfile.NamedTemporaryFile()
self.app_ctx.dm.getFile(
self.leak_report_file,
local_leak_file.name)
self.app_ctx.dm.removeFile(self.leak_report_file)
mozleak.process_leak_log(
local_leak_file.name,
leak_thresholds=options.leakThresholds,
ignore_missing_leaks=options.ignoreMissingLeaks,
log=self.log,
stack_fixer=get_stack_fixer_function(options.utilityPath,
options.symbolsPath),
)
except KeyboardInterrupt:
self.log.info("runtests.py | Received keyboard interrupt.\n")
status = -1
except:
traceback.print_exc()
self.log.error(
"Automation Error: Received unexpected exception while running application\n")
if hasattr(self, 'runner'):
self.runner.check_for_crashes()
status = 1
self.stopServers()
self.log.info("runtestsb2g.py | Running tests: end.")
if manifest is not None:
self.cleanup(manifest, options)
return status
def getGMPPluginPath(self, options):
if options.gmp_path:
return options.gmp_path
return '/system/b2g/gmp-clearkey/0.1'
def getChromeTestDir(self, options):
# The chrome test directory returned here is the remote location
# of chrome test files. A reference to this directory is requested
# when building the profile locally, before self.app_ctx is defined.
# To get around this, return a dummy directory until self.app_ctx
# is defined; the correct directory will be returned later, over-
# writing the dummy.
if hasattr(self, 'app_ctx'):
self.remote_chrome_test_dir = posixpath.join(
self.app_ctx.remote_test_root,
'chrome')
return self.remote_chrome_test_dir
return 'dummy-chrome-test-dir'
def cleanup(self, manifest, options):
if self.local_log:
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
self.app_ctx.dm.removeFile(self.remote_log)
if options.pidFile != "":
try:
os.remove(options.pidFile)
os.remove(options.pidFile + ".xpcshell.pid")
except:
print("Warning: cleaning up pidfile '%s' was unsuccessful "
"from the test harness") % options.pidFile
# stop and clean up the runner
if getattr(self, 'runner', False):
if self.local_log:
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
self.app_ctx.dm.removeFile(self.remote_log)
self.runner.cleanup()
self.runner = None
def startServers(self, options, debuggerInfo):
""" Create the servers on the host and start them up """
savedXre = options.xrePath
savedUtility = options.utilityPath
savedProfie = options.profilePath
options.xrePath = self.local_binary_dir
options.utilityPath = self.local_binary_dir
options.profilePath = tempfile.mkdtemp()
MochitestBase.startServers(self, options, debuggerInfo)
options.xrePath = savedXre
options.utilityPath = savedUtility
options.profilePath = savedProfie
def buildURLOptions(self, options, env):
self.local_log = options.logFile
options.logFile = self.remote_log
options.profilePath = self.profile.profile
MochitestBase.buildURLOptions(self, options, env)
test_url = self.buildTestPath(options)
# For B2G emulators buildURLOptions has been called
# without calling buildTestPath first and that
# causes manifestFile not to be set
if "manifestFile=tests.json" not in self.urlOpts:
self.urlOpts.append("manifestFile=%s" % options.manifestFile)
if len(self.urlOpts) > 0:
test_url += "?" + "&".join(self.urlOpts)
self.start_script_args.append(test_url)
options.profilePath = self.app_ctx.remote_profile
options.logFile = self.local_log
def run_test_harness(parser, options):
parser.validate(options)
# create our Marionette instance
marionette_args = {
'adb_path': options.adbPath,
'emulator': options.emulator,
'no_window': options.noWindow,
'logdir': options.logdir,
'busybox': options.busybox,
'symbols_path': options.symbolsPath,
'sdcard': options.sdcard,
'homedir': options.b2gPath,
}
if options.marionette:
host, port = options.marionette.split(':')
marionette_args['host'] = host
marionette_args['port'] = int(port)
if (options is None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
mochitest = MochitestB2G(
marionette_args,
options,
options.profile_data_dir,
options.xrePath,
remote_log_file=options.remoteLogFile)
if (options is None):
sys.exit(1)
retVal = 1
try:
mochitest.cleanup(None, options)
retVal = mochitest.run_tests(options)
except:
print "Automation Error: Exception caught while running tests"
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(None, options)
except:
pass
retVal = 1
mochitest.message_logger.finish()
return retVal
def main():
parser = MochitestArgumentParser(app='b2g')
options = parser.parse_args()
return run_test_harness(parser, options)
if __name__ == "__main__":
sys.exit(main())

Просмотреть файл

@ -190,8 +190,7 @@ class MochiRemote(MochitestDesktop):
def addChromeToProfile(self, options):
manifest = MochitestDesktop.addChromeToProfile(self, options)
# Support Firefox (browser), B2G (shell), SeaMonkey (navigator), and Webapp
# Runtime (webapp).
# Support Firefox (browser), SeaMonkey (navigator), and Webapp Runtime (webapp).
if options.flavor == 'chrome':
# append overlay to chrome.manifest
chrome = ("overlay chrome://browser/content/browser.xul "

Просмотреть файл

@ -1,176 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var outOfProcess = __webDriverArguments[0]
var mochitestUrl = __webDriverArguments[1]
var onDevice = __webDriverArguments[2]
var wifiSettings = __webDriverArguments[3]
var chrome = __webDriverArguments[4]
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch)
var settings = window.navigator.mozSettings;
var cm = Components.classes["@mozilla.org/categorymanager;1"].
getService(Components.interfaces.nsICategoryManager);
if (wifiSettings)
wifiSettings = JSON.parse(wifiSettings);
const CHILD_SCRIPT = "chrome://specialpowers/content/specialpowers.js";
const CHILD_SCRIPT_API = "chrome://specialpowers/content/specialpowersAPI.js";
const CHILD_LOGGER_SCRIPT = "chrome://specialpowers/content/MozillaLogger.js";
var homescreen = document.getElementById('systemapp');
var container = homescreen.contentWindow.document.getElementById('test-container');
// Disable udpate timers which cause failure in b2g permisson prompt tests.
if (cm) {
cm.deleteCategoryEntry("update-timer", "WebappsUpdateTimer", false);
cm.deleteCategoryEntry("update-timer", "nsUpdateService", false);
}
var SECURITY_PREF = "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref(SECURITY_PREF, true);
// RIL DOM events and mozChromeEvents will be pending until
// this observer message is sent.
Services.obs.notifyObservers(null, 'system-message-listener-ready', null);
function openWindow(aEvent) {
var popupIframe = aEvent.detail.frameElement;
popupIframe.id = 'popupiframe';
// This is to size the iframe to what is requested in the window.open call,
// e.g. window.open("", "", "width=600,height=600");
if (aEvent.detail.features.indexOf('width') != -1) {
let width = aEvent.detail.features.substr(aEvent.detail.features.indexOf('width')+6);
width = width.substr(0,width.indexOf(',') == -1 ? width.length : width.indexOf(','));
popupIframe.setAttribute('width', width);
}
if (aEvent.detail.features.indexOf('height') != -1) {
let height = aEvent.detail.features.substr(aEvent.detail.features.indexOf('height')+7);
height = height.substr(0, height.indexOf(',') == -1 ? height.length : height.indexOf(','));
popupIframe.setAttribute('height', height);
}
popupIframe.addEventListener('mozbrowserclose', function(e) {
container.parentNode.removeChild(popupIframe);
container.focus();
});
// yes, the popup can call window.open too!
popupIframe.addEventListener('mozbrowseropenwindow', openWindow);
popupIframe.addEventListener('mozbrowserloadstart', function(e) {
popupIframe.focus();
let mm = popupIframe.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
mm.loadFrameScript(CHILD_LOGGER_SCRIPT, true);
mm.loadFrameScript(CHILD_SCRIPT_API, true);
mm.loadFrameScript(CHILD_SCRIPT, true);
mm.loadFrameScript('data:,attachSpecialPowersToWindow(content);', true);
});
container.parentNode.appendChild(popupIframe);
}
container.addEventListener('mozbrowseropenwindow', openWindow);
container.addEventListener('mozbrowsershowmodalprompt', function (e) {
if (e.detail.message == 'setVisible::false') {
container.setVisible(false);
}
else if (e.detail.message == 'setVisible::true') {
container.setVisible(true);
}
});
function StartTest() {
if (outOfProcess) {
let mm = container.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
//Workaround for bug 848411, once that bug is fixed, the following line can be removed
function contentScript() {
addEventListener("DOMWindowCreated", function listener(e) {
removeEventListener("DOMWindowCreated", listener, false);
var window = e.target.defaultView;
window.wrappedJSObject.SpecialPowers.addPermission("allowXULXBL", true, window.document);
});
}
mm.loadFrameScript("data:,(" + encodeURI(contentScript.toSource()) + ")();", true);
}
if (chrome) {
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
if (typeof(SpecialPowers) == 'undefined') {
loader.loadSubScript("chrome://specialpowers/content/specialpowersAPI.js");
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js");
loader.loadSubScript("chrome://specialpowers/content/ChromePowers.js");
}
loader.loadSubScript("chrome://mochikit/content/browser-test.js");
b2gStart();
}
if (onDevice) {
var cpuLock = Components.classes["@mozilla.org/power/powermanagerservice;1"]
.getService(Ci.nsIPowerManagerService)
.newWakeLock("cpu");
let manager = navigator.mozWifiManager;
let con = manager.connection;
manager.setPowerSavingMode(false);
manager.onenabled = function () {
if(wifiSettings) {
var req = manager.getKnownNetworks();
req.onsuccess = function () {
var networks = req.result;
for (var i = 0; i < networks.length; ++i){
var network = networks[i];
if(network.ssid == wifiSettings.ssid) {
manager.forget(network);
}
}
manager.associate(new window.MozWifiNetwork(wifiSettings));
};
}
};
manager.onstatuschange = function (event) {
prefs.setIntPref("network.proxy.type", 2);
if (event.status == 'connected') {
container.src = mochitestUrl;
}
};
if(wifiSettings) {
var req = settings.createLock().set({
'wifi.enabled': false,
'wifi.suspended': false
});
req.onsuccess = function () {
dump("----------------------enabling wifi------------------\n");
var req1 = settings.createLock().set({
'wifi.enabled': true,
'wifi.suspended': false});
};
}
} else {
if (!chrome) {
container.src = mochitestUrl;
}
}
}
// Prevent display off during testing.
navigator.mozPower.screenEnabled = true;
var settingLock = navigator.mozSettings.createLock();
var settingResult = settingLock.set({
'screen.timeout': 0
});
settingResult.onsuccess = function () {
dump("Set screen.time to 0\n");
StartTest();
}
settingResult.onerror = function () {
dump("Change screen.time failed\n");
StartTest();
}

Просмотреть файл

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = buildapp == 'b2g'
[test_TestsRunningAfterSimpleTestFinish.html]
skip-if = true #depends on fix for bug 1048446
[test_add_task.html]
@ -35,14 +34,14 @@ support-files = SpecialPowersLoadChromeScript.js
[test_SpecialPowersLoadPrivilegedScript.html]
[test_bug649012.html]
[test_bug816847.html]
skip-if = true || toolkit == 'android' || buildapp == 'b2g' || buildapp == 'mulet' || e10s #No test app installed ### Bug 1255339: blacklist because no more mozApps
skip-if = true || toolkit == 'android' || e10s # No test app installed
[test_sanity_cleanup.html]
[test_sanity_cleanup2.html]
[test_sanityEventUtils.html]
skip-if = buildapp == 'mulet' || toolkit == 'android' #bug 688052
skip-if = toolkit == 'android' # bug 688052
[test_sanitySimpletest.html]
subsuite = clipboard
skip-if = toolkit == 'android' #bug 688052
skip-if = toolkit == 'android' # bug 688052
[test_sanity_manifest.html]
skip-if = toolkit == 'android' # we use the old manifest style on android
fail-if = true

Просмотреть файл

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = buildapp == 'b2g'
support-files =
SimpleTest/test.css
test_Base.js

Просмотреть файл

@ -307,7 +307,7 @@ SimpleTest.todo = function(condition, name, diag) {
* Returns the absolute URL to a test data file from where tests
* are served. i.e. the file doesn't necessarely exists where tests
* are executed.
* (For b2g and android, mochitest are executed on the device, while
* (For android, mochitest are executed on the device, while
* all mochitest html (and others) files are served from the test runner
* slave)
*/
@ -1625,7 +1625,7 @@ function getAndroidSdk() {
gAndroidSdk = -1;
} else {
// See nsSystemInfo.cpp, the getProperty('version') returns different value
// on each platforms, so we need to distinguish the android and B2G platform.
// on each platforms, so we need to distinguish the android platform.
var versionString = nav.userAgent.indexOf("Android") != -1 ?
'version' : 'sdk_version';
gAndroidSdk = SpecialPowers.Cc['@mozilla.org/system-info;1']

Просмотреть файл

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
mochitest_profile_files = [
'prefs_b2g_unittest.js',
'prefs_general.js',
'webapps_mochitest.json',
]

Просмотреть файл

@ -1,12 +0,0 @@
// Prefs specific to b2g mochitests
user_pref("b2g.system_manifest_url","app://test-container.gaiamobile.org/manifest.webapp");
user_pref("b2g.system_startup_url","app://test-container.gaiamobile.org/index.html");
user_pref("dom.ipc.browser_frames.oop_by_default", false);
user_pref("dom.ipc.tabs.disabled", false);
user_pref("dom.ipc.tabs.shutdownTimeoutSecs", 0);
user_pref("dom.mozBrowserFramesEnabled", "%(OOP)s");
user_pref("dom.mozBrowserFramesWhitelist","app://test-container.gaiamobile.org,http://mochi.test:8888");
user_pref("dom.testing.datastore_enabled_for_hosted_apps", true);
user_pref('identity.fxaccounts.skipDeviceRegistration', true);
user_pref("marionette.force-local", true);