Bug 833291 - Part 7/7: fix createMessageList(). r=hsinyi
authorVicamo Yang <vyang@mozilla.com>
Fri, 08 Mar 2013 00:12:56 +0800
changeset 124117 ed4682d0df21d2338e9dec72e5b280fc8cfb1c09
parent 124116 917a2c1cad20a2957d067116cdd9bc42e230b0f9
child 124118 9c58cb6c3b860813fb303a02775108be23a16dca
push id24408
push userryanvm@gmail.com
push dateFri, 08 Mar 2013 04:58:11 +0000
treeherdermozilla-central@cb432984d5ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs833291
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 833291 - Part 7/7: fix createMessageList(). r=hsinyi
dom/mobilemessage/src/ril/MobileMessageDatabaseService.js
dom/mobilemessage/tests/marionette/test_filter_mixed.js
dom/mobilemessage/tests/marionette/test_getmessage.js
dom/mobilemessage/tests/marionette/test_incoming.js
dom/mobilemessage/tests/marionette/test_incoming_delete.js
dom/mobilemessage/tests/marionette/test_incoming_max_segments.js
dom/mobilemessage/tests/marionette/test_incoming_multipart.js
dom/mobilemessage/tests/marionette/test_outgoing.js
dom/mobilemessage/tests/marionette/test_outgoing_delete.js
--- a/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js
+++ b/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js
@@ -772,17 +772,17 @@ MobileMessageDatabaseService.prototype =
       return false;
     }
 
     let tres = queues[0].results;
     let qres = queues[1].results;
     tres = tres.filter(function (element) {
       return qres.indexOf(element.id) != -1;
     });
-    if (aContextIndex < 0) {
+    if (aContextIndex == null) {
       for (let i = 0; i < tres.length; i++) {
         this.onNextMessageInListGot(aMessageStore, aMessageList, tres[i].id);
       }
       this.onNextMessageInListGot(aMessageStore, aMessageList, 0);
     } else {
       for (let i = 0; i < tres.length; i++) {
         this.onNextMessageInMultiFiltersGot(aMessageStore, aMessageList,
                                             aContextIndex,
@@ -1331,24 +1331,27 @@ MobileMessageDatabaseService.prototype =
             " endDate: " + filter.endDate +
             " delivery: " + filter.delivery +
             " numbers: " + filter.numbers +
             " read: " + filter.read +
             " reverse: " + reverse);
     }
 
     let self = this;
-    this.newTxn(READ_ONLY, function (error, txn, messageStore) {
+    this.newTxn(READ_ONLY, function (error, txn, stores) {
       if (error) {
         //TODO look at event.target.errorCode, pick appropriate error constant.
         if (DEBUG) debug("IDBRequest error " + error.target.errorCode);
         aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
         return;
       }
 
+      let messageStore = stores[0];
+      let participantStore = stores[1];
+
       let messageList = {
         listId: -1,
         reverse: reverse,
         processing: true,
         stop: false,
         // Local contexts for multiple filter targets' case.
         contexts: null,
         // Result queues for multiple numbers filter's case.
@@ -1358,65 +1361,69 @@ MobileMessageDatabaseService.prototype =
         results: []
       };
 
       let onNextMessageInListGotCb =
         self.onNextMessageInListGot.bind(self, messageStore, messageList);
 
       let singleFilterSuccessCb = function onsfsuccess(event) {
         if (messageList.stop) {
+          // Client called clearMessageList(). Return.
           return;
         }
 
         let cursor = event.target.result;
         // Once the cursor has retrieved all keys that matches its key range,
         // the filter search is done.
         if (cursor) {
           onNextMessageInListGotCb(cursor.primaryKey);
           cursor.continue();
         } else {
           onNextMessageInListGotCb(0);
         }
       };
 
       let singleFilterErrorCb = function onsferror(event) {
         if (messageList.stop) {
+          // Client called clearMessageList(). Return.
           return;
         }
 
-        if (DEBUG) debug("IDBRequest error " + event.target.errorCode);
+        if (DEBUG && event) debug("IDBRequest error " + event.target.errorCode);
         onNextMessageInListGotCb(-1);
       };
 
       let direction = reverse ? PREV : NEXT;
 
       // We support filtering by date range only (see `else` block below) or
       // by number/delivery status/read status with an optional date range.
       if (filter.delivery || filter.numbers || filter.read != undefined) {
         let multiFiltersGotCb = self.onNextMessageInMultiFiltersGot
                                     .bind(self, messageStore, messageList);
 
         let multiFiltersSuccessCb = function onmfsuccess(contextIndex, event) {
           if (messageList.stop) {
+            // Client called clearMessageList(). Return.
             return;
           }
 
           let cursor = event.target.result;
           if (cursor) {
             if (multiFiltersGotCb(contextIndex,
                                   cursor.primaryKey, cursor.key[1])) {
               cursor.continue();
             }
           } else {
             multiFiltersGotCb(contextIndex, 0, 0);
           }
         };
 
         let multiFiltersErrorCb = function onmferror(contextIndex, event) {
           if (messageList.stop) {
+            // Client called clearMessageList(). Return.
             return;
           }
 
           // Act as no more matched records.
           multiFiltersGotCb(contextIndex, 0, 0);
         };
 
         // Numeric 0 is smaller than any time stamp, and empty string is larger
@@ -1444,62 +1451,85 @@ MobileMessageDatabaseService.prototype =
 
         let numberOfContexts = 0;
 
         let createRangedRequest = function crr(indexName, key) {
           let range = IDBKeyRange.bound([key, startDate], [key, endDate]);
           return messageStore.index(indexName).openKeyCursor(range, direction);
         };
 
-        let createSimpleRangedRequest = function csrr(indexName, key) {
+        let createSimpleRangedRequest = function csrr(indexName, key, contextIndex) {
           let request = createRangedRequest(indexName, key);
           if (singleFilter) {
             request.onsuccess = singleFilterSuccessCb;
             request.onerror = singleFilterErrorCb;
           } else {
-            let contextIndex = numberOfContexts++;
-            messageList.contexts.push({
-              processing: true,
-              results: []
-            });
+            if (contextIndex == null) {
+              contextIndex = numberOfContexts++;
+              messageList.contexts.push({
+                processing: true,
+                results: []
+              });
+            }
             request.onsuccess = multiFiltersSuccessCb.bind(null, contextIndex);
             request.onerror = multiFiltersErrorCb.bind(null, contextIndex);
           }
         };
 
         // Retrieve the keys from the 'delivery' index that matches the
         // value of filter.delivery.
         if (filter.delivery) {
           if (DEBUG) debug("filter.delivery " + filter.delivery);
           createSimpleRangedRequest("delivery", filter.delivery);
         }
 
         // Retrieve the keys from the 'sender' and 'receiver' indexes that
         // match the values of filter.numbers
         if (filter.numbers) {
           if (DEBUG) debug("filter.numbers " + filter.numbers.join(", "));
-          let multiNumbers = filter.numbers.length > 1;
-          if (!multiNumbers) {
-            createSimpleRangedRequest("number", filter.numbers[0]);
-          } else {
-            let contextIndex = -1;
-            if (!singleFilter) {
-              contextIndex = numberOfContexts++;
-              messageList.contexts.push({
-                processing: true,
-                results: []
-              });
+          let contextIndex;
+          if (!singleFilter) {
+            contextIndex = numberOfContexts++;
+            messageList.contexts.push({
+              processing: true,
+              results: []
+            });
+          }
+          self.findParticipantIdsByAddresses(participantStore, filter.numbers,
+                                             false, true,
+                                             function (participantIds) {
+            if (!participantIds || !participantIds.length) {
+              // Oops! No such participant at all.
+
+              if (messageList.stop) {
+                // Client called clearMessageList(). Return.
+                return;
+              }
+
+              if (singleFilter) {
+                onNextMessageInListGotCb(0);
+              } else {
+                multiFiltersGotCb(contextIndex, 0, 0);
+              }
+              return;
+            }
+
+            if (participantIds.length == 1) {
+              createSimpleRangedRequest("participantIds", participantIds[0],
+                                        contextIndex);
+              return;
             }
 
             let multiNumbersGotCb =
               self.onNextMessageInMultiNumbersGot
                   .bind(self, messageStore, messageList, contextIndex);
 
             let multiNumbersSuccessCb = function onmnsuccess(queueIndex, event) {
               if (messageList.stop) {
+                // Client called clearMessageList(). Return.
                 return;
               }
 
               let cursor = event.target.result;
               if (cursor) {
                 // If queueIndex is non-zero, it's timestamp result queue;
                 // otherwise, it's per phone number result queue.
                 let key = queueIndex ? cursor.key[1] : cursor.key;
@@ -1508,30 +1538,31 @@ MobileMessageDatabaseService.prototype =
                 }
               } else {
                 multiNumbersGotCb(queueIndex, 0, 0);
               }
             };
 
             let multiNumbersErrorCb = function onmnerror(queueIndex, event) {
               if (messageList.stop) {
+                // Client called clearMessageList(). Return.
                 return;
               }
 
               // Act as no more matched records.
               multiNumbersGotCb(queueIndex, 0, 0);
             };
 
             messageList.numberQueues = [{
               // For timestamp.
               processing: 1,
               results: []
             }, {
               // For all numbers.
-              processing: filter.numbers.length,
+              processing: participantIds.length,
               results: []
             }];
 
             let timeRange = null;
             if (filter.startDate != null && filter.endDate != null) {
               timeRange = IDBKeyRange.bound(filter.startDate.getTime(),
                                             filter.endDate.getTime());
             } else if (filter.startDate != null) {
@@ -1540,22 +1571,23 @@ MobileMessageDatabaseService.prototype =
               timeRange = IDBKeyRange.upperBound(filter.endDate.getTime());
             }
 
             let timeRequest = messageStore.index("timestamp")
                                           .openKeyCursor(timeRange, direction);
             timeRequest.onsuccess = multiNumbersSuccessCb.bind(null, 0);
             timeRequest.onerror = multiNumbersErrorCb.bind(null, 0);
 
-            for (let i = 0; i < filter.numbers.length; i++) {
-              let request = createRangedRequest("number", filter.numbers[i]);
+            for (let i = 0; i < participantIds.length; i++) {
+              let request = createRangedRequest("participantIds",
+                                                participantIds[i]);
               request.onsuccess = multiNumbersSuccessCb.bind(null, 1);
               request.onerror = multiNumbersErrorCb.bind(null, 1);
             }
-          }
+          });
         }
 
         // Retrieve the keys from the 'read' index that matches the value of
         // filter.read
         if (filter.read != undefined) {
           let read = filter.read ? FILTER_READ_READ : FILTER_READ_UNREAD;
           if (DEBUG) debug("filter.read " + read);
           createSimpleRangedRequest("read", read);
@@ -1583,17 +1615,17 @@ MobileMessageDatabaseService.prototype =
 
       if (DEBUG) {
         txn.oncomplete = function oncomplete(event) {
           debug("Transaction " + txn + " completed.");
         };
       }
 
       txn.onerror = singleFilterErrorCb;
-    });
+    }, [MESSAGE_STORE_NAME, PARTICIPANT_STORE_NAME]);
   },
 
   getNextMessageInList: function getNextMessageInList(listId, aRequest) {
     if (DEBUG) debug("Getting next message in list " + listId);
     let messageId;
     let list = this.messageLists[listId];
     if (!list) {
       if (DEBUG) debug("Wrong list id");
--- a/dom/mobilemessage/tests/marionette/test_filter_mixed.js
+++ b/dom/mobilemessage/tests/marionette/test_filter_mixed.js
@@ -112,20 +112,20 @@ tasks.push(deleteAllMessages);
  *   ...
  *   send    to   "9"
  *   receive from "9", count = 10
  */
 tasks.push(function populateMessages() {
   let count = 0;
 
   function sendMessage(iter) {
-    let request = sms.send("" + iter, "Nice to meet you");
+    let request = sms.send("+1555531555" + iter, "Nice to meet you");
     request.onsuccess = function onRequestSuccess(event) {
       sms.addEventListener("received", onReceived);
-      sendSmsToEmulator("" + iter, "Nice to meet you, too");
+      sendSmsToEmulator("555541555" + iter, "Nice to meet you, too");
     }
     request.onerror = function onRequestError(event) {
       tasks.finish();
     }
   }
 
   function onReceived(event) {
     sms.removeEventListener("received", onReceived);
@@ -152,19 +152,19 @@ tasks.push(function populateMessages() {
 
   sendMessage(count);
 });
 
 tasks.push(function testDeliveryAndNumber() {
   log("Checking delivery == sent && number == 0");
   let filter = new MozSmsFilter();
   filter.delivery = "sent";
-  filter.numbers = ["0"];
+  filter.numbers = ["+15555315550"];
   getAllMessages(function (messages) {
-    // Only { delivery: "sent", receiver: "0", read: true }
+    // Only { delivery: "sent", receiver: "+15555315550", read: true }
     is(messages.length, 1, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       is(message.delivery, filter.delivery, "message delivery");
       if (!((message.sender == filter.numbers[0])
             || (message.receiver == filter.numbers[0]))) {
         ok(false, "message sendor or receiver number");
       }
@@ -194,21 +194,21 @@ tasks.push(function testDeliveryAndNumbe
 });
 
 tasks.push(function testDeliveryAndRead() {
   log("Checking delivery == received && read == true");
   let filter = new MozSmsFilter();
   filter.delivery = "received";
   filter.read = true;
   getAllMessages(function (messages) {
-    // { delivery: "received", sender: "0", read: true },
-    // { delivery: "received", sender: "2", read: true },
-    // { delivery: "received", sender: "4", read: true },
-    // { delivery: "received", sender: "6", read: true }, and
-    // { delivery: "received", sender: "8", read: true },
+    // { delivery: "received", sender: "5555415550", read: true },
+    // { delivery: "received", sender: "5555415552", read: true },
+    // { delivery: "received", sender: "5555415554", read: true },
+    // { delivery: "received", sender: "5555415556", read: true }, and
+    // { delivery: "received", sender: "5555415558", read: true },
     is(messages.length, NUM_THREADS / 2, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       is(message.delivery, filter.delivery, "message delivery");
       is(message.read, filter.read, "message read");
     }
 
     getAllMessages(function (messages_r) {
@@ -232,22 +232,21 @@ tasks.push(function testDeliveryAndReadN
 
     tasks.next();
   }, filter);
 });
 
 tasks.push(function testNumberAndRead() {
   log("Checking number == 0 && read == true");
   let filter = new MozSmsFilter();
-  filter.numbers = ["0"];
+  filter.numbers = ["5555415550"];
   filter.read = true;
   getAllMessages(function (messages) {
-    // { delivery: "sent", receiver: "0", read: true }, and
-    // { delivery: "received", sender: "0", read: true }
-    is(messages.length, 2, "message count");
+    // { delivery: "received", sender: "5555415550", read: true }
+    is(messages.length, 1, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       if (!((message.sender == filter.numbers[0])
             || (message.receiver == filter.numbers[0]))) {
         ok(false, "message sendor or receiver number");
       }
       is(message.read, filter.read, "message read");
     }
@@ -273,23 +272,21 @@ tasks.push(function testNumberAndReadNot
 
     tasks.next();
   }, filter);
 });
 
 tasks.push(function testMultipleNumbers() {
   log("Checking number == 0 || number == 1");
   let filter = new MozSmsFilter();
-  filter.numbers = ["0", "1"];
+  filter.numbers = ["5555415550", "5555415551"];
   getAllMessages(function (messages) {
-    // { delivery: "sent", receiver: "0", read: true }
-    // { delivery: "received", sender: "0", read: true }
-    // { delivery: "sent", receiver: "1", read: true }
-    // { delivery: "received", sender: "1", read: false }
-    is(messages.length, 4, "message count");
+    // { delivery: "received", sender: "5555415550", read: true }
+    // { delivery: "received", sender: "5555415551", read: false }
+    is(messages.length, 2, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       if (!((message.sender == filter.numbers[0])
             || (message.receiver == filter.numbers[0])
             || (message.sender == filter.numbers[1])
             || (message.receiver == filter.numbers[1]))) {
         ok(false, "message sendor or receiver number");
       }
@@ -309,20 +306,20 @@ tasks.push(function testMultipleNumbersN
     tasks.next();
   }, filter);
 });
 
 tasks.push(function testDeliveryAndMultipleNumbers() {
   log("Checking delivery == sent && (number == 0 || number == 1)");
   let filter = new MozSmsFilter();
   filter.delivery = "sent";
-  filter.numbers = ["0", "1"];
+  filter.numbers = ["+15555315550", "+15555315551"];
   getAllMessages(function (messages) {
-    // { delivery: "sent", receiver: "0", read: true }
-    // { delivery: "sent", receiver: "1", read: true }
+    // { delivery: "sent", receiver: "+15555315550", read: true }
+    // { delivery: "sent", receiver: "+15555315551", read: true }
     is(messages.length, 2, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       is(message.delivery, filter.delivery, "message delivery");
       if (!((message.sender == filter.numbers[0])
             || (message.receiver == filter.numbers[0])
             || (message.sender == filter.numbers[1])
             || (message.receiver == filter.numbers[1]))) {
@@ -332,38 +329,75 @@ tasks.push(function testDeliveryAndMulti
 
     tasks.next();
   }, filter);
 });
 
 tasks.push(function testMultipleNumbersAndRead() {
   log("Checking (number == 0 || number == 1) && read == true");
   let filter = new MozSmsFilter();
-  filter.numbers = ["0", "1"];
+  filter.numbers = ["+15555315550", "5555415550"];
   filter.read = true;
   getAllMessages(function (messages) {
-    // { delivery: "sent", receiver: "0", read: true }
-    // { delivery: "received", sender: "0", read: true }
-    // { delivery: "sent", receiver: "1", read: true }
-    is(messages.length, 3, "message count");
+    // { delivery: "sent", receiver: "+15555315550", read: true }
+    // { delivery: "received", sender: "5555415550", read: true }
+    is(messages.length, 2, "message count");
     for (let i = 0; i < messages.length; i++) {
       let message = messages[i];
       is(message.read, filter.read, "message read");
       if (!((message.sender == filter.numbers[0])
             || (message.receiver == filter.numbers[0])
             || (message.sender == filter.numbers[1])
             || (message.receiver == filter.numbers[1]))) {
         ok(false, "message sendor or receiver number");
       }
     }
 
     tasks.next();
   }, filter);
 });
 
+tasks.push(function testNationalNumber() {
+  log("Checking number = 5555315550");
+  let filter = new MozSmsFilter();
+  filter.numbers = ["5555315550"];
+  getAllMessages(function (messages) {
+    // { delivery: "sent", receiver: "+15555315550", read: true }
+    is(messages.length, 1, "message count");
+    for (let i = 0; i < messages.length; i++) {
+      let message = messages[i];
+      if (!((message.sender == "+15555315550")
+            || (message.receiver == "+15555315550"))) {
+        ok(false, "message sendor or receiver number");
+      }
+    }
+
+    tasks.next();
+  }, filter);
+});
+
+tasks.push(function testInternationalNumber() {
+  log("Checking number = +15555415550");
+  let filter = new MozSmsFilter();
+  filter.numbers = ["+15555415550"];
+  getAllMessages(function (messages) {
+    // { delivery: "received", sender: "5555415550", read: true }
+    is(messages.length, 1, "message count");
+    for (let i = 0; i < messages.length; i++) {
+      let message = messages[i];
+      if (!((message.sender == "5555415550")
+            || (message.receiver == "5555415550"))) {
+        ok(false, "message sendor or receiver number");
+      }
+    }
+
+    tasks.next();
+  }, filter);
+});
+
 tasks.push(deleteAllMessages);
 
 // WARNING: All tasks should be pushed before this!!!
 tasks.push(function cleanUp() {
   if (pendingEmulatorCmdCount) {
     window.setTimeout(cleanUp, 100);
     return;
   }
--- a/dom/mobilemessage/tests/marionette/test_getmessage.js
+++ b/dom/mobilemessage/tests/marionette/test_getmessage.js
@@ -1,19 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 10000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
-const REMOTE = "5559997777";
-const REMOTE_FMT = "+15559997777"; // the normalized remote number
-const EMU_FMT = "+15555215554"; // the emulator's number
+const REMOTE = "5559997777"; // the remote number
+const EMULATOR = "15555215554"; // the emulator's number
 
 let sms = window.navigator.mozSms;
 let inText = "Incoming SMS message. Mozilla Firefox OS!";
 let outText = "Outgoing SMS message. Mozilla Firefox OS!";
 let gotSmsOnsent = false;
 let gotReqOnsuccess = false;
 let inSmsId = 0;
 let outSmsId = 0;
@@ -35,18 +34,18 @@ function simulateIncomingSms() {
     ok(incomingSms, "incoming sms");
     ok(incomingSms.id, "sms id");
     inSmsId = incomingSms.id;
     log("Received SMS (id: " + inSmsId + ").");
     is(incomingSms.body, inText, "msg body");
     is(incomingSms.delivery, "received", "delivery");
     is(incomingSms.deliveryStatus, "success", "deliveryStatus");
     is(incomingSms.read, false, "read");
-    is(incomingSms.receiver, EMU_FMT, "receiver");
-    is(incomingSms.sender, REMOTE_FMT, "sender");
+    is(incomingSms.receiver, EMULATOR, "receiver");
+    is(incomingSms.sender, REMOTE, "sender");
     is(incomingSms.messageClass, "normal", "messageClass");
     ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
     inSmsTimeStamp = incomingSms.timestamp;
     sendSms();
   };
   // Simulate incoming sms sent from remoteNumber to our emulator
   runEmulatorCmd("sms send " + REMOTE + " " + inText, function(result) {
     is(result[0], "OK", "emulator output");
@@ -62,18 +61,18 @@ function sendSms() {
     ok(sentSms, "outgoing sms");
     ok(sentSms.id, "sms id");
     outSmsId = sentSms.id;
     log("Sent SMS (id: " + outSmsId + ").");
     is(sentSms.body, outText, "msg body");
     is(sentSms.delivery, "sent", "delivery");
     is(sentSms.deliveryStatus, "pending", "deliveryStatus");
     is(sentSms.read, true, "read");
-    is(sentSms.receiver, REMOTE_FMT, "receiver");
-    is(sentSms.sender, EMU_FMT, "sender");
+    is(sentSms.receiver, REMOTE, "receiver");
+    is(sentSms.sender, EMULATOR, "sender");
     is(sentSms.messageClass, "normal", "messageClass");
     ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");  
     outSmsTimeStamp = sentSms.timestamp;
 
     if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
   };
 
   let requestRet = sms.send(REMOTE, outText);
@@ -111,18 +110,18 @@ function getReceivedSms() {
     ok(event.target.result, "smsrequest event.target.result");
     let foundSms = event.target.result;
     is(foundSms.id, inSmsId, "SMS id matches");
     log("Got SMS (id: " + foundSms.id + ").");
     is(foundSms.body, inText, "SMS msg text matches");
     is(foundSms.delivery, "received", "delivery");
     is(foundSms.deliveryStatus, "success", "deliveryStatus");
     is(foundSms.read, false, "read");
-    is(foundSms.receiver, EMU_FMT, "receiver");
-    is(foundSms.sender, REMOTE_FMT, "sender");
+    is(foundSms.receiver, EMULATOR, "receiver");
+    is(foundSms.sender, REMOTE, "sender");
     is(foundSms.messageClass, "normal", "messageClass");
     ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
     is(foundSms.timestamp.getTime(), inSmsTimeStamp.getTime(), "timestamp matches");
     getSentSms();
   };
 
   requestRet.onerror = function(event) {
     log("Received 'onerror' smsrequest event.");
@@ -144,18 +143,18 @@ function getSentSms() {
     ok(event.target.result, "smsrequest event.target.result");
     let foundSms = event.target.result;
     is(foundSms.id, outSmsId, "SMS id matches");
     log("Got SMS (id: " + foundSms.id + ").");
     is(foundSms.body, outText, "SMS msg text matches");
     is(foundSms.delivery, "sent", "delivery");
     is(foundSms.deliveryStatus, "pending", "deliveryStatus");
     is(foundSms.read, true, "read");
-    is(foundSms.receiver, REMOTE_FMT, "receiver");
-    is(foundSms.sender, EMU_FMT, "sender");
+    is(foundSms.receiver, REMOTE, "receiver");
+    is(foundSms.sender, EMULATOR, "sender");
     is(foundSms.messageClass, "normal", "messageClass");
     ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
     is(foundSms.timestamp.getTime(), outSmsTimeStamp.getTime(), "timestamp matches");
     deleteMsgs();
   };
 
   requestRet.onerror = function(event) {
     log("Received 'onerror' smsrequest event.");
--- a/dom/mobilemessage/tests/marionette/test_incoming.js
+++ b/dom/mobilemessage/tests/marionette/test_incoming.js
@@ -1,26 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 10000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
-const REMOTE = "5555552368";
-const SENDER = "+15555552368"; // the normalized remote number
-const RECEIVER = "+15555215554"; // the emulator's number
+const SENDER = "5555552368"; // the remote number
+const RECEIVER = "15555215554"; // the emulator's number
 
 let sms = window.navigator.mozSms;
 let body = "Hello SMS world!";
 let now = Date.now();
 
 let completed = false;
-runEmulatorCmd("sms send " + REMOTE + " " + body, function(result) {
+runEmulatorCmd("sms send " + SENDER + " " + body, function(result) {
   log("Sent fake SMS: " + result);
   is(result[0], "OK");
   completed = true;
 });
 
 sms.onreceived = function onreceived(event) {
   log("Received an SMS!");
 
--- a/dom/mobilemessage/tests/marionette/test_incoming_delete.js
+++ b/dom/mobilemessage/tests/marionette/test_incoming_delete.js
@@ -1,19 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 10000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
-const REMOTE = "5555552368";
-const SENDER = "+15555552368"; // the normalized remote number
-const RECEIVER = "+15555215554"; // the emulator's number
+const SENDER = "5555552368"; // the remote number
+const RECEIVER = "15555215554"; // the emulator's number
 
 let sms = window.navigator.mozSms;
 let msgText = "Mozilla Firefox OS!";
 
 function verifyInitialState() {
   log("Verifying initial state.");
   ok(sms, "mozSms");
   simulateIncomingSms();  
@@ -34,17 +33,17 @@ function simulateIncomingSms() {
     is(incomingSms.read, false, "read");
     is(incomingSms.receiver, RECEIVER, "receiver");
     is(incomingSms.sender, SENDER, "sender");
     is(incomingSms.messageClass, "normal", "messageClass");
     ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
 
     verifySmsExists(incomingSms);
   };
-  runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
+  runEmulatorCmd("sms send " + SENDER + " " + msgText, function(result) {
     is(result[0], "OK", "emulator output");
   });
 }
 
 function verifySmsExists(incomingSms) {
   log("Getting SMS (id: " + incomingSms.id + ").");
   let requestRet = sms.getMessage(incomingSms.id);
   ok(requestRet, "smsrequest obj returned");
--- a/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js
+++ b/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js
@@ -6,19 +6,18 @@ MARIONETTE_TIMEOUT = 20000;
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
 let sms = window.navigator.mozSms;
 // https://developer.mozilla.org/en-US/docs/DOM/SmsManager
 let maxCharsPerSms = 160;
 let maxSegments = 10; // 10 message segments concatenated into 1 multipart SMS
 
-const REMOTE = "5551234567";
-const REMOTE_FMT = "+15551234567"; // the normalized remote number
-const EMU_FMT = "+15555215554"; // the emulator's number
+const REMOTE = "5551234567"; // the remote number
+const EMULATOR = "15555215554"; // the emulator's number
 
 function verifyInitialState() {
   log("Verifying initial state.");
   ok(sms, "mozSms");
   simulateIncomingSms();
 }
 
 function simulateIncomingSms() {
@@ -36,18 +35,18 @@ function simulateIncomingSms() {
     let incomingSms = event.message;
     ok(incomingSms, "incoming sms");
     ok(incomingSms.id, "sms id");
     log("Received SMS (id: " + incomingSms.id + ").");
     is(incomingSms.body.length, msgText.length, "msg body length");
     is(incomingSms.body, msgText, "msg body");
     is(incomingSms.delivery, "received", "delivery");
     is(incomingSms.read, false, "read");
-    is(incomingSms.receiver, EMU_FMT, "receiver");
-    is(incomingSms.sender, REMOTE_FMT, "sender");
+    is(incomingSms.receiver, EMULATOR, "receiver");
+    is(incomingSms.sender, REMOTE, "sender");
     ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
 
     verifySmsExists(incomingSms);
   };
   runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
     is(result[0], "OK", "emulator output");
   });
 }
--- a/dom/mobilemessage/tests/marionette/test_incoming_multipart.js
+++ b/dom/mobilemessage/tests/marionette/test_incoming_multipart.js
@@ -1,19 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 10000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
-const REMOTE = "5555552368";
-const SENDER = "+15555552368"; // the normalized remote number
-const RECEIVER = "+15555215554"; // the emulator's number
+const SENDER = "5555552368"; // the remote number
+const RECEIVER = "15555215554"; // the emulator's number
 
 let sms = window.navigator.mozSms;
 
 function verifyInitialState() {
   log("Verifying initial state.");
   ok(sms, "mozSms");
   simulateIncomingSms();  
 }
@@ -38,17 +37,17 @@ function simulateIncomingSms() {
     is(incomingSms.delivery, "received", "delivery");
     is(incomingSms.read, false, "read");
     is(incomingSms.receiver, RECEIVER, "receiver");
     is(incomingSms.sender, SENDER, "sender");
     ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
 
     verifySmsExists(incomingSms);
   };
-  runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
+  runEmulatorCmd("sms send " + SENDER + " " + msgText, function(result) {
     is(result[0], "OK", "emulator output");
   });
 }
 
 function verifySmsExists(incomingSms) {
   log("Getting SMS (id: " + incomingSms.id + ").");
   let requestRet = sms.getMessage(incomingSms.id);
   ok(requestRet, "smsrequest obj returned");
--- a/dom/mobilemessage/tests/marionette/test_outgoing.js
+++ b/dom/mobilemessage/tests/marionette/test_outgoing.js
@@ -2,17 +2,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 40000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", false);
 SpecialPowers.addPermission("sms", true, document);
 
-const SENDER = "+15555215554"; // the emulator's number
+const SENDER = "15555215554"; // the emulator's number
 
 let sms = window.navigator.mozSms;
 const SHORT_BODY = "Hello SMS world!";
 const LONG_BODY = "Let me not to the marriage of true minds\n"
                 + "Admit impediments. Love is not love\n"
                 + "Which alters when it alteration finds,\n"
                 + "Or bends with the remover to remove:\n\n"
                 + "O, no! it is an ever-fix`ed mark,\n"
--- a/dom/mobilemessage/tests/marionette/test_outgoing_delete.js
+++ b/dom/mobilemessage/tests/marionette/test_outgoing_delete.js
@@ -1,19 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 10000;
 
 SpecialPowers.setBoolPref("dom.sms.enabled", true);
 SpecialPowers.addPermission("sms", true, document);
 
-const SENDER = "+15555215554"; // the emulator's number
-const DEST = "5551117777";
-const RECEIVER = "+15551117777"; // normalized destination number
+const SENDER = "15555215554"; // the emulator's number
+const RECEIVER = "5551117777"; // the destination number
 
 let sms = window.navigator.mozSms;
 let msgText = "Mozilla Firefox OS!";
 let gotSmsOnsent = false;
 let gotReqOnsuccess = false;
 
 function verifyInitialState() {
   log("Verifying initial state.");
@@ -40,17 +39,17 @@ function sendSms() {
     is(sentSms.receiver, RECEIVER, "receiver");
     is(sentSms.sender, SENDER, "sender");
     is(sentSms.messageClass, "normal", "messageClass");
     ok(sentSms.timestamp instanceof Date, "timestamp is istanceof date");
 
     if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
   };
 
-  let requestRet = sms.send(DEST, msgText);
+  let requestRet = sms.send(RECEIVER, msgText);
   ok(requestRet, "smsrequest obj returned");
 
   requestRet.onsuccess = function(event) {
     log("Received 'onsuccess' smsrequest event.");
     gotReqOnsuccess = true;
     if(event.target.result){
       if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
     } else {