Merge mozilla-central and b2g-inbound

This commit is contained in:
Ed Morley 2013-11-01 13:17:37 +00:00
commit a2c6f681ea
28 changed files with 261 additions and 90 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "b033e280989ae8e7f7e6716cd0a7126438670a5b",
"revision": "9e33e5cbf4c065e25cb88dcc28eb11069d5449b5",
"repo_path": "/integration/gaia-central"
}

View File

@ -282,12 +282,12 @@ this.PermissionsTable = { geolocation: {
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"keyboard": {
"input": {
app: DENY_ACTION,
privileged: ALLOW_ACTION,
certified: ALLOW_ACTION
},
"inputmethod-manage": {
"input-manage": {
app: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION

View File

@ -1833,7 +1833,7 @@ bool Navigator::HasInputMethodSupport(JSContext* /* unused */,
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return Preferences::GetBool("dom.mozInputMethod.testing", false) ||
(Preferences::GetBool("dom.mozInputMethod.enabled", false) &&
win && CheckPermission(win, "keyboard"));
win && CheckPermission(win, "input"));
}
/* static */

View File

@ -196,7 +196,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
let principal = this._frameElement.ownerDocument.nodePrincipal;
let perm = Services.perms
.testExactPermissionFromPrincipal(principal, "inputmethod-manage");
.testExactPermissionFromPrincipal(principal, "input-manage");
if (perm === Ci.nsIPermissionManager.ALLOW_ACTION) {
defineMethod('setInputMethodActive', this._setInputMethodActive);
}

View File

@ -12,13 +12,13 @@ browserElementTestHelpers.addPermission();
function setup() {
SpecialPowers.setBoolPref("dom.mozInputMethod.enabled", true);
SpecialPowers.setBoolPref("dom.mozInputMethod.testing", true);
SpecialPowers.addPermission('inputmethod-manage', true, document);
SpecialPowers.addPermission('input-manage', true, document);
}
function tearDown() {
SpecialPowers.setBoolPref("dom.mozInputMethod.enabled", false);
SpecialPowers.setBoolPref("dom.mozInputMethod.testing", false);
SpecialPowers.removePermission("inputmethod-manage", document);
SpecialPowers.removePermission("input-manage", document);
SimpleTest.finish();
}

View File

@ -90,7 +90,7 @@ this.Keyboard = {
receiveMessage: function keyboardReceiveMessage(msg) {
// If we get a 'Keyboard:XXX' message, check that the sender has the
// keyboard permission.
// input permission.
if (msg.name.indexOf("Keyboard:") != -1) {
if (!this.messageManager) {
return;
@ -110,9 +110,9 @@ this.Keyboard = {
return;
}
if (!mm.assertPermission("keyboard")) {
if (!mm.assertPermission("input")) {
dump("Keyboard message " + msg.name +
" from a content process with no 'keyboard' privileges.");
" from a content process with no 'input' privileges.");
return;
}
}

View File

@ -44,7 +44,7 @@ MozKeyboard.prototype = {
let principal = win.document.nodePrincipal;
// Limited the deprecated mozKeyboard API to certified apps only
let perm = Services.perms.testExactPermissionFromPrincipal(principal,
"inputmethod-manage");
"input-manage");
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
dump("No permission to use the keyboard API for " +
principal.origin + "\n");

View File

@ -71,6 +71,9 @@ this.SystemMessagePermissionsTable = {
"push-register": {
"push": []
},
"sms-delivery-success": {
"sms": []
},
"sms-received": {
"sms": []
},

View File

@ -4,7 +4,7 @@
#include "nsISupports.idl"
[scriptable, builtinclass, uuid(b755a401-d5cb-4d35-a93e-47c89d2e15ca)]
[scriptable, builtinclass, uuid(407b6d98-4140-11e3-9ec2-238ca8916558)]
interface nsIDOMMozSmsMessage : nsISupports
{
/**
@ -43,6 +43,12 @@ interface nsIDOMMozSmsMessage : nsISupports
readonly attribute DOMString messageClass;
[implicit_jscontext]
readonly attribute jsval timestamp; // jsval is for Date.
readonly attribute jsval timestamp; // Date object.
[implicit_jscontext]
readonly attribute jsval deliveryTimestamp;
// Date object; null if not available (e.g.,
// |delivery| = "received" or not yet delivered).
readonly attribute boolean read;
};

View File

@ -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]

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -1464,7 +1464,7 @@ MmsService.prototype = {
*/
broadcastSentMessageEvent: function broadcastSentMessageEvent(aDomMessage) {
// Broadcasting a 'sms-sent' system message to open apps.
this.broadcastMmsSystemMessage("sms-sent", aDomMessage);
this.broadcastMmsSystemMessage(kSmsSentObserverTopic, aDomMessage);
// Notifying observers an MMS message is sent.
Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
@ -1479,7 +1479,7 @@ MmsService.prototype = {
*/
broadcastReceivedMessageEvent :function broadcastReceivedMessageEvent(aDomMessage) {
// Broadcasting a 'sms-received' system message to open apps.
this.broadcastMmsSystemMessage("sms-received", aDomMessage);
this.broadcastMmsSystemMessage(kSmsReceivedObserverTopic, aDomMessage);
// Notifying observers an MMS message is received.
Services.obs.notifyObservers(aDomMessage, kSmsReceivedObserverTopic, null);
@ -1714,10 +1714,12 @@ MmsService.prototype = {
let topic;
if (mmsStatus === MMS.MMS_PDU_STATUS_RETRIEVED) {
topic = kSmsDeliverySuccessObserverTopic;
// Broadcasting a 'sms-delivery-success' system message to open apps.
this.broadcastMmsSystemMessage(topic, aDomMessage);
} else if (mmsStatus === MMS.MMS_PDU_STATUS_REJECTED) {
topic = kSmsDeliveryErrorObserverTopic;
}
if (!topic) {
} else {
if (DEBUG) debug("Needn't fire event for this MMS status. Returning.");
return;
}

View File

@ -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)) {

View File

@ -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;
};

View File

@ -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(); }
};

View File

@ -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();
};

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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");
}

View File

@ -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");

View File

@ -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); }
};

View File

@ -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();
});

View File

@ -18,13 +18,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=920977
<script type="application/javascript;version=1.8">
var gData = [
{
perm: ["keyboard"],
perm: ["input"],
obj: "mozInputMethod",
webidl: "MozInputMethod",
settings: [["dom.mozInputMethod.enabled", true]],
},
{
perm: ["inputmethod-manage"],
perm: ["input-manage"],
obj: "mozKeyboard",
idl: "nsIB2GKeyboard",
}

View File

@ -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,
@ -1888,7 +1890,7 @@ RadioInterface.prototype = {
return;
}
this.broadcastSmsSystemMessage("sms-received", domMessage);
this.broadcastSmsSystemMessage(kSmsReceivedObserverTopic, domMessage);
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
}.bind(this);
@ -1912,6 +1914,7 @@ RadioInterface.prototype = {
message.body,
message.messageClass,
message.timestamp,
0,
message.read);
notifyReceived(Cr.NS_OK, domMessage);
@ -3000,9 +3003,18 @@ RadioInterface.prototype = {
null,
function notifyResult(rv, domMessage) {
// TODO bug 832140 handle !Components.isSuccessCode(rv)
let topic = (response.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
let topic = (response.deliveryStatus ==
RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
? kSmsDeliverySuccessObserverTopic
: kSmsDeliveryErrorObserverTopic;
// Broadcasting a 'sms-delivery-success' system message to open apps.
if (topic == kSmsDeliverySuccessObserverTopic) {
this.broadcastSmsSystemMessage(topic, domMessage);
}
// Notifying observers the delivery status is updated.
Services.obs.notifyObservers(domMessage, topic, null);
});
@ -3012,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,
@ -3026,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;
@ -3039,12 +3052,12 @@ RadioInterface.prototype = {
null,
(function notifyResult(rv, domMessage) {
// TODO bug 832140 handle !Components.isSuccessCode(rv)
this.broadcastSmsSystemMessage("sms-sent", domMessage);
if (context.requestStatusReport) {
context.sms = domMessage;
}
this.broadcastSmsSystemMessage(kSmsSentObserverTopic, domMessage);
context.request.notifyMessageSent(domMessage);
Services.obs.notifyObservers(domMessage, kSmsSentObserverTopic, null);
}).bind(this));
@ -3076,6 +3089,7 @@ RadioInterface.prototype = {
sendingMessage.body,
"normal", // message class
sendingMessage.timestamp,
0,
false);
notifyResult(Cr.NS_OK, domMessage);
return;