michael@0: from marionette_test import * michael@0: michael@0: michael@0: class SMSTest(MarionetteTestCase): michael@0: michael@0: @unittest.expectedFailure michael@0: def test_sms_between_emulators(self): michael@0: # Tests always have one emulator available as self.marionette; we'll michael@0: # use this for the receiving emulator. We'll also launch a second michael@0: # emulator to use as the sender. michael@0: sender = self.get_new_emulator() michael@0: receiver = self.marionette michael@0: michael@0: self.set_up_test_page(sender, "test.html", ["sms"]) michael@0: self.set_up_test_page(receiver, "test.html", ["sms"]) michael@0: michael@0: # Setup the event listsener on the receiver, which should store michael@0: # a global variable when an SMS is received. michael@0: message = 'hello world!' michael@0: self.assertTrue(receiver.execute_script("return window.navigator.mozMobileMessage != null;")) michael@0: receiver.execute_script(""" michael@0: global.smsreceived = null; michael@0: window.navigator.mozMobileMessage.addEventListener("received", function(e) { michael@0: global.smsreceived = e.message.body; michael@0: }); michael@0: """, new_sandbox=False) michael@0: michael@0: # Send the SMS from the sender. michael@0: sender.execute_script(""" michael@0: window.navigator.mozMobileMessage.send("%d", "%s"); michael@0: """ % (receiver.emulator.port, message)) michael@0: michael@0: # On the receiver, wait up to 10s for an SMS to be received, by michael@0: # checking the value of the global var that the listener will change. michael@0: receiver.set_script_timeout(0) # TODO no timeout for now since the test fails michael@0: received = receiver.execute_async_script(""" michael@0: waitFor(function () { michael@0: marionetteScriptFinished(global.smsreceived); michael@0: }, function () { michael@0: return global.smsreceived michael@0: }); michael@0: """, new_sandbox=False) michael@0: self.assertEqual(received, message)