Bug 903034 - Fix b2g desktop mochitest regression, r=jgriffin
This commit is contained in:
@@ -32,6 +32,7 @@ function openWindow(aEvent) {
|
|||||||
}
|
}
|
||||||
container.addEventListener('mozbrowseropenwindow', openWindow);
|
container.addEventListener('mozbrowseropenwindow', openWindow);
|
||||||
|
|
||||||
|
if (outOfProcess) {
|
||||||
let specialpowers = {};
|
let specialpowers = {};
|
||||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||||
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js", specialpowers);
|
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js", specialpowers);
|
||||||
@@ -50,5 +51,6 @@ mm.loadFrameScript(CHILD_LOGGER_SCRIPT, true);
|
|||||||
mm.loadFrameScript(CHILD_SCRIPT_API, true);
|
mm.loadFrameScript(CHILD_SCRIPT_API, true);
|
||||||
mm.loadFrameScript(CHILD_SCRIPT, true);
|
mm.loadFrameScript(CHILD_SCRIPT, true);
|
||||||
specialPowersObserver._isFrameScriptLoaded = true;
|
specialPowersObserver._isFrameScriptLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
container.src = mochitestUrl;
|
container.src = mochitestUrl;
|
||||||
|
|||||||
@@ -321,13 +321,6 @@ class MochitestOptions(optparse.OptionParser):
|
|||||||
"metavar": "PREF=VALUE",
|
"metavar": "PREF=VALUE",
|
||||||
"help": "defines an extra user preference",
|
"help": "defines an extra user preference",
|
||||||
}],
|
}],
|
||||||
[["--build-info-json"],
|
|
||||||
{ "action": "store",
|
|
||||||
"type": "string",
|
|
||||||
"default": None,
|
|
||||||
"dest": "mozInfo",
|
|
||||||
"help": "path to mozinfo.json to determine build time options",
|
|
||||||
}],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, automation=None, **kwargs):
|
def __init__(self, automation=None, **kwargs):
|
||||||
@@ -466,15 +459,6 @@ class MochitestOptions(optparse.OptionParser):
|
|||||||
if not options.repeat:
|
if not options.repeat:
|
||||||
options.repeat = 29
|
options.repeat = 29
|
||||||
|
|
||||||
if not options.mozInfo:
|
|
||||||
if build_obj:
|
|
||||||
options.mozInfo = os.path.join(build_obj.topobjdir, 'mozinfo.json')
|
|
||||||
else:
|
|
||||||
options.mozInfo = os.path.abspath('mozinfo.json')
|
|
||||||
|
|
||||||
if not os.path.isfile(options.mozInfo):
|
|
||||||
self.error("Unable to file build information file (mozinfo.json) at this location: %s" % options.mozInfo)
|
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,15 @@ class MochitestUtilsMixin(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
os.chdir(SCRIPT_DIR)
|
os.chdir(SCRIPT_DIR)
|
||||||
mozinfo.find_and_update_from_json(SCRIPT_DIR)
|
path = SCRIPT_DIR
|
||||||
|
dirs = []
|
||||||
|
while path != os.path.expanduser('~'):
|
||||||
|
if path in dirs:
|
||||||
|
break
|
||||||
|
dirs.append(path)
|
||||||
|
path = os.path.split(path)[0]
|
||||||
|
|
||||||
|
mozinfo.find_and_update_from_json(*dirs)
|
||||||
|
|
||||||
def getFullPath(self, path):
|
def getFullPath(self, path):
|
||||||
" Get an absolute path relative to self.oldcwd."
|
" Get an absolute path relative to self.oldcwd."
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ except ImportError:
|
|||||||
here = os.path.abspath(os.path.dirname(sys.argv[0]))
|
here = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||||
sys.path.insert(0, here)
|
sys.path.insert(0, here)
|
||||||
|
|
||||||
|
from b2gautomation import B2GDesktopAutomation
|
||||||
|
from runtests import Mochitest
|
||||||
from runtests import MochitestUtilsMixin
|
from runtests import MochitestUtilsMixin
|
||||||
from runtests import MochitestOptions
|
from runtests import MochitestOptions
|
||||||
from runtests import MochitestServer
|
from runtests import MochitestServer
|
||||||
@@ -26,7 +28,7 @@ from mochitest_options import B2GOptions, MochitestOptions
|
|||||||
from marionette import Marionette
|
from marionette import Marionette
|
||||||
|
|
||||||
from mozdevice import DeviceManagerADB
|
from mozdevice import DeviceManagerADB
|
||||||
from mozprofile import Profile, Preferences, DEFAULT_PORTS
|
from mozprofile import Profile, Preferences
|
||||||
from mozrunner import B2GRunner
|
from mozrunner import B2GRunner
|
||||||
import mozlog
|
import mozlog
|
||||||
import mozinfo
|
import mozinfo
|
||||||
@@ -221,16 +223,23 @@ class B2GDeviceMochitest(B2GMochitest):
|
|||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
|
||||||
class B2GDesktopMochitest(B2GMochitest):
|
class B2GDesktopMochitest(B2GMochitest, Mochitest):
|
||||||
|
|
||||||
def __init__(self, marionette, profile_data_dir):
|
def __init__(self, automation, marionette, profile_data_dir):
|
||||||
B2GMochitest.__init__(self, out_of_process=False, profile_data_dir=profile_data_dir)
|
B2GMochitest.__init__(self, marionette, out_of_process=False, profile_data_dir=profile_data_dir)
|
||||||
|
Mochitest.__init__(self, automation)
|
||||||
|
|
||||||
def runMarionetteScript(self, marionette, test_script):
|
def runMarionetteScript(self, marionette, test_script, test_script_args):
|
||||||
assert(marionette.wait_for_port())
|
assert(marionette.wait_for_port())
|
||||||
marionette.start_session()
|
marionette.start_session()
|
||||||
marionette.set_context(marionette.CONTEXT_CHROME)
|
marionette.set_context(marionette.CONTEXT_CHROME)
|
||||||
marionette.execute_script(test_script)
|
|
||||||
|
if os.path.isfile(test_script):
|
||||||
|
f = open(test_script, 'r')
|
||||||
|
test_script = f.read()
|
||||||
|
f.close()
|
||||||
|
self.marionette.execute_script(test_script,
|
||||||
|
script_args=test_script_args)
|
||||||
|
|
||||||
def startTests(self):
|
def startTests(self):
|
||||||
# This is run in a separate thread because otherwise, the app's
|
# This is run in a separate thread because otherwise, the app's
|
||||||
@@ -238,7 +247,8 @@ class B2GDesktopMochitest(B2GMochitest):
|
|||||||
# function returns, by waitForFinish), which causes the app to hang.
|
# function returns, by waitForFinish), which causes the app to hang.
|
||||||
thread = threading.Thread(target=self.runMarionetteScript,
|
thread = threading.Thread(target=self.runMarionetteScript,
|
||||||
args=(self.marionette,
|
args=(self.marionette,
|
||||||
self.test_script))
|
self.test_script,
|
||||||
|
self.test_script_args))
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
def buildURLOptions(self, options, env):
|
def buildURLOptions(self, options, env):
|
||||||
@@ -258,6 +268,9 @@ class B2GDesktopMochitest(B2GMochitest):
|
|||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
def buildProfile(self, options):
|
||||||
|
return self.build_profile(options)
|
||||||
|
|
||||||
|
|
||||||
def run_remote_mochitests(parser, options):
|
def run_remote_mochitests(parser, options):
|
||||||
# create our Marionette instance
|
# create our Marionette instance
|
||||||
@@ -324,6 +337,8 @@ def run_remote_mochitests(parser, options):
|
|||||||
sys.exit(retVal)
|
sys.exit(retVal)
|
||||||
|
|
||||||
def run_desktop_mochitests(parser, options):
|
def run_desktop_mochitests(parser, options):
|
||||||
|
automation = B2GDesktopAutomation()
|
||||||
|
|
||||||
# create our Marionette instance
|
# create our Marionette instance
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if options.marionette:
|
if options.marionette:
|
||||||
@@ -331,8 +346,9 @@ def run_desktop_mochitests(parser, options):
|
|||||||
kwargs['host'] = host
|
kwargs['host'] = host
|
||||||
kwargs['port'] = int(port)
|
kwargs['port'] = int(port)
|
||||||
marionette = Marionette.getMarionetteOrExit(**kwargs)
|
marionette = Marionette.getMarionetteOrExit(**kwargs)
|
||||||
|
automation.marionette = marionette
|
||||||
|
|
||||||
mochitest = B2GDesktopMochitest(marionette, options.profile_data_dir)
|
mochitest = B2GDesktopMochitest(automation, marionette, options.profile_data_dir)
|
||||||
|
|
||||||
# b2g desktop builds don't always have a b2g-bin file
|
# b2g desktop builds don't always have a b2g-bin file
|
||||||
if options.app[-4:] == '-bin':
|
if options.app[-4:] == '-bin':
|
||||||
@@ -345,6 +361,10 @@ def run_desktop_mochitests(parser, options):
|
|||||||
if options.desktop and not options.profile:
|
if options.desktop and not options.profile:
|
||||||
raise Exception("must specify --profile when specifying --desktop")
|
raise Exception("must specify --profile when specifying --desktop")
|
||||||
|
|
||||||
|
automation.setServerInfo(options.webServer,
|
||||||
|
options.httpPort,
|
||||||
|
options.sslPort,
|
||||||
|
options.webSocketPort)
|
||||||
sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
|
sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user