dom/mobilemessage/tests/marionette/test_between_emulators.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 from marionette_test import *
michael@0 2
michael@0 3
michael@0 4 class SMSTest(MarionetteTestCase):
michael@0 5
michael@0 6 @unittest.expectedFailure
michael@0 7 def test_sms_between_emulators(self):
michael@0 8 # Tests always have one emulator available as self.marionette; we'll
michael@0 9 # use this for the receiving emulator. We'll also launch a second
michael@0 10 # emulator to use as the sender.
michael@0 11 sender = self.get_new_emulator()
michael@0 12 receiver = self.marionette
michael@0 13
michael@0 14 self.set_up_test_page(sender, "test.html", ["sms"])
michael@0 15 self.set_up_test_page(receiver, "test.html", ["sms"])
michael@0 16
michael@0 17 # Setup the event listsener on the receiver, which should store
michael@0 18 # a global variable when an SMS is received.
michael@0 19 message = 'hello world!'
michael@0 20 self.assertTrue(receiver.execute_script("return window.navigator.mozMobileMessage != null;"))
michael@0 21 receiver.execute_script("""
michael@0 22 global.smsreceived = null;
michael@0 23 window.navigator.mozMobileMessage.addEventListener("received", function(e) {
michael@0 24 global.smsreceived = e.message.body;
michael@0 25 });
michael@0 26 """, new_sandbox=False)
michael@0 27
michael@0 28 # Send the SMS from the sender.
michael@0 29 sender.execute_script("""
michael@0 30 window.navigator.mozMobileMessage.send("%d", "%s");
michael@0 31 """ % (receiver.emulator.port, message))
michael@0 32
michael@0 33 # On the receiver, wait up to 10s for an SMS to be received, by
michael@0 34 # checking the value of the global var that the listener will change.
michael@0 35 receiver.set_script_timeout(0) # TODO no timeout for now since the test fails
michael@0 36 received = receiver.execute_async_script("""
michael@0 37 waitFor(function () {
michael@0 38 marionetteScriptFinished(global.smsreceived);
michael@0 39 }, function () {
michael@0 40 return global.smsreceived
michael@0 41 });
michael@0 42 """, new_sandbox=False)
michael@0 43 self.assertEqual(received, message)

mercurial