Bug 782655 - Enable remote xul for B2G reftests, r=jgriffin

This commit is contained in:
Andrew Halberstadt 2012-08-15 15:26:31 -04:00
parent fb8f81c5e4
commit d6f030c237
3 changed files with 26 additions and 7 deletions

View File

@ -43,6 +43,8 @@ class B2GRemoteAutomation(Automation):
self.marionette = marionette
self.context_chrome = context_chrome
self._is_emulator = False
self.test_script = None
self.test_script_args = None
# Default our product to b2g
self._product = "b2g"
@ -254,14 +256,14 @@ class B2GRemoteAutomation(Automation):
# provided by B2G's shell.js.
self.marionette.execute_script("document.getElementById('homescreen').src='%s';" % self.testURL)
# run the script that starts the tests
elif hasattr(self, 'testScript'):
if os.path.isfile(self.testScript):
script = open(self.testScript, 'r')
self.marionette.execute_script(script.read())
elif self.test_script:
if os.path.isfile(self.test_script):
script = open(self.test_script, 'r')
self.marionette.execute_script(script.read(), script_args=self.test_script_args)
script.close()
else:
# assume testScript is a string
self.marionette.execute_script(self.testScript)
# assume test_script is a string
self.marionette.execute_script(self.test_script, script_args=self.test_script_args)
else:
# assumes the tests are started on startup automatically
pass

View File

@ -1,3 +1,5 @@
args = __marionetteParams;
function setDefaultPrefs() {
// This code sets the preferences for extension-based reftest; for
// command-line based reftest they are set in function handler_handle in
@ -21,10 +23,24 @@ function setDefaultPrefs() {
branch.setBoolPref("app.update.enabled", false);
}
function setPermissions(webserver, port) {
var perms = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = ioService.newURI("http://" + webserver + ":" + port, null, null);
perms.add(uri, "allowXULXBL", Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
}
// Load into any existing windows
let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
let win = wm.getMostRecentWindow('');
// Set preferences and permissions
setDefaultPrefs();
setPermissions(args[0], args[1]);
// Start the reftests
Components.utils.import("chrome://reftest/content/reftest.jsm");
OnRefTestLoad(win);

View File

@ -460,7 +460,8 @@ def main(args=sys.argv[1:]):
return 1
auto.setProduct("b2g")
auto.testScript = os.path.join(SCRIPT_DIRECTORY, 'b2g_start_script.js')
auto.test_script = os.path.join(SCRIPT_DIRECTORY, 'b2g_start_script.js')
auto.test_script_args = [options.remoteWebServer, options.httpPort]
auto.logFinish = "REFTEST TEST-START | Shutdown"
reftest = B2GReftest(auto, dm, options, SCRIPT_DIRECTORY)