Bug 793213 - Disable offline mode for b2g mochitest/reftest, r=ahal, DONTBUILD because NPOTB
authorJonathan Griffin <jgriffin@mozilla.com>
Fri, 21 Sep 2012 15:20:39 -0700
changeset 107802 034411ee68589403a36d00eb8135a99475523b4c
parent 107801 f0c89cebf913c81b0d7a96abea7ba3ddabed6821
child 107803 b061c2316d0ce367d4a1aa05159146431c4d9edc
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersahal, DONTBUILD
bugs793213
milestone18.0a1
Bug 793213 - Disable offline mode for b2g mochitest/reftest, r=ahal, DONTBUILD because NPOTB
build/mobile/b2gautomation.py
--- a/build/mobile/b2gautomation.py
+++ b/build/mobile/b2gautomation.py
@@ -241,17 +241,31 @@ class B2GRemoteAutomation(Automation):
         else:
             time.sleep(5)
 
         # start a marionette session
         session = self.marionette.start_session()
         if 'b2g' not in session:
             raise Exception("bad session value %s returned by start_session" % session)
 
-        if self.context_chrome:
+        if self._is_emulator:
+            # 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.set_context(self.marionette.CONTEXT_CHROME)
+            self.marionette.execute_script("""
+                Components.utils.import("resource://gre/modules/Services.jsm");
+                Services.io.manageOfflineStatus = false;
+                Services.io.offline = false;
+                """)
+
+            if not self.context_chrome:
+                self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
+
+        elif self.context_chrome:
             self.marionette.set_context(self.marionette.CONTEXT_CHROME)
 
         # start the tests
         if hasattr(self, 'testURL'):
             # Start the tests by navigating to the mochitest url, by setting it
             # as the 'src' attribute to the homescreen mozbrowser element
             # provided by B2G's shell.js.
             self.marionette.execute_script("document.getElementById('homescreen').src='%s';" % self.testURL)