Bug 867548 - Disable updates when launching emulator, r=ahal
authorJonathan Griffin <jgriffin@mozilla.com>
Thu, 02 May 2013 16:16:44 -0700
changeset 141636 f9a5c9ba7d7adf6a282615c49a3571450c54b18e
parent 141635 d846f95bc7616e8309239ccdc951c03ac799fce1
child 141637 0875726579b21a321215d363ce44b8437fa96192
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs867548
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 867548 - Disable updates when launching emulator, r=ahal
testing/marionette/client/marionette/emulator.py
--- a/testing/marionette/client/marionette/emulator.py
+++ b/testing/marionette/client/marionette/emulator.py
@@ -38,16 +38,19 @@ class LogcatProc(ProcessHandlerMixin):
         f.write(line + "\n")
         f.flush()
 
 
 class Emulator(object):
 
     deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
     _default_res = '320x480'
+    prefs = {'app.update.enabled': False,
+             'app.update.staging.enabled': False,
+             'app.update.service.enabled': False}
 
     def __init__(self, homedir=None, noWindow=False, logcat_dir=None,
                  arch="x86", emulatorBinary=None, res=None, sdcard=None,
                  userdata=None):
         self.port = None
         self.dm = None
         self._emulator_launched = False
         self.proc = None
@@ -343,16 +346,37 @@ waitFor(
     def setup(self, marionette, gecko_path=None, busybox=None):
         if busybox:
             self.install_busybox(busybox)
 
         if gecko_path:
             self.install_gecko(gecko_path, marionette)
 
         self.wait_for_system_message(marionette)
+        self.set_prefs(marionette)
+
+    def set_prefs(self, marionette):
+        marionette.start_session()
+        marionette.set_context(marionette.CONTEXT_CHROME)
+        for pref in self.prefs:
+            marionette.execute_script("""
+            Components.utils.import("resource://gre/modules/Services.jsm");
+            let argtype = typeof(arguments[1]);
+            switch(argtype) {
+                case 'boolean':
+                    Services.prefs.setBoolPref(arguments[0], arguments[1]);
+                    break;
+                case 'number':
+                    Services.prefs.setIntPref(arguments[0], arguments[1]);
+                    break;
+                default:
+                    Services.prefs.setCharPref(arguments[0], arguments[1]);
+            }
+            """, [pref, self.prefs[pref]])
+        marionette.delete_session()
 
     def restart_b2g(self):
         print 'restarting B2G'
         self.dm.shellCheckOutput(['stop', 'b2g'])
         time.sleep(10)
         self.dm.shellCheckOutput(['start', 'b2g'])
 
         if not self.wait_for_port():