Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | MARIONETTE_TIMEOUT = 60000; |
michael@0 | 5 | |
michael@0 | 6 | SpecialPowers.setBoolPref("dom.sms.enabled", true); |
michael@0 | 7 | SpecialPowers.addPermission("sms", true, document); |
michael@0 | 8 | |
michael@0 | 9 | const SENDER = "5555552368"; // the remote number |
michael@0 | 10 | const RECEIVER = "15555215554"; // the emulator's number |
michael@0 | 11 | |
michael@0 | 12 | let manager = window.navigator.mozMobileMessage; |
michael@0 | 13 | ok(manager instanceof MozMobileMessageManager, |
michael@0 | 14 | "manager is instance of " + manager.constructor); |
michael@0 | 15 | |
michael@0 | 16 | let body = "Hello SMS world!"; |
michael@0 | 17 | |
michael@0 | 18 | let completed = false; |
michael@0 | 19 | runEmulatorCmd("sms send " + SENDER + " " + body, function(result) { |
michael@0 | 20 | log("Sent fake SMS: " + result); |
michael@0 | 21 | is(result[0], "OK", "Emulator command result"); |
michael@0 | 22 | completed = true; |
michael@0 | 23 | }); |
michael@0 | 24 | |
michael@0 | 25 | manager.onreceived = function onreceived(event) { |
michael@0 | 26 | log("Received an SMS!"); |
michael@0 | 27 | |
michael@0 | 28 | let message = event.message; |
michael@0 | 29 | ok(message instanceof MozSmsMessage, "Message is instanceof MozSmsMessage"); |
michael@0 | 30 | |
michael@0 | 31 | ok(message.threadId, "thread id"); |
michael@0 | 32 | is(message.delivery, "received", "Message delivery"); |
michael@0 | 33 | is(message.deliveryStatus, "success", "Delivery status"); |
michael@0 | 34 | is(message.sender, SENDER, "Message sender"); |
michael@0 | 35 | is(message.receiver, RECEIVER, "Message receiver"); |
michael@0 | 36 | is(message.body, body, "Message body"); |
michael@0 | 37 | is(message.messageClass, "normal", "Message class"); |
michael@0 | 38 | is(message.deliveryTimestamp, 0, "deliveryTimestamp is 0"); |
michael@0 | 39 | |
michael@0 | 40 | cleanUp(); |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | function cleanUp() { |
michael@0 | 44 | if (!completed) { |
michael@0 | 45 | window.setTimeout(cleanUp, 100); |
michael@0 | 46 | return; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | SpecialPowers.removePermission("sms", document); |
michael@0 | 50 | finish(); |
michael@0 | 51 | } |