mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 887159 - B2G SMS: Handle message delivered timestamp for delivery report (part 2, implementation and tests). r=vicamo
This commit is contained in:
parent
d33063f9a5
commit
e69ea19f62
@ -14,7 +14,7 @@ interface nsIDOMMozSmsSegmentInfo;
|
||||
#define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(2a231e8d-761d-47a9-8928-93de7b0cbaac)]
|
||||
[scriptable, builtinclass, uuid(11b7bda8-414b-11e3-8781-1b737e7958ae)]
|
||||
interface nsIMobileMessageService : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
@ -27,6 +27,7 @@ interface nsIMobileMessageService : nsISupports
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in jsval timestamp,
|
||||
in jsval deliveryTimestamp,
|
||||
in bool read);
|
||||
|
||||
[implicit_jscontext]
|
||||
|
@ -38,6 +38,7 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
@ -51,6 +52,7 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
aBody,
|
||||
aMessageClass,
|
||||
aTimestamp,
|
||||
aDeliveryTimestamp,
|
||||
aRead,
|
||||
aCx,
|
||||
aMessage);
|
||||
|
@ -13,6 +13,43 @@ using namespace mozilla::dom::mobilemessage;
|
||||
|
||||
DOMCI_DATA(MozSmsMessage, mozilla::dom::SmsMessage)
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* A helper function to convert the JS value to an integer value for time.
|
||||
*
|
||||
* @params aCx
|
||||
* The JS context.
|
||||
* @params aTime
|
||||
* Can be an object or a number.
|
||||
* @params aReturn
|
||||
* The integer value to return.
|
||||
* @return NS_OK if the convertion succeeds.
|
||||
*/
|
||||
static nsresult
|
||||
convertTimeToInt(JSContext* aCx, const JS::Value& aTime, uint64_t& aReturn)
|
||||
{
|
||||
if (aTime.isObject()) {
|
||||
JS::Rooted<JSObject*> timestampObj(aCx, &aTime.toObject());
|
||||
if (!JS_ObjectIsDate(aCx, timestampObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
aReturn = js_DateGetMsecSinceEpoch(timestampObj);
|
||||
} else {
|
||||
if (!aTime.isNumber()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
double number = aTime.toNumber();
|
||||
if (static_cast<uint64_t>(number) != number) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
aReturn = static_cast<uint64_t>(number);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -34,9 +71,10 @@ SmsMessage::SmsMessage(int32_t aId,
|
||||
const nsString& aBody,
|
||||
MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead)
|
||||
: mData(aId, aThreadId, aDelivery, aDeliveryStatus, aSender, aReceiver, aBody,
|
||||
aMessageClass, aTimestamp, aRead)
|
||||
aMessageClass, aTimestamp, aDeliveryTimestamp, aRead)
|
||||
{
|
||||
}
|
||||
|
||||
@ -55,6 +93,7 @@ SmsMessage::Create(int32_t aId,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
@ -109,23 +148,13 @@ SmsMessage::Create(int32_t aId,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// We support both a Date object and a millisecond timestamp as a number.
|
||||
if (aTimestamp.isObject()) {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aTimestamp.toObject());
|
||||
if (!JS_ObjectIsDate(aCx, obj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
data.timestamp() = js_DateGetMsecSinceEpoch(obj);
|
||||
} else {
|
||||
if (!aTimestamp.isNumber()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
double number = aTimestamp.toNumber();
|
||||
if (static_cast<uint64_t>(number) != number) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
data.timestamp() = static_cast<uint64_t>(number);
|
||||
}
|
||||
// Set |timestamp|.
|
||||
nsresult rv = convertTimeToInt(aCx, aTimestamp, data.timestamp());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set |deliveryTimestamp|.
|
||||
rv = convertTimeToInt(aCx, aDeliveryTimestamp, data.deliveryTimestamp());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(data);
|
||||
message.swap(*aMessage);
|
||||
@ -265,6 +294,21 @@ SmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetDeliveryTimestamp(JSContext* aCx, JS::Value* aDate)
|
||||
{
|
||||
if (mData.deliveryTimestamp() == 0) {
|
||||
*aDate = JSVAL_NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject *obj = JS_NewDateObjectMsec(aCx, mData.deliveryTimestamp());
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
|
||||
|
||||
*aDate = OBJECT_TO_JSVAL(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetRead(bool* aRead)
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
const nsString& aBody,
|
||||
mobilemessage::MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead);
|
||||
SmsMessage(const mobilemessage::SmsMessageData& aData);
|
||||
|
||||
@ -42,6 +43,7 @@ public:
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const JS::Value& aTimestamp,
|
||||
const JS::Value& aDeliveryTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage);
|
||||
|
@ -24,7 +24,7 @@ const DISABLE_MMS_GROUPING_FOR_RECEIVING = true;
|
||||
|
||||
|
||||
const DB_NAME = "sms";
|
||||
const DB_VERSION = 14;
|
||||
const DB_VERSION = 15;
|
||||
const MESSAGE_STORE_NAME = "sms";
|
||||
const THREAD_STORE_NAME = "thread";
|
||||
const PARTICIPANT_STORE_NAME = "participant";
|
||||
@ -226,6 +226,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
self.upgradeSchema13(event.target.transaction, next);
|
||||
break;
|
||||
case 14:
|
||||
if (DEBUG) debug("Upgrade to version 15. Add deliveryTimestamp.");
|
||||
self.upgradeSchema14(event.target.transaction, next);
|
||||
break;
|
||||
case 15:
|
||||
// This will need to be moved for each new version
|
||||
if (DEBUG) debug("Upgrade finished.");
|
||||
break;
|
||||
@ -1018,6 +1022,33 @@ MobileMessageDatabaseService.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Add deliveryTimestamp.
|
||||
*/
|
||||
upgradeSchema14: function upgradeSchema14(transaction, next) {
|
||||
let messageStore = transaction.objectStore(MESSAGE_STORE_NAME);
|
||||
|
||||
messageStore.openCursor().onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
let messageRecord = cursor.value;
|
||||
if (messageRecord.type == "sms") {
|
||||
messageRecord.deliveryTimestamp = 0;
|
||||
} else if (messageRecord.type == "mms") {
|
||||
let deliveryInfo = messageRecord.deliveryInfo;
|
||||
for (let i = 0; i < deliveryInfo.length; i++) {
|
||||
deliveryInfo[i].deliveryTimestamp = 0;
|
||||
}
|
||||
}
|
||||
cursor.update(messageRecord);
|
||||
cursor.continue();
|
||||
};
|
||||
},
|
||||
|
||||
matchParsedPhoneNumbers: function matchParsedPhoneNumbers(addr1, parsedAddr1,
|
||||
addr2, parsedAddr2) {
|
||||
if ((parsedAddr1.internationalNumber &&
|
||||
@ -1080,6 +1111,7 @@ MobileMessageDatabaseService.prototype = {
|
||||
aMessageRecord.body,
|
||||
aMessageRecord.messageClass,
|
||||
aMessageRecord.timestamp,
|
||||
aMessageRecord.deliveryTimestamp,
|
||||
aMessageRecord.read);
|
||||
} else if (aMessageRecord.type == "mms") {
|
||||
let headers = aMessageRecord["headers"];
|
||||
@ -1498,6 +1530,12 @@ MobileMessageDatabaseService.prototype = {
|
||||
if (messageRecord.type == "sms") {
|
||||
if (messageRecord.deliveryStatus != deliveryStatus) {
|
||||
messageRecord.deliveryStatus = deliveryStatus;
|
||||
|
||||
// Update the delivery timestamp if it's successfully delivered.
|
||||
if (deliveryStatus == DELIVERY_STATUS_SUCCESS) {
|
||||
messageRecord.deliveryTimestamp = Date.now();
|
||||
}
|
||||
|
||||
isRecordUpdated = true;
|
||||
}
|
||||
} else if (messageRecord.type == "mms") {
|
||||
@ -1674,6 +1712,11 @@ MobileMessageDatabaseService.prototype = {
|
||||
if (aMessage.type == "sms") {
|
||||
aMessage.delivery = DELIVERY_RECEIVED;
|
||||
aMessage.deliveryStatus = DELIVERY_STATUS_SUCCESS;
|
||||
|
||||
// If |deliveryTimestamp| is not specified, use 0 as default.
|
||||
if (aMessage.deliveryTimestamp == undefined) {
|
||||
aMessage.deliveryTimestamp = 0;
|
||||
}
|
||||
}
|
||||
aMessage.deliveryIndex = [aMessage.delivery, timestamp];
|
||||
|
||||
@ -1699,6 +1742,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
: DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
if (aMessage.type == "sms") {
|
||||
aMessage.deliveryStatus = deliveryStatus;
|
||||
// If |deliveryTimestamp| is not specified, use 0 as default.
|
||||
if (aMessage.deliveryTimestamp == undefined) {
|
||||
aMessage.deliveryTimestamp = 0;
|
||||
}
|
||||
} else if (aMessage.type == "mms") {
|
||||
let receivers = aMessage.receivers
|
||||
if (!Array.isArray(receivers)) {
|
||||
|
@ -34,7 +34,8 @@ struct SmsMessageData
|
||||
nsString receiver;
|
||||
nsString body;
|
||||
MessageClass messageClass;
|
||||
uint64_t timestamp; // ms since epoch.
|
||||
uint64_t timestamp; // ms since epoch.
|
||||
uint64_t deliveryTimestamp; // ms since epoch.
|
||||
bool read;
|
||||
};
|
||||
|
||||
|
@ -79,6 +79,7 @@ function sendSms() {
|
||||
is(sentSms.messageClass, "normal", "messageClass");
|
||||
ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||
outSmsTimeStamp = sentSms.timestamp;
|
||||
ok(sentSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
|
||||
};
|
||||
|
@ -36,6 +36,7 @@ manager.onreceived = function onreceived(event) {
|
||||
is(message.body, body, "Message body");
|
||||
is(message.messageClass, "normal", "Message class");
|
||||
ok(message.timestamp instanceof Date, "Message timestamp is a date");
|
||||
ok(message.deliveryTimestamp === null, "Message deliveryTimestamp is null");
|
||||
|
||||
cleanUp();
|
||||
};
|
||||
|
@ -37,6 +37,7 @@ function simulateIncomingSms() {
|
||||
is(incomingSms.sender, SENDER, "sender");
|
||||
is(incomingSms.messageClass, "normal", "messageClass");
|
||||
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||
ok(incomingSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
verifySmsExists(incomingSms);
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ function simulateIncomingSms() {
|
||||
is(incomingSms.receiver, EMULATOR, "receiver");
|
||||
is(incomingSms.sender, REMOTE, "sender");
|
||||
ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||
ok(incomingSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
verifySmsExists(incomingSms);
|
||||
};
|
||||
|
@ -41,6 +41,7 @@ function simulateIncomingSms() {
|
||||
is(incomingSms.receiver, RECEIVER, "receiver");
|
||||
is(incomingSms.sender, SENDER, "sender");
|
||||
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||
ok(incomingSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
verifySmsExists(incomingSms);
|
||||
};
|
||||
|
@ -146,6 +146,7 @@ tasks.push(function init() {
|
||||
is(incomingSms.sender, SENDER, "sender");
|
||||
is(incomingSms.messageClass, "normal", "messageClass");
|
||||
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||
ok(incomingSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
verifySmsExists(incomingSms);
|
||||
};
|
||||
|
@ -49,8 +49,8 @@ function checkMessage(message, id, threadId, messageClass) {
|
||||
is(message.sender, "+1", "message.sender");
|
||||
is(message.body, "A", "message.body");
|
||||
is(message.messageClass, messageClass, "message.messageClass");
|
||||
ok(message.timestamp instanceof Date,
|
||||
"message.timestamp is instanceof " + message.timestamp.constructor);
|
||||
ok(message.timestamp instanceof Date, "timestamp is instanceof Date");
|
||||
ok(message.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
is(message.read, false, "message.read");
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,11 @@ function checkMessage(message, delivery, body) {
|
||||
ok(message.receiver, "message.receiver");
|
||||
is(message.body, body, "message.body");
|
||||
is(message.messageClass, "normal", "message.messageClass");
|
||||
ok(message.timestamp instanceof Date,
|
||||
"message.timestamp is instanceof " + message.timestamp.constructor);
|
||||
ok(message.timestamp instanceof Date, "timestamp is instanceof Date");
|
||||
|
||||
// TODO: bug 788928 - add test cases for deliverysuccess event.
|
||||
ok(message.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
is(message.read, true, "message.read");
|
||||
}
|
||||
|
||||
@ -116,7 +119,7 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
|
||||
|
||||
let message = event.message;
|
||||
checkMessage(message, "sending", body);
|
||||
// SMSC timestamp is in seconds.
|
||||
// timestamp is in seconds.
|
||||
ok(Math.floor(message.timestamp.getTime() / 1000) >= Math.floor(now / 1000),
|
||||
"sent timestamp is valid");
|
||||
|
||||
|
@ -43,6 +43,7 @@ function sendSms() {
|
||||
is(sentSms.sender, SENDER, "sender");
|
||||
is(sentSms.messageClass, "normal", "messageClass");
|
||||
ok(sentSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||
ok(sentSms.deliveryTimestamp === null, "deliveryTimestamp is null");
|
||||
|
||||
if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
|
||||
};
|
||||
|
@ -30,18 +30,19 @@ function run_test() {
|
||||
* Ensure an SmsMessage object created has sensible initial values.
|
||||
*/
|
||||
add_test(function test_interface() {
|
||||
let sms = newMessage(null, null, "sent", "pending", null, null, null,
|
||||
"normal", new Date(), true);
|
||||
let sms = newMessage(null, null, "sent", "success", null, null, null,
|
||||
"normal", new Date(), 0, true);
|
||||
do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
|
||||
do_check_eq(sms.id, 0);
|
||||
do_check_eq(sms.threadId, 0);
|
||||
do_check_eq(sms.delivery, "sent");
|
||||
do_check_eq(sms.deliveryStatus, "pending");
|
||||
do_check_eq(sms.deliveryStatus, "success");
|
||||
do_check_eq(sms.receiver, null);
|
||||
do_check_eq(sms.sender, null);
|
||||
do_check_eq(sms.body, null);
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_true(sms.timestamp instanceof Date);
|
||||
do_check_true(sms.deliveryTimestamp === null);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -51,7 +52,7 @@ add_test(function test_interface() {
|
||||
*/
|
||||
add_test(function test_readonly_attributes() {
|
||||
let sms = newMessage(null, null, "received", "success", null, null, null,
|
||||
"normal", new Date(), true);
|
||||
"normal", new Date(), 0, true);
|
||||
|
||||
sms.id = 1;
|
||||
do_check_eq(sms.id, 0);
|
||||
@ -77,9 +78,13 @@ add_test(function test_readonly_attributes() {
|
||||
sms.messageClass = "class-0";
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
|
||||
let oldTimestamp = sms.timestamp.getTime();
|
||||
let oldTimestamp = sms.timestamp;
|
||||
sms.timestamp = new Date();
|
||||
do_check_eq(sms.timestamp.getTime(), oldTimestamp);
|
||||
do_check_eq(sms.timestamp.getTime(), oldTimestamp.getTime());
|
||||
|
||||
let oldDeliveryTimestamp = sms.deliveryTimestamp;
|
||||
sms.deliveryTimestamp = new Date();
|
||||
do_check_eq(sms.deliveryTimestamp, oldDeliveryTimestamp);
|
||||
|
||||
sms.read = false;
|
||||
do_check_true(sms.read);
|
||||
@ -92,18 +97,19 @@ add_test(function test_readonly_attributes() {
|
||||
*/
|
||||
add_test(function test_timestamp_number() {
|
||||
let ts = Date.now();
|
||||
let sms = newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", ts, true);
|
||||
let sms = newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", ts, 0, true);
|
||||
do_check_eq(sms.id, 42);
|
||||
do_check_eq(sms.threadId, 1);
|
||||
do_check_eq(sms.delivery, "sent");
|
||||
do_check_eq(sms.deliveryStatus, "pending");
|
||||
do_check_eq(sms.deliveryStatus, "success");
|
||||
do_check_eq(sms.sender, "the sender");
|
||||
do_check_eq(sms.receiver, "the receiver");
|
||||
do_check_eq(sms.body, "the body");
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_true(sms.timestamp instanceof Date);
|
||||
do_check_eq(sms.timestamp.getTime(), ts);
|
||||
do_check_true(sms.deliveryTimestamp === null);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -113,18 +119,19 @@ add_test(function test_timestamp_number() {
|
||||
*/
|
||||
add_test(function test_timestamp_date() {
|
||||
let date = new Date();
|
||||
let sms = newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", date, true);
|
||||
let sms = newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", date, 0, true);
|
||||
do_check_eq(sms.id, 42);
|
||||
do_check_eq(sms.threadId, 1);
|
||||
do_check_eq(sms.delivery, "sent");
|
||||
do_check_eq(sms.deliveryStatus, "pending");
|
||||
do_check_eq(sms.deliveryStatus, "success");
|
||||
do_check_eq(sms.sender, "the sender");
|
||||
do_check_eq(sms.receiver, "the receiver");
|
||||
do_check_eq(sms.body, "the body");
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_true(sms.timestamp instanceof Date);
|
||||
do_check_eq(sms.timestamp.getTime(), date.getTime());
|
||||
do_check_true(sms.deliveryTimestamp === null);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -133,10 +140,18 @@ add_test(function test_timestamp_date() {
|
||||
* Test that a floating point number for the timestamp is not allowed.
|
||||
*/
|
||||
add_test(function test_invalid_timestamp_float() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", 3.1415, true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 3.1415, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, 3.1415, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -144,10 +159,18 @@ add_test(function test_invalid_timestamp_float() {
|
||||
* Test that a null value for the timestamp is not allowed.
|
||||
*/
|
||||
add_test(function test_invalid_timestamp_null() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", null, true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", null, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, null, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -155,10 +178,18 @@ add_test(function test_invalid_timestamp_null() {
|
||||
* Test that undefined for the timestamp is not allowed.
|
||||
*/
|
||||
add_test(function test_invalid_timestamp_undefined() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", undefined, true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", undefined, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, undefined, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -166,10 +197,18 @@ add_test(function test_invalid_timestamp_undefined() {
|
||||
* Test that a random object for the timestamp is not allowed.
|
||||
*/
|
||||
add_test(function test_invalid_timestamp_object() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "normal", {}, true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", {}, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, {}, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -179,7 +218,7 @@ add_test(function test_invalid_timestamp_object() {
|
||||
add_test(function test_invalid_delivery_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "this is invalid", "pending", "the sender",
|
||||
"the receiver", "the body", "normal", new Date(), true);
|
||||
"the receiver", "the body", "normal", new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -190,7 +229,7 @@ add_test(function test_invalid_delivery_string() {
|
||||
add_test(function test_invalid_delivery_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, 1, "pending", "the sender", "the receiver", "the body",
|
||||
"normal", new Date(), true);
|
||||
"normal", new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -201,7 +240,7 @@ add_test(function test_invalid_delivery_string() {
|
||||
add_test(function test_invalid_delivery_status_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "this is invalid", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), true);
|
||||
"the body", "normal", new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -212,7 +251,7 @@ add_test(function test_invalid_delivery_status_string() {
|
||||
add_test(function test_invalid_delivery_status_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", 1, "the sender", "the receiver", "the body",
|
||||
"normal", new Date(), true);
|
||||
"normal", new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -222,8 +261,8 @@ add_test(function test_invalid_delivery_status_string() {
|
||||
*/
|
||||
add_test(function test_invalid_message_class_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", "this is invalid", new Date(), true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "this is invalid", new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -233,8 +272,8 @@ add_test(function test_invalid_message_class_string() {
|
||||
*/
|
||||
add_test(function test_invalid_message_class_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, "sent", "pending", "the sender", "the receiver",
|
||||
"the body", 1, new Date(), true);
|
||||
newMessage(42, 1, "sent", "success", "the sender", "the receiver",
|
||||
"the body", 1, new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -1752,17 +1752,18 @@ RadioInterface.prototype = {
|
||||
// because the system message mechamism will rewrap the object
|
||||
// based on the content window, which needs to know the properties.
|
||||
gSystemMessenger.broadcastMessage(aName, {
|
||||
type: aDomMessage.type,
|
||||
id: aDomMessage.id,
|
||||
threadId: aDomMessage.threadId,
|
||||
delivery: aDomMessage.delivery,
|
||||
deliveryStatus: aDomMessage.deliveryStatus,
|
||||
sender: aDomMessage.sender,
|
||||
receiver: aDomMessage.receiver,
|
||||
body: aDomMessage.body,
|
||||
messageClass: aDomMessage.messageClass,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
read: aDomMessage.read
|
||||
type: aDomMessage.type,
|
||||
id: aDomMessage.id,
|
||||
threadId: aDomMessage.threadId,
|
||||
delivery: aDomMessage.delivery,
|
||||
deliveryStatus: aDomMessage.deliveryStatus,
|
||||
sender: aDomMessage.sender,
|
||||
receiver: aDomMessage.receiver,
|
||||
body: aDomMessage.body,
|
||||
messageClass: aDomMessage.messageClass,
|
||||
timestamp: aDomMessage.timestamp,
|
||||
deliveryTimestamp: aDomMessage.deliveryTimestamp,
|
||||
read: aDomMessage.read
|
||||
});
|
||||
},
|
||||
|
||||
@ -1848,6 +1849,7 @@ RadioInterface.prototype = {
|
||||
message.body,
|
||||
message.messageClass,
|
||||
message.timestamp,
|
||||
0,
|
||||
message.read);
|
||||
|
||||
Services.obs.notifyObservers(domMessage,
|
||||
@ -1912,6 +1914,7 @@ RadioInterface.prototype = {
|
||||
message.body,
|
||||
message.messageClass,
|
||||
message.timestamp,
|
||||
0,
|
||||
message.read);
|
||||
|
||||
notifyReceived(Cr.NS_OK, domMessage);
|
||||
@ -3021,9 +3024,9 @@ RadioInterface.prototype = {
|
||||
|
||||
// Message sent.
|
||||
if (context.silent) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they are
|
||||
// read only so we just create a new sms instance to send along with
|
||||
// the notification.
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
let sms = context.sms;
|
||||
context.request.notifyMessageSent(
|
||||
gMobileMessageService.createSmsMessage(sms.id,
|
||||
@ -3035,6 +3038,7 @@ RadioInterface.prototype = {
|
||||
sms.body,
|
||||
sms.messageClass,
|
||||
sms.timestamp,
|
||||
0,
|
||||
sms.read));
|
||||
// We don't wait for SMS-DELIVER-REPORT for silent one.
|
||||
return false;
|
||||
@ -3085,6 +3089,7 @@ RadioInterface.prototype = {
|
||||
sendingMessage.body,
|
||||
"normal", // message class
|
||||
sendingMessage.timestamp,
|
||||
0,
|
||||
false);
|
||||
notifyResult(Cr.NS_OK, domMessage);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user