Bug 803253 - Only wait for system-message-listener-ready on emulator startup, r=mdas, DONTBUILD(NPOTB)

This commit is contained in:
Jonathan Griffin 2012-10-18 13:19:21 -07:00
parent e7ef921ac9
commit 4ca039d2ec
2 changed files with 26 additions and 10 deletions

View File

@ -134,6 +134,32 @@ class Marionette(object):
self.client = MarionetteClient(self.host, self.port)
if emulator:
# When launching an emulator, telephony API's are not
# available immediately. They start working after the
# system-message-listener-ready event is observed. See
# bug 792647. This code causes us to wait for this event
# after launching an emulator, before allowing any tests
# to run.
self.start_session()
self.set_context(self.CONTEXT_CHROME)
self.set_script_timeout(30000)
try:
self.execute_async_script("""
waitFor(
function() { marionetteScriptFinished(true); },
function() { return isSystemMessageListenerReady(); }
);
""")
except ScriptTimeoutException:
# We silently ignore the timeout if it occurs, since
# isSystemMessageListenerReady() isn't available on
# older emulators. 30s *should* be enough of a delay
# to allow telephony API's to work.
pass
self.set_context(self.CONTEXT_CONTENT)
self.delete_session()
def __del__(self):
if self.emulator:
self.emulator.close()

View File

@ -160,16 +160,6 @@ class MarionetteJSTestCase(CommonTestCase):
self.marionette.start_session()
self.marionette.execute_script("log('TEST-START: %s');" % self.jsFile.replace('\\', '\\\\'))
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
self.marionette.set_script_timeout(30000)
self.marionette.execute_async_script("""
waitFor(
function() { marionetteScriptFinished(true); },
function() { return isSystemMessageListenerReady(); }
);
""")
self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
f = open(self.jsFile, 'r')
js = f.read()
args = []