Bug 709568 - Part 0: Create SmsMessages from JS. r=smaug
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Sat, 24 Dec 2011 06:02:52 +0100
changeset 83306 49b65b70d75f14beafc8e756ce260a0b2589b5d6
parent 83305 6cb5f489a82c9da5f3c6c0a17eb4983cd5635234
child 83307 35a734c5f8c37157f7693375af20a033e70316ca
push id4345
push userpweitershausen@mozilla.com
push dateSat, 24 Dec 2011 05:06:23 +0000
treeherdermozilla-inbound@f50fd00d1c0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs709568
milestone12.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 709568 - Part 0: Create SmsMessages from JS. r=smaug
dom/sms/Makefile.in
dom/sms/interfaces/nsIDOMSmsMessage.idl
dom/sms/interfaces/nsISmsService.idl
dom/sms/src/Constants.h
dom/sms/src/SmsMessage.cpp
dom/sms/src/SmsMessage.h
dom/sms/src/android/SmsService.cpp
dom/sms/src/fallback/SmsService.cpp
dom/sms/src/ipc/SmsIPCService.cpp
dom/sms/tests/test_smsservice_createsmsmessage.js
dom/sms/tests/xpcshell.ini
testing/xpcshell/xpcshell.ini
--- a/dom/sms/Makefile.in
+++ b/dom/sms/Makefile.in
@@ -34,17 +34,20 @@
 #
 # ***** END LICENSE BLOCK *****
 
 DEPTH            = ../..
 topsrcdir        = @top_srcdir@
 srcdir           = @srcdir@
 VPATH            = @srcdir@
 
+relativesrcdir   = dom/sms
+
 include $(DEPTH)/config/autoconf.mk
 
 PARALLEL_DIRS = interfaces src
 
 ifdef ENABLE_TESTS
 DIRS += tests
+XPCSHELL_TESTS = tests
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/dom/sms/interfaces/nsIDOMSmsMessage.idl
+++ b/dom/sms/interfaces/nsIDOMSmsMessage.idl
@@ -14,16 +14,17 @@
  * The Original Code is mozilla.org.
  *
  * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *  Philipp von Weitershausen <philipp@weitershausen.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -31,17 +32,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
-[scriptable, function, uuid(0a0037ba-585e-41f4-b0a5-1d0224353105)]
+[scriptable, builtinclass, uuid(20da0c51-2224-49ae-afe9-4b309c6d8f84)]
 interface nsIDOMMozSmsMessage : nsISupports
 {
   // TODO: we should add SENT and RECEIVED DOMString constants, see bug 443316.
 
   readonly attribute long      id;
   readonly attribute DOMString delivery;  // Should be "sent" or "received".
   readonly attribute DOMString sender;
   readonly attribute DOMString receiver;
--- a/dom/sms/interfaces/nsISmsService.idl
+++ b/dom/sms/interfaces/nsISmsService.idl
@@ -14,16 +14,17 @@
  * The Original Code is mozilla.org.
  *
  * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *  Philipp von Weitershausen <philipp@weitershausen.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -31,20 +32,30 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
+interface nsIDOMMozSmsMessage;
+
 %{C++
 #define NS_SMSSERVICE_CID { 0xbada3cb8, 0xa568, 0x4dff, { 0xb5, 0x43, 0x52, 0xbb, 0xb3, 0x14, 0x31, 0x21 } }
 #define SMSSERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1"
 %}
 
-[scriptable, function, uuid(24edea1d-130a-4ae3-9522-0e2a7ee2885d)]
+[scriptable, builtinclass, uuid(a0fbbe74-5d61-4b7e-b7ab-9b5224f9e5e9)]
 interface nsISmsService : nsISupports
 {
   boolean        hasSupport();
   unsigned short getNumberOfMessagesForText(in DOMString text);
             void send(in DOMString number, in DOMString message);
+
+  [implicit_jscontext]
+  nsIDOMMozSmsMessage createSmsMessage(in long      id,
+                                       in DOMString delivery,
+                                       in DOMString sender,
+                                       in DOMString receiver,
+                                       in DOMString body,
+                                       in jsval     timestamp);
 };
--- a/dom/sms/src/Constants.h
+++ b/dom/sms/src/Constants.h
@@ -39,13 +39,16 @@
 #define mozilla_dom_sms_Constants_h
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 extern const char* kSmsReceivedObserverTopic; // Defined in the .cpp.
 
+#define DELIVERY_RECEIVED NS_LITERAL_STRING("received")
+#define DELIVERY_SENT     NS_LITERAL_STRING("sent")
+
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_sms_Constants_h
--- a/dom/sms/src/SmsMessage.cpp
+++ b/dom/sms/src/SmsMessage.cpp
@@ -15,16 +15,17 @@
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *   Philipp von Weitershausen <philipp@weitershausen.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -33,16 +34,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SmsMessage.h"
 #include "nsIDOMClassInfo.h"
 #include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
+#include "jsdate.h" // For js_DateGetMsecSinceEpoch
 #include "Constants.h"
 
 DOMCI_DATA(MozSmsMessage, mozilla::dom::sms::SmsMessage)
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
@@ -55,16 +57,67 @@ NS_INTERFACE_MAP_END
 NS_IMPL_ADDREF(SmsMessage)
 NS_IMPL_RELEASE(SmsMessage)
 
 SmsMessage::SmsMessage(const SmsMessageData& aData)
   : mData(aData)
 {
 }
 
+/* static */ nsresult
+SmsMessage::Create(PRInt32 aId,
+                   const nsAString& aDelivery,
+                   const nsAString& aSender,
+                   const nsAString& aReceiver,
+                   const nsAString& aBody,
+                   const jsval& aTimestamp,
+                   JSContext* aCx,
+                   nsIDOMMozSmsMessage** aMessage)
+{
+  *aMessage = nsnull;
+
+  // SmsMessageData exposes these as references, so we can simply assign
+  // to them.
+  SmsMessageData data;
+  data.id() = aId;
+  data.sender() = nsString(aSender);
+  data.receiver() = nsString(aReceiver);
+  data.body() = nsString(aBody);
+
+  if (aDelivery.Equals(DELIVERY_RECEIVED)) {
+    data.delivery() = eDeliveryState_Received;
+  } else if (aDelivery.Equals(DELIVERY_SENT)) {
+    data.delivery() = eDeliveryState_Sent;
+  } else {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  // We support both a Date object and a millisecond timestamp as a number.
+  if (aTimestamp.isObject()) {
+    JSObject& obj = aTimestamp.toObject();
+    if (!JS_ObjectIsDate(aCx, &obj)) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    data.timestamp() = js_DateGetMsecSinceEpoch(aCx, &obj);
+  } else {
+    if (!aTimestamp.isNumber()) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    jsdouble number = aTimestamp.toNumber();
+    if (static_cast<PRUint64>(number) != number) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    data.timestamp() = static_cast<PRUint64>(number);
+  }
+
+  nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(data);
+  message.swap(*aMessage);
+  return NS_OK;
+}
+
 const SmsMessageData&
 SmsMessage::GetData() const
 {
   return mData;
 }
 
 NS_IMETHODIMP
 SmsMessage::GetId(PRInt32* aId)
--- a/dom/sms/src/SmsMessage.h
+++ b/dom/sms/src/SmsMessage.h
@@ -36,29 +36,38 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_dom_sms_SmsMessage_h
 #define mozilla_dom_sms_SmsMessage_h
 
 #include "mozilla/dom/sms/PSms.h"
 #include "nsIDOMSmsMessage.h"
 #include "nsString.h"
+#include "jspubtd.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 class SmsMessage : public nsIDOMMozSmsMessage
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMMOZSMSMESSAGE
 
   SmsMessage(const SmsMessageData& aData);
 
+  static nsresult Create(PRInt32 aId,
+                         const nsAString& aDelivery,
+                         const nsAString& aSender,
+                         const nsAString& aReceiver,
+                         const nsAString& aBody,
+                         const JS::Value& aTimestamp,
+                         JSContext* aCx,
+                         nsIDOMMozSmsMessage** aMessage);
   const SmsMessageData& GetData() const;
 
 private:
   // Don't try to use the default constructor.
   SmsMessage();
 
   SmsMessageData mData;
 };
--- a/dom/sms/src/android/SmsService.cpp
+++ b/dom/sms/src/android/SmsService.cpp
@@ -15,33 +15,36 @@
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *   Philipp von Weitershausen <philipp@weitershausen.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "mozilla/dom/sms/SmsMessage.h"
 #include "SmsService.h"
 #include "AndroidBridge.h"
+#include "jsapi.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
 
 NS_IMETHODIMP
@@ -69,11 +72,25 @@ SmsService::Send(const nsAString& aNumbe
   if (!AndroidBridge::Bridge()) {
     return NS_OK;
   }
 
   AndroidBridge::Bridge()->SendMessage(aNumber, aMessage);
   return NS_OK;
 }
 
+NS_IMETHODIMP
+SmsService::CreateSmsMessage(PRInt32 aId,
+                             const nsAString& aDelivery,
+                             const nsAString& aSender,
+                             const nsAString& aReceiver,
+                             const nsAString& aBody,
+                             const jsval& aTimestamp,
+                             JSContext* aCx,
+                             nsIDOMMozSmsMessage** aMessage)
+{
+  return SmsMessage::Create(
+    aId, aDelivery, aSender, aReceiver, aBody, aTimestamp, aCx, aMessage);
+}
+
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/fallback/SmsService.cpp
+++ b/dom/sms/src/fallback/SmsService.cpp
@@ -15,32 +15,35 @@
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
+ *   Philipp von Weitershausen <philipp@weitershausen.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "mozilla/dom/sms/SmsMessage.h"
 #include "SmsService.h"
+#include "jsapi.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
 
 NS_IMETHODIMP
@@ -60,11 +63,25 @@ SmsService::GetNumberOfMessagesForText(c
 
 NS_IMETHODIMP
 SmsService::Send(const nsAString& aNumber, const nsAString& aMessage)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
+NS_IMETHODIMP
+SmsService::CreateSmsMessage(PRInt32 aId,
+                             const nsAString& aDelivery,
+                             const nsAString& aSender,
+                             const nsAString& aReceiver,
+                             const nsAString& aBody,
+                             const jsval& aTimestamp,
+                             JSContext* aCx,
+                             nsIDOMMozSmsMessage** aMessage)
+{
+  return SmsMessage::Create(
+    aId, aDelivery, aSender, aReceiver, aBody, aTimestamp, aCx, aMessage);
+}
+
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
--- a/dom/sms/src/ipc/SmsIPCService.cpp
+++ b/dom/sms/src/ipc/SmsIPCService.cpp
@@ -33,17 +33,19 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/dom/ContentChild.h"
 #include "SmsIPCService.h"
 #include "nsXULAppAPI.h"
+#include "jsapi.h"
 #include "mozilla/dom/sms/SmsChild.h"
+#include "mozilla/dom/sms/SmsMessage.h"
 
 namespace mozilla {
 namespace dom {
 namespace sms {
 
 PSmsChild* SmsIPCService::sSmsChild = nsnull;
 
 NS_IMPL_ISUPPORTS1(SmsIPCService, nsISmsService)
@@ -77,11 +79,25 @@ SmsIPCService::GetNumberOfMessagesForTex
 NS_IMETHODIMP
 SmsIPCService::Send(const nsAString& aNumber, const nsAString& aMessage)
 {
   GetSmsChild()->SendSendMessage(nsString(aNumber), nsString(aMessage));
 
   return NS_OK;
 }
 
+NS_IMETHODIMP
+SmsIPCService::CreateSmsMessage(PRInt32 aId,
+                                const nsAString& aDelivery,
+                                const nsAString& aSender,
+                                const nsAString& aReceiver,
+                                const nsAString& aBody,
+                                const jsval& aTimestamp,
+                                JSContext* aCx,
+                                nsIDOMMozSmsMessage** aMessage)
+{
+  return SmsMessage::Create(
+    aId, aDelivery, aSender, aReceiver, aBody, aTimestamp, aCx, aMessage);
+}
+
 } // namespace sms
 } // namespace dom
 } // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/sms/tests/test_smsservice_createsmsmessage.js
@@ -0,0 +1,165 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+function do_check_throws(f, result, stack) {
+  if (!stack) {
+    stack = Components.stack.caller;
+  }
+
+  try {
+    f();
+  } catch (exc) {
+    if (exc.result == result)
+      return;
+    do_throw("expected result " + result + ", caught " + exc, stack);
+  }
+  do_throw("expected result " + result + ", none thrown", stack);
+}
+
+let gSmsService = Cc["@mozilla.org/sms/smsservice;1"]
+                    .getService(Ci.nsISmsService);
+function newMessage() {
+  return gSmsService.createSmsMessage.apply(gSmsService, arguments);
+}
+
+function run_test() {
+  run_next_test();
+}
+
+/**
+ * Ensure an SmsMessage object created has sensible initial values.
+ */
+add_test(function test_interface() {
+  let sms = newMessage(null, "sent", null, null, null, new Date());
+  do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
+  do_check_eq(sms.id, 0);
+  do_check_eq(sms.delivery, "sent");
+  do_check_eq(sms.receiver, null);
+  do_check_eq(sms.sender, null);
+  do_check_eq(sms.body, null);
+  do_check_true(sms.timestamp instanceof Date);
+  run_next_test();
+});
+
+/**
+ * Verify that attributes are read-only.
+ */
+add_test(function test_readonly_attributes() {
+  let sms = newMessage(null, "received", null, null, null, new Date());
+
+  sms.id = 1;
+  do_check_eq(sms.id, 0);
+
+  sms.delivery = "sent";
+  do_check_eq(sms.delivery, "received");
+
+  sms.receiver = "a receiver";
+  do_check_eq(sms.receiver, null);
+
+  sms.sender = "a sender";
+  do_check_eq(sms.sender, null);
+
+  sms.body = "a body";
+  do_check_eq(sms.body, null);
+
+  let oldTimestamp = sms.timestamp.getTime();
+  sms.timestamp = new Date();
+  do_check_eq(sms.timestamp.getTime(), oldTimestamp);
+
+  run_next_test();
+});
+
+/**
+ * Test supplying the timestamp as a number of milliseconds.
+ */
+add_test(function test_timestamp_number() {
+  let ts = Date.now();
+  let sms = newMessage(42, "sent", "the sender", "the receiver", "the body", ts);
+  do_check_eq(sms.id, 42);
+  do_check_eq(sms.delivery, "sent");
+  do_check_eq(sms.sender, "the sender");
+  do_check_eq(sms.receiver, "the receiver");
+  do_check_eq(sms.body, "the body");
+  do_check_true(sms.timestamp instanceof Date);
+  do_check_eq(sms.timestamp.getTime(), ts);
+  run_next_test();
+});
+
+/**
+ * Test supplying the timestamp as a Date object.
+ */
+add_test(function test_timestamp_date() {
+  let date = new Date();
+  let sms = newMessage(42, "sent", "the sender", "the receiver", "the body", date);
+  do_check_eq(sms.id, 42);
+  do_check_eq(sms.delivery, "sent");
+  do_check_eq(sms.sender, "the sender");
+  do_check_eq(sms.receiver, "the receiver");
+  do_check_eq(sms.body, "the body");
+  do_check_true(sms.timestamp instanceof Date);
+  do_check_eq(sms.timestamp.getTime(), date.getTime());
+  run_next_test();
+});
+
+/**
+ * Test that a floating point number for the timestamp is not allowed.
+ */
+add_test(function test_invalid_timestamp_float() {
+  do_check_throws(function() {
+    newMessage(42, "sent", "the sender", "the receiver", "the body", 3.1415);
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
+
+/**
+ * Test that a null value for the timestamp is not allowed.
+ */
+add_test(function test_invalid_timestamp_null() {
+  do_check_throws(function() {
+    newMessage(42, "sent", "the sender", "the receiver", "the body", null);
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
+
+/**
+ * Test that undefined for the timestamp is not allowed.
+ */
+add_test(function test_invalid_timestamp_undefined() {
+  do_check_throws(function() {
+    newMessage(42, "sent", "the sender", "the receiver", "the body", undefined);
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
+
+/**
+ * Test that a random object for the timestamp is not allowed.
+ */
+add_test(function test_invalid_timestamp_object() {
+  do_check_throws(function() {
+    newMessage(42, "sent", "the sender", "the receiver", "the body", {});
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
+
+/**
+ * Test that an invalid delivery string is not accepted.
+ */
+add_test(function test_invalid_delivery_string() {
+  do_check_throws(function() {
+    newMessage(42, "this is invalid", "the sender", "the receiver", "the body",
+               new Date());
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
+
+/**
+ * Test that a number is not accepted for the 'delivery' argument.
+ */
+add_test(function test_invalid_delivery_string() {
+  do_check_throws(function() {
+    newMessage(42, 1, "the sender", "the receiver", "the body", new Date());
+  }, Cr.NS_ERROR_INVALID_ARG);
+  run_next_test();
+});
new file mode 100644
--- /dev/null
+++ b/dom/sms/tests/xpcshell.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+head = 
+tail = 
+
+[test_smsservice_createsmsmessage.js]
--- a/testing/xpcshell/xpcshell.ini
+++ b/testing/xpcshell/xpcshell.ini
@@ -1,16 +1,17 @@
 [include:chrome/test/unit/xpcshell.ini]
 [include:intl/locale/tests/unit/xpcshell.ini]
 [include:netwerk/cookie/test/unit/xpcshell.ini]
 [include:modules/libjar/zipwriter/test/unit/xpcshell.ini]
 [include:uriloader/exthandler/tests/unit/xpcshell.ini]
 [include:parser/xml/test/unit/xpcshell.ini]
 [include:image/test/unit/xpcshell.ini]
 [include:dom/plugins/test/unit/xpcshell.ini]
+[include:dom/sms/tests/xpcshell.ini]
 [include:dom/src/json/test/unit/xpcshell.ini]
 [include:dom/tests/unit/xpcshell.ini]
 [include:content/xtf/test/unit/xpcshell.ini]
 [include:docshell/test/unit/xpcshell.ini]
 [include:embedding/tests/unit/xpcshell.ini]
 [include:toolkit/components/commandlines/test/unit/xpcshell.ini]
 [include:toolkit/components/contentprefs/tests/unit/xpcshell.ini]
 [include:toolkit/components/passwordmgr/test/unit/xpcshell.ini]