2012-05-30 04:41:44 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
MARIONETTE_TIMEOUT = 10000;
|
|
|
|
|
2012-08-22 21:30:40 +04:00
|
|
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
|
|
|
SpecialPowers.addPermission("sms", true, document);
|
2012-05-30 04:41:44 +04:00
|
|
|
|
2013-03-07 20:12:56 +04:00
|
|
|
const SENDER = "5555552368"; // the remote number
|
|
|
|
const RECEIVER = "15555215554"; // the emulator's number
|
2013-01-23 13:40:48 +04:00
|
|
|
|
2012-05-30 04:41:44 +04:00
|
|
|
let sms = window.navigator.mozSms;
|
|
|
|
let body = "Hello SMS world!";
|
|
|
|
|
|
|
|
let completed = false;
|
2013-03-07 20:12:56 +04:00
|
|
|
runEmulatorCmd("sms send " + SENDER + " " + body, function(result) {
|
2012-05-30 04:41:44 +04:00
|
|
|
log("Sent fake SMS: " + result);
|
2013-03-26 00:38:18 +04:00
|
|
|
is(result[0], "OK", "Emulator command result");
|
2012-05-30 04:41:44 +04:00
|
|
|
completed = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
sms.onreceived = function onreceived(event) {
|
|
|
|
log("Received an SMS!");
|
|
|
|
|
|
|
|
let message = event.message;
|
2013-03-26 00:38:18 +04:00
|
|
|
ok(message instanceof MozSmsMessage, "Message is instanceof MozSmsMessage");
|
|
|
|
|
2013-04-05 16:16:01 +04:00
|
|
|
ok(message.threadId, "thread id");
|
2013-03-26 00:38:18 +04:00
|
|
|
is(message.delivery, "received", "Message delivery");
|
|
|
|
is(message.deliveryStatus, "success", "Delivery status");
|
|
|
|
is(message.sender, SENDER, "Message sender");
|
|
|
|
is(message.receiver, RECEIVER, "Message receiver");
|
|
|
|
is(message.body, body, "Message body");
|
|
|
|
is(message.messageClass, "normal", "Message class");
|
|
|
|
ok(message.timestamp instanceof Date, "Message timestamp is a date");
|
2012-05-30 04:41:44 +04:00
|
|
|
|
|
|
|
cleanUp();
|
|
|
|
};
|
|
|
|
|
|
|
|
function cleanUp() {
|
|
|
|
if (!completed) {
|
|
|
|
window.setTimeout(cleanUp, 100);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 21:30:40 +04:00
|
|
|
SpecialPowers.removePermission("sms", document);
|
2012-05-30 04:41:44 +04:00
|
|
|
finish();
|
|
|
|
}
|