Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-07-26 14:20:01 -04:00
commit 999bcfda0a
56 changed files with 468 additions and 1025 deletions

View File

@ -12,7 +12,7 @@ this.EXPORTED_SYMBOLS = ["TelURIParser"];
this.TelURIParser = {
parseURI: function(scheme, uri) {
// https://www.ietf.org/rfc/rfc2806.txt
let subscriber = uri.slice((scheme + ':').length);
let subscriber = decodeURIComponent(uri.slice((scheme + ':').length));
if (!subscriber.length) {
return null;
@ -23,7 +23,7 @@ this.TelURIParser = {
let len = subscriber.length;
// visual-separator
let visualSeparator = [ '-', '.', '(', ')' ];
let visualSeparator = [ ' ', '-', '.', '(', ')' ];
let digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
let dtmfDigits = [ '*', '#', 'A', 'B', 'C', 'D' ];
let pauseCharacter = [ 'p', 'w' ];

View File

@ -7,6 +7,9 @@ function run_test() {
// global-phone-number
do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234'), '+1234');
// global-phone-number => white space separator
do_check_eq(TelURIParser.parseURI('tel', 'tel:+123 456 789'), '+123 456 789');
// global-phone-number => ignored chars
do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234_123'), '+1234');

View File

@ -1,4 +1,4 @@
{
"revision": "72f1b7c657c65389c843dcd032e5bb787f4afafc",
"revision": "f2454e95b24f028b6ebc1b1edb880c12f80454de",
"repo_path": "/integration/gaia-central"
}

View File

@ -149,8 +149,6 @@ function nextTest() {
}
function done() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
mediaTestCleanup();
opener.done();
}

View File

@ -216,7 +216,7 @@ var gInvalidTests = [
// we've specified.
function fileUriToSrc(path, mustExist) {
// android mochitest doesn't support file://
if (navigator.appVersion.indexOf("Android") != -1)
if (navigator.appVersion.indexOf("Android") != -1 || SpecialPowers.Services.appinfo.name == "B2G")
return path;
const Ci = SpecialPowers.Ci;
@ -691,25 +691,25 @@ function mediaTestCleanup() {
var oldGStreamer = undefined;
var oldOpus = undefined;
try { oldGStreamer = branch.getBoolPref("gstreamer.enabled"); } catch(ex) { }
try { oldDefault = branch.getIntPref("preload.default"); } catch(ex) { }
try { oldAuto = branch.getIntPref("preload.auto"); } catch(ex) { }
try { oldOpus = branch.getBoolPref("opus.enabled"); } catch(ex) { }
try { oldGStreamer = SpecialPowers.getBoolPref("media.gstreamer.enabled"); } catch(ex) { }
try { oldDefault = SpecialPowers.getIntPref("media.preload.default"); } catch(ex) { }
try { oldAuto = SpecialPowers.getIntPref("media.preload.auto"); } catch(ex) { }
try { oldOpus = SpecialPowers.getBoolPref("media.opus.enabled"); } catch(ex) { }
branch.setIntPref("preload.default", 2); // preload_metadata
branch.setIntPref("preload.auto", 3); // preload_enough
SpecialPowers.setIntPref("media.preload.default", 2); // preload_metadata
SpecialPowers.setIntPref("media.preload.auto", 3); // preload_enough
// test opus playback iff the pref exists
if (oldOpus !== undefined)
branch.setBoolPref("opus.enabled", true);
SpecialPowers.setBoolPref("media.opus.enabled", true);
if (oldGStreamer !== undefined)
branch.setBoolPref("gstreamer.enabled", true);
SpecialPowers.setBoolPref("media.gstreamer.enabled", true);
window.addEventListener("unload", function() {
if (oldGStreamer !== undefined)
branch.setBoolPref("gstreamer.enabled", oldGStreamer);
branch.setIntPref("preload.default", oldDefault);
branch.setIntPref("preload.auto", oldAuto);
SpecialPowers.setBoolPref("media.gstreamer.enabled", oldGStreamer);
SpecialPowers.setIntPref("media.preload.default", oldDefault);
SpecialPowers.setIntPref("media.preload.auto", oldAuto);
if (oldOpus !== undefined)
branch.setBoolPref("opus.enabled", oldOpus);
SpecialPowers.setBoolPref("media.opus.enabled", oldOpus);
}, false);
})();

View File

@ -30,7 +30,6 @@
#include "PowerManager.h"
#include "nsIDOMWakeLock.h"
#include "nsIPowerManagerService.h"
#include "mozilla/dom/SmsManager.h"
#include "mozilla/dom/MobileMessageManager.h"
#include "nsISmsService.h"
#include "mozilla/Hal.h"
@ -141,7 +140,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotification)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSmsManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager)
#ifdef MOZ_B2G_RIL
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
@ -204,11 +202,6 @@ Navigator::Invalidate()
mPowerManager = nullptr;
}
if (mSmsManager) {
mSmsManager->Shutdown();
mSmsManager = nullptr;
}
if (mMobileMessageManager) {
mMobileMessageManager->Shutdown();
mMobileMessageManager = nullptr;
@ -1114,19 +1107,6 @@ Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv)
return wakelock.forget();
}
nsIDOMMozSmsManager*
Navigator::GetMozSms()
{
if (!mSmsManager) {
NS_ENSURE_TRUE(mWindow, nullptr);
NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
mSmsManager = SmsManager::CreateInstance(mWindow);
}
return mSmsManager;
}
nsIDOMMozMobileMessageManager*
Navigator::GetMozMobileMessage()
{
@ -1615,14 +1595,6 @@ Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */)
return !!pmService;
}
/* static */
bool
Navigator::HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && SmsManager::CreationIsAllowed(win);
}
/* static */
bool
Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal)

View File

@ -9,7 +9,6 @@
#include "mozilla/MemoryReporting.h"
#include "nsIDOMNavigator.h"
#include "nsIDOMSmsManager.h"
#include "nsIDOMMobileMessageManager.h"
#include "nsIMozNavigatorNetwork.h"
#include "nsAutoPtr.h"
@ -63,7 +62,6 @@ class BatteryManager;
} // namespace battery
class DesktopNotificationCenter;
class SmsManager;
class MobileMessageManager;
class MozIdleObserver;
#ifdef MOZ_GAMEPAD
@ -208,7 +206,6 @@ public:
DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
ErrorResult& aRv);
nsIDOMMozSmsManager* GetMozSms();
nsIDOMMozMobileMessageManager* GetMozMobileMessage();
nsIDOMMozConnection* GetMozConnection();
nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
@ -257,7 +254,6 @@ public:
{
return HasDesktopNotificationSupport();
}
static bool HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasMobileMessageSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasCameraSupport(JSContext* /* unused */,
@ -306,7 +302,6 @@ private:
nsRefPtr<DesktopNotificationCenter> mNotification;
nsRefPtr<battery::BatteryManager> mBatteryManager;
nsRefPtr<power::PowerManager> mPowerManager;
nsRefPtr<SmsManager> mSmsManager;
nsRefPtr<MobileMessageManager> mMobileMessageManager;
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsIDOMTelephony> mTelephony;

View File

@ -218,7 +218,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "BatteryManager.h"
#include "nsIDOMPowerManager.h"
#include "nsIDOMWakeLock.h"
#include "nsIDOMSmsManager.h"
#include "nsIDOMMobileMessageManager.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsIDOMMozMmsMessage.h"
@ -577,9 +576,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozWakeLock, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -1441,10 +1437,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozWakeLock)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsManager, nsIDOMMozSmsManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsManager)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageManager, nsIDOMMozMobileMessageManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageManager)
DOM_CLASSINFO_MAP_END

View File

@ -95,7 +95,6 @@ DOMCI_CLASS(ModalContentWindow)
DOMCI_CLASS(MozPowerManager)
DOMCI_CLASS(MozWakeLock)
DOMCI_CLASS(MozSmsManager)
DOMCI_CLASS(MozMobileMessageManager)
DOMCI_CLASS(MozSmsMessage)
DOMCI_CLASS(MozMmsMessage)

View File

@ -1705,7 +1705,6 @@ addExternalIface('MozPowerManager', headerFile='nsIDOMPowerManager.h')
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
notflattened=True)
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozSmsManager', headerFile='nsIDOMSmsManager.h')
addExternalIface('MozTelephony', nativeType='nsIDOMTelephony')
addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
notflattened=True)

View File

@ -106,7 +106,7 @@ ContactDB.prototype = {
_dispatcher: {},
upgradeSchema: function upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) {
function loadInitialContacts() {
let loadInitialContacts = function() {
// Add default contacts
let jsm = {};
Cu.import("resource://gre/modules/FileUtils.jsm", jsm);
@ -155,7 +155,7 @@ ContactDB.prototype = {
if (DEBUG) debug("import: " + JSON.stringify(contact));
objectStore.put(contact);
}
}
}.bind(this);
if (DEBUG) debug("upgrade schema from: " + aOldVersion + " to " + aNewVersion + " called!");
let db = aDb;

View File

@ -12,7 +12,6 @@ XPIDL_SOURCES += [
'nsIDOMMozSmsEvent.idl',
'nsIDOMMozSmsMessage.idl',
'nsIDOMSmsFilter.idl',
'nsIDOMSmsManager.idl',
'nsIDOMSmsSegmentInfo.idl',
'nsIMmsService.idl',
'nsIMobileMessageCallback.idl',

View File

@ -1,44 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEventTarget.idl"
interface nsIDOMDOMCursor;
interface nsIDOMDOMRequest;
interface nsIDOMEventListener;
interface nsIDOMMozSmsFilter;
interface nsIDOMMozSmsSegmentInfo;
[scriptable, builtinclass, uuid(8ce00d77-71b4-43f6-92a1-2eae7c9581b9)]
interface nsIDOMMozSmsManager : nsIDOMEventTarget
{
nsIDOMMozSmsSegmentInfo getSegmentInfoForText(in DOMString text);
// The first parameter can be either a DOMString (only one number) or an array
// of DOMStrings.
// The method returns a DOMRequest object if one number has been passed.
// An array of DOMRequest objects otherwise.
jsval send(in jsval number, in DOMString message);
[binaryname(GetMessageMoz)]
nsIDOMDOMRequest getMessage(in long id);
// The parameter can be either a message id or a SmsMessage.
nsIDOMDOMRequest delete(in jsval param);
// Iterates through nsIDOMMozSmsMessage.
nsIDOMDOMCursor getMessages(in nsIDOMMozSmsFilter filter, in boolean reverse);
nsIDOMDOMRequest markMessageRead(in long id, in boolean aValue);
// Iterates through nsIDOMMozMobileMessageThread.
nsIDOMDOMCursor getThreads();
[implicit_jscontext] attribute jsval onreceived;
[implicit_jscontext] attribute jsval onsending;
[implicit_jscontext] attribute jsval onsent;
[implicit_jscontext] attribute jsval onfailed;
[implicit_jscontext] attribute jsval ondeliverysuccess;
[implicit_jscontext] attribute jsval ondeliveryerror;
};

View File

@ -18,14 +18,12 @@ namespace dom {
class DOMCursor;
class MobileMessageManager;
class SmsManager;
namespace mobilemessage {
class MobileMessageCursorCallback : public nsIMobileMessageCursorCallback
{
friend class mozilla::dom::MobileMessageManager;
friend class mozilla::dom::SmsManager;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS

View File

@ -1,502 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SmsFilter.h"
#include "SmsManager.h"
#include "nsIDOMClassInfo.h"
#include "nsISmsService.h"
#include "nsIObserverService.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "Constants.h"
#include "nsIDOMMozSmsEvent.h"
#include "nsIDOMMozSmsMessage.h"
#include "nsJSUtils.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsIMobileMessageDatabaseService.h"
#include "nsIXPConnect.h"
#include "nsIPermissionManager.h"
#include "GeneratedEvents.h"
#include "MobileMessageCallback.h"
#include "MobileMessageCursorCallback.h"
#include "DOMCursor.h"
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
#define SENDING_EVENT_NAME NS_LITERAL_STRING("sending")
#define SENT_EVENT_NAME NS_LITERAL_STRING("sent")
#define FAILED_EVENT_NAME NS_LITERAL_STRING("failed")
#define DELIVERY_SUCCESS_EVENT_NAME NS_LITERAL_STRING("deliverysuccess")
#define DELIVERY_ERROR_EVENT_NAME NS_LITERAL_STRING("deliveryerror")
using namespace mozilla::dom::mobilemessage;
DOMCI_DATA(MozSmsManager, mozilla::dom::SmsManager)
namespace mozilla {
namespace dom {
NS_INTERFACE_MAP_BEGIN(SmsManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsManager)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(SmsManager, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(SmsManager, nsDOMEventTargetHelper)
NS_IMPL_EVENT_HANDLER(SmsManager, received)
NS_IMPL_EVENT_HANDLER(SmsManager, sending)
NS_IMPL_EVENT_HANDLER(SmsManager, sent)
NS_IMPL_EVENT_HANDLER(SmsManager, failed)
NS_IMPL_EVENT_HANDLER(SmsManager, deliverysuccess)
NS_IMPL_EVENT_HANDLER(SmsManager, deliveryerror)
/* static */
bool
SmsManager::CreationIsAllowed(nsPIDOMWindow* aWindow)
{
NS_ASSERTION(aWindow, "Null pointer!");
#ifndef MOZ_WEBSMS_BACKEND
return false;
#endif
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.sms.enabled", &enabled);
NS_ENSURE_TRUE(enabled, false);
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromWindow(aWindow, "sms", &permission);
if (permission != nsIPermissionManager::ALLOW_ACTION) {
return false;
}
// Check the Sms Service:
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsService, false);
bool result = false;
smsService->HasSupport(&result);
if (!result) {
return false;
}
return true;
}
// static
already_AddRefed<SmsManager>
SmsManager::CreateInstance(nsPIDOMWindow* aWindow)
{
nsRefPtr<SmsManager> smsMgr = new SmsManager();
smsMgr->Init(aWindow);
return smsMgr.forget();
}
void
SmsManager::Init(nsPIDOMWindow *aWindow)
{
BindToOwner(aWindow);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
// GetObserverService() can return null is some situations like shutdown.
if (!obs) {
return;
}
obs->AddObserver(this, kSmsReceivedObserverTopic, false);
obs->AddObserver(this, kSmsSendingObserverTopic, false);
obs->AddObserver(this, kSmsSentObserverTopic, false);
obs->AddObserver(this, kSmsFailedObserverTopic, false);
obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
}
void
SmsManager::Shutdown()
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
// GetObserverService() can return null is some situations like shutdown.
if (!obs) {
return;
}
obs->RemoveObserver(this, kSmsReceivedObserverTopic);
obs->RemoveObserver(this, kSmsSendingObserverTopic);
obs->RemoveObserver(this, kSmsSentObserverTopic);
obs->RemoveObserver(this, kSmsFailedObserverTopic);
obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
}
NS_IMETHODIMP
SmsManager::GetSegmentInfoForText(const nsAString& aText,
nsIDOMMozSmsSegmentInfo** aResult)
{
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
return smsService->GetSegmentInfoForText(aText, aResult);
}
nsresult
SmsManager::Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<JSString*> aNumber,
const nsAString& aMessage, JS::Value* aRequest)
{
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
nsDependentJSString number;
number.init(aCx, aNumber);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
new MobileMessageCallback(request);
nsresult rv = smsService->Send(number, aMessage, msgCallback);
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> global(aCx, aGlobal);
rv = nsContentUtils::WrapNative(aCx, global,
static_cast<nsIDOMDOMRequest*>(request.get()),
aRequest);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the js value!");
return rv;
}
return NS_OK;
}
NS_IMETHODIMP
SmsManager::Send(const JS::Value& aNumber, const nsAString& aMessage, JS::Value* aReturn)
{
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
NS_ENSURE_STATE(sc);
AutoPushJSContext cx(sc->GetNativeContext());
NS_ASSERTION(cx, "Failed to get a context!");
if (!aNumber.isString() &&
!(aNumber.isObject() && JS_IsArrayObject(cx, &aNumber.toObject()))) {
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
NS_ASSERTION(global, "Failed to get global object!");
JSAutoCompartment ac(cx, global);
if (aNumber.isString()) {
JS::Rooted<JSString*> number(cx, aNumber.toString());
return Send(cx, global, number, aMessage, aReturn);
}
// Must be an object then.
if (!aNumber.isObject()) {
return NS_ERROR_FAILURE;
}
JS::Rooted<JSObject*> numbers(cx, &aNumber.toObject());
uint32_t size;
if (!JS_GetArrayLength(cx, numbers, &size)) {
return NS_ERROR_FAILURE;
}
JS::AutoValueVector requests(cx);
if (!requests.resize(size)) {
return NS_ERROR_FAILURE;
}
JS::RootedString str(cx);
for (uint32_t i = 0; i < size; ++i) {
JS::Rooted<JS::Value> number(cx);
if (!JS_GetElement(cx, numbers, i, number.address())) {
return NS_ERROR_INVALID_ARG;
}
str = JS_ValueToString(cx, number);
if (!str) {
return NS_ERROR_FAILURE;
}
nsresult rv = Send(cx, global, str, aMessage, &requests[i]);
NS_ENSURE_SUCCESS(rv, rv);
}
JSObject* obj = JS_NewArrayObject(cx, requests.length(), requests.begin());
if (!obj) {
return NS_ERROR_FAILURE;
}
aReturn->setObject(*obj);
return NS_OK;
}
NS_IMETHODIMP
SmsManager::GetMessageMoz(int32_t aId, nsIDOMDOMRequest** aRequest)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
new MobileMessageCallback(request);
nsresult rv = dbService->GetMessageMoz(aId, msgCallback);
NS_ENSURE_SUCCESS(rv, rv);
request.forget(aRequest);
return NS_OK;
}
nsresult
SmsManager::GetSmsMessageId(AutoPushJSContext &aCx,
const JS::Value &aSmsMessage, int32_t &aId)
{
nsCOMPtr<nsIDOMMozSmsMessage> message =
do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, &aSmsMessage.toObject()));
NS_ENSURE_TRUE(message, NS_ERROR_INVALID_ARG);
return message->GetId(&aId);
}
NS_IMETHODIMP
SmsManager::Delete(const JS::Value& aParam, nsIDOMDOMRequest** aRequest)
{
// We expect Int32, SmsMessage, Int32[], SmsMessage[]
if (!aParam.isObject() && !aParam.isInt32()) {
return NS_ERROR_INVALID_ARG;
}
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
AutoPushJSContext cx(sc->GetNativeContext());
NS_ENSURE_STATE(sc);
int32_t id, *idArray;
uint32_t size;
if (aParam.isInt32()) {
// Single Integer Message ID
id = aParam.toInt32();
size = 1;
idArray = &id;
} else if (!JS_IsArrayObject(cx, &aParam.toObject())) {
// Single SmsMessage object
rv = GetSmsMessageId(cx, aParam, id);
NS_ENSURE_SUCCESS(rv, rv);
size = 1;
idArray = &id;
} else {
// Int32[] or SmsMessage[]
JS::Rooted<JSObject*> ids(cx, &aParam.toObject());
JS_ALWAYS_TRUE(JS_GetArrayLength(cx, ids, &size));
nsAutoArrayPtr<int32_t> idAutoArray(new int32_t[size]);
JS::Rooted<JS::Value> idJsValue(cx);
for (uint32_t i = 0; i < size; i++) {
if (!JS_GetElement(cx, ids, i, idJsValue.address())) {
return NS_ERROR_INVALID_ARG;
}
if (idJsValue.get().isInt32()) {
idAutoArray[i] = idJsValue.get().toInt32();
} else if (idJsValue.get().isObject()) {
rv = GetSmsMessageId(cx, idJsValue, id);
NS_ENSURE_SUCCESS(rv, rv);
idAutoArray[i] = id;
}
}
idArray = idAutoArray.forget();
}
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
new MobileMessageCallback(request);
rv = dbService->DeleteMessage(idArray, size, msgCallback);
NS_ENSURE_SUCCESS(rv, rv);
request.forget(aRequest);
return NS_OK;
}
NS_IMETHODIMP
SmsManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
bool aReverse,
nsIDOMDOMCursor** aCursor)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
if (!filter) {
filter = new SmsFilter();
}
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
new MobileMessageCursorCallback();
nsCOMPtr<nsICursorContinueCallback> continueCallback;
nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
getter_AddRefs(continueCallback));
NS_ENSURE_SUCCESS(rv, rv);
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
return NS_OK;
}
NS_IMETHODIMP
SmsManager::MarkMessageRead(int32_t aId, bool aValue,
nsIDOMDOMRequest** aRequest)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
new MobileMessageCallback(request);
nsresult rv = dbService->MarkMessageRead(aId, aValue, msgCallback);
NS_ENSURE_SUCCESS(rv, rv);
request.forget(aRequest);
return NS_OK;
}
NS_IMETHODIMP
SmsManager::GetThreads(nsIDOMDOMCursor** aCursor)
{
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsRefPtr<MobileMessageCursorCallback> cursorCallback =
new MobileMessageCursorCallback();
nsCOMPtr<nsICursorContinueCallback> continueCallback;
nsresult rv = dbService->CreateThreadCursor(cursorCallback,
getter_AddRefs(continueCallback));
NS_ENSURE_SUCCESS(rv, rv);
cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
return NS_OK;
}
nsresult
SmsManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName, nsIDOMMozSmsMessage* aMessage)
{
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMMozSmsEvent(getter_AddRefs(event), this, nullptr, nullptr);
NS_ASSERTION(event, "This should never fail!");
nsCOMPtr<nsIDOMMozSmsEvent> se = do_QueryInterface(event);
MOZ_ASSERT(se);
nsresult rv = se->InitMozSmsEvent(aEventName, false, false, aMessage);
NS_ENSURE_SUCCESS(rv, rv);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
SmsManager::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, kSmsReceivedObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-received' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(RECEIVED_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsSendingObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-sending' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(SENDING_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsSentObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-sent' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(SENT_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsFailedObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-failed' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(FAILED_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliverySuccessObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivery-success' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(DELIVERY_SUCCESS_EVENT_NAME, message);
return NS_OK;
}
if (!strcmp(aTopic, kSmsDeliveryErrorObserverTopic)) {
nsCOMPtr<nsIDOMMozSmsMessage> message = do_QueryInterface(aSubject);
if (!message) {
NS_ERROR("Got a 'sms-delivery-error' topic without a valid message!");
return NS_OK;
}
DispatchTrustedSmsEventToSelf(DELIVERY_ERROR_EVENT_NAME, message);
return NS_OK;
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla

View File

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_mobilemessage_SmsManager_h
#define mozilla_dom_mobilemessage_SmsManager_h
#include "nsIDOMSmsManager.h"
#include "nsIObserver.h"
#include "nsDOMEventTargetHelper.h"
class nsIDOMMozSmsMessage;
namespace mozilla {
namespace dom {
class SmsManager : public nsDOMEventTargetHelper
, public nsIDOMMozSmsManager
, public nsIObserver
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER
NS_DECL_NSIDOMMOZSMSMANAGER
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
static already_AddRefed<SmsManager>
CreateInstance(nsPIDOMWindow *aWindow);
static bool
CreationIsAllowed(nsPIDOMWindow *aWindow);
void Init(nsPIDOMWindow *aWindow);
void Shutdown();
private:
/**
* Internal Send() method used to send one message.
*/
nsresult Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<JSString*> aNumber,
const nsAString& aMessage, JS::Value* aRequest);
nsresult DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
nsIDOMMozSmsMessage* aMessage);
/**
* Helper to get message ID from SMS Message object
*/
nsresult GetSmsMessageId(AutoPushJSContext &aCx, const JS::Value &aSmsMessage,
int32_t &aId);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_mobilemessage_SmsManager_h

View File

@ -42,7 +42,6 @@ EXPORTS.mozilla.dom += [
'MmsMessage.h',
'MobileMessageManager.h',
'SmsFilter.h',
'SmsManager.h',
'SmsMessage.h',
'SmsSegmentInfo.h',
]
@ -58,7 +57,6 @@ CPP_SOURCES += [
'SmsChild.cpp',
'SmsFilter.cpp',
'SmsIPCService.cpp',
'SmsManager.cpp',
'SmsMessage.cpp',
'SmsParent.cpp',
'SmsSegmentInfo.cpp',

View File

@ -17,17 +17,17 @@ class SMSTest(MarionetteTestCase):
# Setup the event listsener on the receiver, which should store
# a global variable when an SMS is received.
message = 'hello world!'
self.assertTrue(receiver.execute_script("return window.navigator.mozSms != null;"))
self.assertTrue(receiver.execute_script("return window.navigator.mozMobileMessage != null;"))
receiver.execute_script("""
global.smsreceived = null;
window.navigator.mozSms.addEventListener("received", function(e) {
window.navigator.mozMobileMessage.addEventListener("received", function(e) {
global.smsreceived = e.message.body;
});
""", new_sandbox=False)
# Send the SMS from the sender.
sender.execute_script("""
window.navigator.mozSms.send("%d", "%s");
window.navigator.mozMobileMessage.send("%d", "%s");
""" % (receiver.emulator.port, message))
# On the receiver, wait up to 10s for an SMS to be received, by

View File

@ -6,12 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Note: 378 chars and below is fine, but 379 and above will cause the issue.
// Sending first message works, but second one we get emulator callback but
// the actual SMS is never received, so script will timeout waiting for the
// sms.onreceived event. Also note that a single larger message (i.e. 1600
// onreceived event. Also note that a single larger message (i.e. 1600
// characters) works; so it is not a compounded send limit.
let fromNumber = "5551110000";
let msgLength = 379;
@ -41,9 +43,9 @@ function simulateIncomingSms(nextFunction) {
log("Simulating incoming multipart SMS (" + msgText.length
+ " chars total).");
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
sms.onreceived = null;
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
manager.onreceived = null;
let incomingSms = event.message;
ok(incomingSms, "incoming sms");

View File

@ -14,8 +14,9 @@ function cleanUp() {
finish();
}
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
function randomString16() {
return Math.random().toString(36).substr(2, 16);
@ -33,7 +34,7 @@ function repeat(func, array, oncomplete) {
}
function doTest(body, callback) {
sms.addEventListener("received", function onReceived(event) {
manager.addEventListener("received", function onReceived(event) {
event.target.removeEventListener(event.type, arguments.callee);
let message = event.message;
@ -42,7 +43,7 @@ function doTest(body, callback) {
window.setTimeout(callback, 0);
});
let request = sms.send(SELF, body);
let request = manager.send(SELF, body);
request.onerror = function onerror() {
ok(false, "failed to send message '" + body + "' to '" + SELF + "'");
};

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -102,7 +103,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -136,7 +137,7 @@ function getMsgs() {
log("Getting SMS messages with dates between " + yesterday + " and "
+ tomorrow +".");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -159,7 +160,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -168,7 +169,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -184,7 +185,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -102,7 +103,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -136,7 +137,7 @@ function getMsgs() {
log("Getting SMS messages with dates between " + twoDaysAgo + " and "
+ yesterday +".");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -158,14 +159,14 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -9,8 +9,9 @@ const NUM_THREADS = 10;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let pendingEmulatorCmdCount = 0;
function sendSmsToEmulator(from, text) {
@ -62,7 +63,7 @@ function getAllMessages(callback, filter, reverse) {
filter = new MozSmsFilter;
}
let messages = [];
let request = sms.getMessages(filter, reverse || false);
let request = manager.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
if (request.result) {
messages.push(request.result);
@ -83,7 +84,7 @@ function deleteAllMessages(next) {
return;
}
let request = sms.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -124,9 +125,9 @@ tasks.push(function populateMessages() {
let count = 0;
function sendMessage(iter) {
let request = sms.send("+1555531555" + iter, "Nice to meet you");
let request = manager.send("+1555531555" + iter, "Nice to meet you");
request.onsuccess = function onRequestSuccess(event) {
sms.addEventListener("received", onReceived);
manager.addEventListener("received", onReceived);
threadIds.push(request.result.threadId);
@ -138,7 +139,7 @@ tasks.push(function populateMessages() {
}
function onReceived(event) {
sms.removeEventListener("received", onReceived);
manager.removeEventListener("received", onReceived);
if (event.message.threadId != threadIds[threadIds.length - 1]) {
ok(false, "Thread IDs of sent and received message mismatch.");
@ -148,7 +149,7 @@ tasks.push(function populateMessages() {
++count;
if (count % 2) {
let request = sms.markMessageRead(event.message.id, true);
let request = manager.markMessageRead(event.message.id, true);
request.onsuccess = function onRequestSuccess(event) {
if (count < NUM_THREADS) {
sendMessage(count);

View File

@ -6,14 +6,15 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
let defaultRemoteNumber = "+15552227777";
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(sendSms);
}
@ -23,7 +24,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -48,7 +49,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -59,7 +60,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -75,7 +76,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -83,7 +84,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -98,8 +99,8 @@ function sendSms() {
log("Sending an SMS.");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsSent = true;
log("Sent SMS (id: " + event.message.id + ").");
if (gotSmsSent && gotRequestSuccess) {
@ -107,7 +108,7 @@ function sendSms() {
}
};
let request = sms.send(remoteNumber, text);
let request = manager.send(remoteNumber, text);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -119,7 +120,7 @@ function sendSms() {
simulateIncomingSms();
}
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false,"SMS send failed");
cleanUp();
}
@ -128,7 +129,7 @@ function sendSms() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -151,7 +152,7 @@ function simulateIncomingSms(remoteNumber) {
});
}
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
// Callback for incoming SMS
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
@ -190,7 +191,7 @@ function getMsgs(secondNumber) {
log("Getting the SMS messages with numbers " + defaultRemoteNumber + " and "
+ secondNumber + ".");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -213,7 +214,7 @@ function getMsgs(secondNumber) {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -222,7 +223,7 @@ function getMsgs(secondNumber) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -238,7 +239,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,14 +6,15 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
let defaultRemoteNumber = "+15552227777";
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -23,7 +24,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -48,7 +49,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -59,7 +60,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -75,7 +76,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -83,7 +84,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -106,7 +107,7 @@ function simulateIncomingSms(remoteNumber) {
});
}
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
// Callback for incoming SMS
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
@ -148,7 +149,7 @@ function getMsgs() {
filter.numbers = new Array(defaultRemoteNumber);
log("Getting the SMS messages from sender " + defaultRemoteNumber + ".");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -171,7 +172,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -180,7 +181,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -196,7 +197,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -102,7 +103,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -130,7 +131,7 @@ function nextRep() {
function markMsgRead(smsMsgs) {
nextSms = smsMsgs.shift();
log("Marking SMS (id: " + nextSms.id + ") as read.");
let request = sms.markMessageRead(nextSms.id, true);
let request = manager.markMessageRead(nextSms.id, true);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -146,7 +147,7 @@ function markMsgRead(smsMsgs) {
}
} else {
log("SMS markMessageRead failed.");
ok(false,"sms.markMessageRead request returned false");
ok(false,"manager.markMessageRead request returned false");
cleanUp();
}
};
@ -154,7 +155,7 @@ function markMsgRead(smsMsgs) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.markMessageRead request returned unexpected error: "
ok(false, "manager.markMessageRead request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -168,7 +169,7 @@ function getMsgs() {
filter.read = true;
log("Getting the read SMS messages.");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -191,7 +192,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -200,7 +201,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -215,7 +216,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -102,7 +103,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -132,8 +133,8 @@ function sendSms() {
log("Sending an SMS.");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsSent = true;
let sentSms = event.message;
log("Sent SMS (id: " + sentSms.id + ").");
@ -144,7 +145,7 @@ function sendSms() {
}
};
let request = sms.send(remoteNumber, text);
let request = manager.send(remoteNumber, text);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -157,7 +158,7 @@ function sendSms() {
getMsgs();
}
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false,"SMS send failed");
cleanUp();
}
@ -166,7 +167,7 @@ function sendSms() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -180,7 +181,7 @@ function getMsgs() {
filter.delivery = "received";
log("Getting the received SMS messages.");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -203,7 +204,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -212,7 +213,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -227,7 +228,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(sendSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -95,8 +96,8 @@ function sendSms() {
log("Sending SMS " + (smsList.length + 1) + " of "
+ (numberMsgs - 1) + ".");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsSent = true;
let sentSms = event.message;
log("Sent SMS (id: " + sentSms.id + ").");
@ -107,7 +108,7 @@ function sendSms() {
}
};
let request = sms.send(remoteNumber, text);
let request = manager.send(remoteNumber, text);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -119,7 +120,7 @@ function sendSms() {
nextRep();
}
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false,"SMS send failed");
cleanUp();
}
@ -128,7 +129,7 @@ function sendSms() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -158,7 +159,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -177,7 +178,7 @@ function getMsgs() {
filter.delivery = "sent";
log("Getting the sent SMS messages.");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -200,7 +201,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -209,7 +210,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -224,7 +225,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -21,7 +22,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -46,7 +47,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -56,7 +57,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -72,7 +73,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -80,7 +81,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -102,7 +103,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -127,7 +128,7 @@ function nextRep() {
function markMsgRead() {
// Mark first message read so not all will be found by filter
log("Marking SMS (id: " + smsList[0].id + ") as read.");
let request = sms.markMessageRead(smsList[0].id, true);
let request = manager.markMessageRead(smsList[0].id, true);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -140,7 +141,7 @@ function markMsgRead() {
getMsgs();
} else {
log("SMS markMessageRead failed.");
ok(false,"sms.markMessageRead request returned false");
ok(false,"manager.markMessageRead request returned false");
cleanUp();
}
};
@ -148,7 +149,7 @@ function markMsgRead() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.markMessageRead request returned unexpected error: "
ok(false, "manager.markMessageRead request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -162,7 +163,7 @@ function getMsgs() {
filter.read = false;
log("Getting the unread SMS messages.");
let cursor = sms.getMessages(filter, false);
let cursor = manager.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -185,7 +186,7 @@ function getMsgs() {
} else {
log("SMS getMessages returned " + foundSmsList.length +
" messages, but expected " + smsList.length + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
deleteAllMsgs(cleanUp);
}
}
@ -194,7 +195,7 @@ function getMsgs() {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -209,7 +210,7 @@ function verifyFoundMsgs(foundSmsList) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -10,7 +10,7 @@ SpecialPowers.addPermission("sms", true, document);
const REMOTE = "5559997777"; // the remote number
const EMULATOR = "15555215554"; // the emulator's number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let inText = "Incoming SMS message. Mozilla Firefox OS!";
let outText = "Outgoing SMS message. Mozilla Firefox OS!";
let gotSmsOnsent = false;
@ -24,15 +24,16 @@ let outSmsTimeStamp;
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
function simulateIncomingSms() {
log("Simulating incoming SMS.");
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
ok(incomingSms.id, "sms id");
@ -59,8 +60,8 @@ function simulateIncomingSms() {
function sendSms() {
log("Sending an SMS.");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsOnsent = true;
let sentSms = event.message;
ok(sentSms, "outgoing sms");
@ -82,7 +83,7 @@ function sendSms() {
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
};
let requestRet = sms.send(REMOTE, outText);
let requestRet = manager.send(REMOTE, outText);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -91,7 +92,7 @@ function sendSms() {
if(event.target.result){
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false,"SMS send failed");
cleanUp();
}
@ -100,7 +101,7 @@ function sendSms() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -109,7 +110,7 @@ function sendSms() {
function getReceivedSms() {
log("Getting the received SMS message (id: " + inSmsId + ").");
let requestRet = sms.getMessage(inSmsId);
let requestRet = manager.getMessage(inSmsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -143,7 +144,7 @@ function getReceivedSms() {
function getSentSms() {
log("Getting the sent SMS message (id: " + outSmsId + ").");
let requestRet = sms.getMessage(outSmsId);
let requestRet = manager.getMessage(outSmsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -177,14 +178,14 @@ function getSentSms() {
function deleteMsgs() {
log("Deleting SMS (id: " + inSmsId + ").");
let requestRet = sms.delete(inSmsId);
let requestRet = manager.delete(inSmsId);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
if(event.target.result){
log("Deleting SMS (id: " + outSmsId + ").");
let nextReqRet = sms.delete(outSmsId);
let nextReqRet = manager.delete(outSmsId);
ok(nextReqRet,"smsrequest obj returned");
nextReqRet.onsuccess = function(event) {
@ -192,12 +193,12 @@ function deleteMsgs() {
if(event.target.result) {
cleanUp();
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false,"SMS delete failed");
}
};
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false,"SMS delete failed");
}
};
@ -205,14 +206,14 @@ function deleteMsgs() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
SpecialPowers.clearUserPref("dom.sms.requestStatusReport");

View File

@ -6,7 +6,7 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let myNumber = "15555215554";
let inText = "Incoming SMS message. Mozilla Firefox OS!";
let remoteNumber = "5559997777";
@ -14,15 +14,16 @@ let inSmsId = 0;
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
function simulateIncomingSms() {
log("Simulating incoming SMS.");
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
ok(incomingSms.id, "sms id");
@ -41,7 +42,7 @@ function simulateIncomingSms() {
function getNonExistentMsg() {
let msgIdNoExist = inSmsId + 1;
log("Attempting to get non-existent message (id: " + msgIdNoExist + ").");
let requestRet = sms.getMessage(msgIdNoExist);
let requestRet = manager.getMessage(msgIdNoExist);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -65,7 +66,7 @@ function getNonExistentMsg() {
function getMsgInvalidId() {
invalidId = -1;
log("Attempting to get sms with invalid id (id: " + invalidId + ").");
let requestRet = sms.getMessage(invalidId);
let requestRet = manager.getMessage(invalidId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -89,7 +90,7 @@ function getMsgInvalidId() {
function deleteMsg() {
log("Deleting SMS (id: " + inSmsId + ").");
let requestRet = sms.delete(inSmsId);
let requestRet = manager.delete(inSmsId);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -102,14 +103,14 @@ function deleteMsg() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.setBoolPref("dom.sms.enabled", false);
finish();

View File

@ -6,13 +6,14 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let numberMsgs = 10;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Ensure test is starting clean with no existing sms messages
deleteAllMsgs(simulateIncomingSms);
}
@ -25,7 +26,7 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let smsFilter = new MozSmsFilter;
let cursor = sms.getMessages(smsFilter, false);
let cursor = manager.getMessages(smsFilter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -50,7 +51,7 @@ function deleteAllMsgs(nextFunction) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -60,7 +61,7 @@ function deleteMsgs(msgList, nextFunction) {
let smsId = msgList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -76,7 +77,7 @@ function deleteMsgs(msgList, nextFunction) {
}
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -84,7 +85,7 @@ function deleteMsgs(msgList, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -106,7 +107,7 @@ function simulateIncomingSms() {
}
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -142,7 +143,7 @@ function getMsgs(reverse) {
// Note: This test is intended for getMessages, so just a basic test with
// no filter (default); separate tests will be written for sms filtering
let cursor = sms.getMessages(smsFilter, reverse);
let cursor = manager.getMessages(smsFilter, reverse);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
@ -165,7 +166,7 @@ function getMsgs(reverse) {
} else {
log("SMS getMessages returned " + foundSmsCount +
" messages, but expected " + numberMsgs + ".");
ok(false, "Incorrect number of messages returned by sms.getMessages");
ok(false, "Incorrect number of messages returned by manager.getMessages");
}
verifyFoundMsgs(foundSmsList, reverse);
}
@ -174,7 +175,7 @@ function getMsgs(reverse) {
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
log("manager.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
cleanUp();
};
@ -216,7 +217,7 @@ function verifyFoundMsgs(foundSmsList, reverse) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -9,8 +9,9 @@ const PDU_MAX_USER_DATA_7BIT = 160;
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager, "mozSmsManager");
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let tasks = {
// List of test fuctions. Each of them should call |tasks.next()| when
@ -48,7 +49,7 @@ let tasks = {
function addTest(text, segments, charsPerSegment, charsAvailableInLastSegment) {
tasks.push(function () {
log("Testing '" + text + "' ...");
let info = sms.getSegmentInfoForText(text);
let info = manager.getSegmentInfoForText(text);
is(info.segments, segments, "info.segments");
is(info.charsPerSegment, charsPerSegment, "info.charsPerSegment");
is(info.charsAvailableInLastSegment, charsAvailableInLastSegment,
@ -62,7 +63,7 @@ function addTestThrows(text) {
tasks.push(function () {
log("Testing '" + text + "' ...");
try {
let info = sms.getSegmentInfoForText(text);
let info = manager.getSegmentInfoForText(text);
ok(false, "Not thrown");
tasks.finish();

View File

@ -6,8 +6,9 @@ MARIONETTE_TIMEOUT = 40000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let pendingEmulatorCmdCount = 0;
function sendSmsToEmulator(from, text, callback) {
@ -59,7 +60,7 @@ function getAllMessages(callback, filter, reverse) {
filter = new MozSmsFilter;
}
let messages = [];
let request = sms.getMessages(filter, reverse || false);
let request = manager.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
if (!request.done) {
messages.push(request.result);
@ -80,7 +81,7 @@ function deleteAllMessages() {
return;
}
let request = sms.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -90,17 +91,17 @@ function deleteAllMessages() {
}
function sendMessage(to, body) {
sms.onsent = function () {
sms.onsent = null;
manager.onsent = function () {
manager.onsent = null;
tasks.next();
};
let request = sms.send(to, body);
let request = manager.send(to, body);
request.onerror = tasks.finish.bind(tasks);
}
function receiveMessage(from, body) {
sms.onreceived = function () {
sms.onreceived = null;
manager.onreceived = function () {
manager.onreceived = null;
tasks.next();
};
sendSmsToEmulator(from, body, function (success) {
@ -113,7 +114,7 @@ function receiveMessage(from, body) {
function getAllThreads(callback) {
let threads = [];
let cursor = sms.getThreads();
let cursor = manager.getThreads();
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);

View File

@ -9,7 +9,10 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "5555552368"; // the remote number
const RECEIVER = "15555215554"; // the emulator's number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let body = "Hello SMS world!";
let completed = false;
@ -19,7 +22,7 @@ runEmulatorCmd("sms send " + SENDER + " " + body, function(result) {
completed = true;
});
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received an SMS!");
let message = event.message;

View File

@ -9,20 +9,21 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "5555552368"; // the remote number
const RECEIVER = "15555215554"; // the emulator's number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let msgText = "Mozilla Firefox OS!";
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
function simulateIncomingSms() {
log("Simulating incoming SMS.");
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
ok(incomingSms.id, "sms id");
@ -46,7 +47,7 @@ function simulateIncomingSms() {
function verifySmsExists(incomingSms) {
log("Getting SMS (id: " + incomingSms.id + ").");
let requestRet = sms.getMessage(incomingSms.id);
let requestRet = manager.getMessage(incomingSms.id);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -78,7 +79,7 @@ function verifySmsExists(incomingSms) {
function deleteSms(smsMsgObj){
log("Deleting SMS (id: " + smsMsgObj.id + ") using smsmsg obj parameter.");
let requestRet = sms.delete(smsMsgObj);
let requestRet = manager.delete(smsMsgObj);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -86,7 +87,7 @@ function deleteSms(smsMsgObj){
if(event.target.result){
verifySmsDeleted(smsMsgObj.id);
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false,"SMS delete failed");
cleanUp();
}
@ -95,7 +96,7 @@ function deleteSms(smsMsgObj){
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -103,7 +104,7 @@ function deleteSms(smsMsgObj){
function verifySmsDeleted(smsId) {
log("Getting SMS (id: " + smsId + ").");
let requestRet = sms.getMessage(smsId);
let requestRet = manager.getMessage(smsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -127,7 +128,7 @@ function verifySmsDeleted(smsId) {
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.setBoolPref("dom.sms.enabled", false);
finish();

View File

@ -6,7 +6,7 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
// https://developer.mozilla.org/en-US/docs/DOM/SmsManager
let maxCharsPerSms = 160;
let maxSegments = 10; // 10 message segments concatenated into 1 multipart SMS
@ -16,7 +16,8 @@ const EMULATOR = "15555215554"; // the emulator's number
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
@ -28,9 +29,9 @@ function simulateIncomingSms() {
log("Simulating incoming multipart SMS (" + msgText.length +
" chars total).");
sms.onreceived = function onreceived(event) {
sms.onreceived = null;
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
manager.onreceived = null;
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
@ -54,7 +55,7 @@ function simulateIncomingSms() {
function verifySmsExists(incomingSms) {
log("Getting SMS (id: " + incomingSms.id + ").");
let requestRet = sms.getMessage(incomingSms.id);
let requestRet = manager.getMessage(incomingSms.id);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -80,7 +81,7 @@ function verifySmsExists(incomingSms) {
function deleteSms(smsMsgObj){
log("Deleting SMS (id: " + smsMsgObj.id + ") using smsmsg obj parameter.");
let requestRet = sms.delete(smsMsgObj);
let requestRet = manager.delete(smsMsgObj);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -88,7 +89,7 @@ function deleteSms(smsMsgObj){
if (event.target.result) {
cleanUp();
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false, "SMS delete failed");
cleanUp();
}
@ -97,7 +98,7 @@ function deleteSms(smsMsgObj){
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: " +
ok(false, "manager.delete request returned unexpected error: " +
event.target.error.name);
cleanUp();
};

View File

@ -9,11 +9,12 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "5555552368"; // the remote number
const RECEIVER = "15555215554"; // the emulator's number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
@ -27,8 +28,8 @@ function simulateIncomingSms() {
msgText += 'FirefoxOS ';
}
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
ok(incomingSms.id, "sms id");
@ -50,7 +51,7 @@ function simulateIncomingSms() {
function verifySmsExists(incomingSms) {
log("Getting SMS (id: " + incomingSms.id + ").");
let requestRet = sms.getMessage(incomingSms.id);
let requestRet = manager.getMessage(incomingSms.id);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -80,7 +81,7 @@ function verifySmsExists(incomingSms) {
function deleteSms(smsMsgObj){
log("Deleting SMS (id: " + smsMsgObj.id + ") using smsmsg obj parameter.");
let requestRet = sms.delete(smsMsgObj);
let requestRet = manager.delete(smsMsgObj);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -88,7 +89,7 @@ function deleteSms(smsMsgObj){
if(event.target.result){
cleanUp();
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false,"SMS delete failed");
cleanUp();
}
@ -97,14 +98,14 @@ function deleteSms(smsMsgObj){
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -41,14 +41,14 @@ let tasks = {
}
};
let mozMobileMessage;
let manager;
function getAllMessages(callback, filter, reverse) {
if (!filter) {
filter = new MozSmsFilter;
}
let messages = [];
let request = mozMobileMessage.getMessages(filter, reverse || false);
let request = manager.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
if (request.result) {
messages.push(request.result);
@ -69,7 +69,7 @@ function deleteAllMessages() {
return;
}
let request = mozMobileMessage.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -79,10 +79,10 @@ function deleteAllMessages() {
}
function testInvalidAddressForSMS(aInvalidAddr) {
log("mozMobileMessage.send(...) should get 'InvalidAddressError' error " +
log("manager.send(...) should get 'InvalidAddressError' error " +
"when attempting to send SMS to: " + aInvalidAddr);
let request = mozMobileMessage.send(aInvalidAddr, "Test");
let request = manager.send(aInvalidAddr, "Test");
request.onerror = function(event) {
log("Received 'onerror' DOMRequest event.");
@ -94,10 +94,10 @@ function testInvalidAddressForSMS(aInvalidAddr) {
}
function testInvalidAddressForMMS(aInvalidAddrs) {
log("mozMobileMessage.sendMMS(...) should get 'InvalidAddressError' error " +
log("manager.sendMMS(...) should get 'InvalidAddressError' error " +
"when attempting to send MMS to: " + aInvalidAddrs);
let request = mozMobileMessage.sendMMS({
let request = manager.sendMMS({
subject: "Test",
receivers: aInvalidAddrs,
attachments: [],
@ -115,8 +115,9 @@ function testInvalidAddressForMMS(aInvalidAddrs) {
tasks.push(function () {
log("Verifying initial state.");
mozMobileMessage = window.navigator.mozMobileMessage;
ok(mozMobileMessage instanceof MozMobileMessageManager);
manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
tasks.next();
});

View File

@ -6,12 +6,13 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let smsList = new Array();
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
@ -30,7 +31,7 @@ function simulateIncomingSms() {
}
// Callback for incoming SMS
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -54,8 +55,8 @@ function sendSms() {
log("Sending an SMS.");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsSent = true;
let sentSms = event.message;
log("Sent SMS (id: " + sentSms.id + ").");
@ -70,7 +71,7 @@ function sendSms() {
}
};
let request = sms.send(remoteNumber, text);
let request = manager.send(remoteNumber, text);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
@ -80,7 +81,7 @@ function sendSms() {
test1();
}
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false, "SMS send failed");
deleteMsgs();
}
@ -89,14 +90,14 @@ function sendSms() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
deleteMsgs();
};
}
function markMessageAndVerify(smsId, readBool, nextFunction) {
let request = sms.markMessageRead(smsId, readBool);
let request = manager.markMessageRead(smsId, readBool);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -108,7 +109,7 @@ function markMessageAndVerify(smsId, readBool, nextFunction) {
// Message marked read/unread, now verify
log("Getting SMS message (id: " + smsId + ").");
let requestRet = sms.getMessage(smsId);
let requestRet = manager.getMessage(smsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -141,7 +142,7 @@ function markMessageAndVerify(smsId, readBool, nextFunction) {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.markMessageRead request returned unexpected error: "
ok(false, "manager.markMessageRead request returned unexpected error: "
+ event.target.error.name );
nextFunction();
};
@ -187,7 +188,7 @@ function deleteMsgs() {
let smsId = smsList.shift();
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -202,7 +203,7 @@ function deleteMsgs() {
}
} else {
log("SMS delete failed.");
ok(false, "sms.delete request returned false");
ok(false, "manager.delete request returned false");
cleanUp();
}
};
@ -210,14 +211,14 @@ function deleteMsgs() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -6,12 +6,13 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let smsId;
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
simulateIncomingSms();
}
@ -30,7 +31,7 @@ function simulateIncomingSms() {
}
// Callback for incoming SMS
sms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' sms event.");
let incomingSms = event.message;
log("Received SMS (id: " + incomingSms.id + ").");
@ -44,7 +45,7 @@ sms.onreceived = function onreceived(event) {
};
function markMsgError(invalidId, readBool, nextFunction) {
let requestRet = sms.markMessageRead(invalidId, readBool);
let requestRet = manager.markMessageRead(invalidId, readBool);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -79,7 +80,7 @@ function test2() {
function deleteMsg() {
log("Deleting SMS (id: " + smsId + ").");
let request = sms.delete(smsId);
let request = manager.delete(smsId);
ok(request instanceof DOMRequest,
"request is instanceof " + request.constructor);
@ -90,7 +91,7 @@ function deleteMsg() {
cleanUp();
} else {
log("SMS delete failed.");
ok(false,"sms.delete request returned false");
ok(false,"manager.delete request returned false");
cleanUp();
}
};
@ -98,14 +99,14 @@ function deleteMsg() {
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
}
function cleanUp() {
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
finish();

View File

@ -9,7 +9,7 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "5555552368"; // the remote number
const RECEIVER = "15555215554"; // the emulator's number
let sms = window.navigator.mozMobileMessage;
let manager = window.navigator.mozMobileMessage;
let MSG_TEXT = "Mozilla Firefox OS!";
let SMS_NUMBER = 100;
@ -68,7 +68,7 @@ function taskNextWrapper() {
function verifySmsExists(incomingSms) {
log("Getting SMS (id: " + incomingSms.id + ").");
let requestRet = sms.getMessage(incomingSms.id);
let requestRet = manager.getMessage(incomingSms.id);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -102,7 +102,7 @@ function verifySmsExists(incomingSms) {
let verifDeletedCount = 0;
function verifySmsDeleted(smsId) {
log("Getting SMS (id: " + smsId + ").");
let requestRet = sms.getMessage(smsId);
let requestRet = manager.getMessage(smsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -127,11 +127,12 @@ function verifySmsDeleted(smsId) {
tasks.push(function init() {
log("Initialize test object.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
// Callback for incoming sms
sms.onreceived = function onreceived(event) {
log("Received 'onreceived' smsmanager event.");
manager.onreceived = function onreceived(event) {
log("Received 'onreceived' event.");
let incomingSms = event.message;
ok(incomingSms, "incoming sms");
ok(incomingSms.id, "sms id");
@ -168,7 +169,7 @@ tasks.push(function deleteAllSms() {
let deleteStart = Date.now();
log("deleteStart: " + deleteStart);
log("SmsList: " + JSON.stringify(SmsList));
let requestRet = sms.delete(SmsList);
let requestRet = manager.delete(SmsList);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -180,7 +181,7 @@ tasks.push(function deleteAllSms() {
verifySmsDeleted(SmsList[i].id);
}
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false, "SMS delete failed");
}
};
@ -188,7 +189,7 @@ tasks.push(function deleteAllSms() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name);
tasks.finish();
};
@ -205,7 +206,7 @@ tasks.push(function cleanUp() {
return;
}
sms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.setBoolPref("dom.sms.enabled", false);
log("Finish!!!");

View File

@ -15,8 +15,9 @@ const PDU_UD = "41";
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let pendingEmulatorCmdCount = 0;
function sendSmsPduToEmulator(pdu) {
@ -61,8 +62,8 @@ function test_message_class_0() {
];
function do_test(dcsIndex) {
sms.addEventListener("received", function onReceived(event) {
sms.removeEventListener("received", onReceived);
manager.addEventListener("received", function onReceived(event) {
manager.removeEventListener("received", onReceived);
let message = event.message;
checkMessage(message, -1, 0, "class-0");
@ -72,7 +73,7 @@ function test_message_class_0() {
"Message's timestamp should be lesser than the timestamp of now");
// Make sure the message is not stored.
let cursor = sms.getMessages(null, false);
let cursor = manager.getMessages(null, false);
cursor.onsuccess = function onsuccess() {
if (cursor.result) {
// Here we check whether there is any message of the same sender.
@ -109,8 +110,8 @@ function test_message_class_0() {
function doTestMessageClassGeneric(allDCSs, messageClass, next) {
function do_test(dcsIndex) {
sms.addEventListener("received", function onReceived(event) {
sms.removeEventListener("received", onReceived);
manager.addEventListener("received", function onReceived(event) {
manager.removeEventListener("received", onReceived);
// Make sure we can correctly receive the message
checkMessage(event.message, null, null, messageClass);
@ -187,7 +188,7 @@ function test_message_class_2() {
}
function next() {
sms.removeEventListener("received", onReceived);
manager.removeEventListener("received", onReceived);
++pidIndex;
if (pidIndex >= allPIDs.length) {
@ -202,7 +203,7 @@ function test_message_class_2() {
}
}
sms.addEventListener("received", onReceived);
manager.addEventListener("received", onReceived);
if (pidIndex != 0) {
// Wait for three seconds to ensure we don't receive the message.

View File

@ -41,14 +41,14 @@ let tasks = {
}
};
let mozMobileMessage;
let manager;
function getAllMessages(callback, filter, reverse) {
if (!filter) {
filter = new MozSmsFilter;
}
let messages = [];
let request = mozMobileMessage.getMessages(filter, reverse || false);
let request = manager.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
if (request.result) {
messages.push(request.result);
@ -69,7 +69,7 @@ function deleteAllMessages() {
return;
}
let request = mozMobileMessage.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -81,8 +81,9 @@ function deleteAllMessages() {
tasks.push(function () {
log("Verifying initial state.");
mozMobileMessage = window.navigator.mozMobileMessage;
ok(mozMobileMessage instanceof MozMobileMessageManager);
manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
tasks.next();
});
@ -90,8 +91,8 @@ tasks.push(function () {
tasks.push(function () {
log("MmsMessage.attachments should be an empty array.");
mozMobileMessage.onfailed = function (event) {
mozMobileMessage.onfailed = null;
manager.onfailed = function (event) {
manager.onfailed = null;
let message = event.message;
ok(Array.isArray(message.attachments) && message.attachments.length === 0,
@ -102,7 +103,7 @@ tasks.push(function () {
// Have a long long subject causes the send fails, so we don't need
// networking here.
mozMobileMessage.sendMMS({
manager.sendMMS({
subject: new Array(MMS_MAX_LENGTH_SUBJECT + 2).join("a"),
receivers: ["1", "2"],
attachments: [],

View File

@ -10,7 +10,10 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "15555215554"; // the emulator's number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
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"
@ -59,8 +62,8 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
}
}
sms.removeEventListener("sending", onSmsSending);
sms.removeEventListener("sent", onSmsSent);
manager.removeEventListener("sending", onSmsSending);
manager.removeEventListener("sent", onSmsSent);
log("Done!");
window.setTimeout(callback, 0);
@ -104,7 +107,7 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
}
function onSmsSending(event) {
log("SmsManager.onsending event received.");
log("onsending event received.");
// Bug 838542: following check throws an exception and fails this case.
// ok(event instanceof MozSmsEvent,
@ -135,7 +138,7 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
}
function onSmsSent(event) {
log("SmsManager.onsent event received.");
log("onsent event received.");
// Bug 838542: following check throws an exception and fails this case.
// ok(event instanceof MozSmsEvent,
@ -145,10 +148,10 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
checkSentMessage(event.message, "onSentCalled");
}
sms.addEventListener("sending", onSmsSending);
sms.addEventListener("sent", onSmsSent);
manager.addEventListener("sending", onSmsSending);
manager.addEventListener("sent", onSmsSent);
let result = sms.send(receivers, body);
let result = manager.send(receivers, body);
is(Array.isArray(result), Array.isArray(receivers),
"send() returns an array of requests if receivers is an array");
if (Array.isArray(receivers)) {
@ -178,7 +181,7 @@ function testSendMultipartMessage() {
function testSendMessageToMultipleRecipients() {
log("Testing sending message to multiple receivers:");
// TODO: bug 788928 - add test cases for nsIDOMSmsManager.ondelivered event
// TODO: bug 788928 - add test cases for ondelivered event.
doSendMessageAndCheckSuccess(["1", "2"], SHORT_BODY, cleanUp);
}

View File

@ -10,14 +10,15 @@ SpecialPowers.addPermission("sms", true, document);
const SENDER = "15555215554"; // the emulator's number
const RECEIVER = "5551117777"; // the destination number
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
let msgText = "Mozilla Firefox OS!";
let gotSmsOnsent = false;
let gotReqOnsuccess = false;
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
sendSms();
}
@ -25,8 +26,8 @@ function sendSms() {
let smsId = 0;
log("Sending an SMS.");
sms.onsent = function(event) {
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
log("Received 'onsent' event.");
gotSmsOnsent = true;
let sentSms = event.message;
ok(sentSms, "outgoing sms");
@ -46,7 +47,7 @@ function sendSms() {
if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
};
let requestRet = sms.send(RECEIVER, msgText);
let requestRet = manager.send(RECEIVER, msgText);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -55,7 +56,7 @@ function sendSms() {
if(event.target.result){
if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false,"SMS send failed");
cleanUp();
}
@ -64,7 +65,7 @@ function sendSms() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: "
ok(false, "manager.send request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -72,7 +73,7 @@ function sendSms() {
function verifySmsExists(smsId) {
log("Getting SMS (id: " + smsId + ").");
let requestRet = sms.getMessage(smsId);
let requestRet = manager.getMessage(smsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -102,7 +103,7 @@ function verifySmsExists(smsId) {
function deleteSms(smsId){
log("Deleting SMS (id: " + smsId + ") using sms id parameter.");
let requestRet = sms.delete(smsId);
let requestRet = manager.delete(smsId);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -110,7 +111,7 @@ function deleteSms(smsId){
if(event.target.result){
verifySmsDeleted(smsId);
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false,"SMS delete failed");
cleanUp();
}
@ -119,7 +120,7 @@ function deleteSms(smsId){
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: "
ok(false, "manager.delete request returned unexpected error: "
+ event.target.error.name );
cleanUp();
};
@ -127,7 +128,7 @@ function deleteSms(smsId){
function verifySmsDeleted(smsId) {
log("Getting SMS (id: " + smsId + ").");
let requestRet = sms.getMessage(smsId);
let requestRet = manager.getMessage(smsId);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -151,7 +152,7 @@ function verifySmsDeleted(smsId) {
}
function cleanUp() {
sms.onsent = null;
manager.onsent = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");
SpecialPowers.clearUserPref("dom.sms.requestStatusReport");

View File

@ -6,14 +6,15 @@ MARIONETTE_TIMEOUT = 60000;
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
// https://developer.mozilla.org/en-US/docs/DOM/SmsManager
let maxCharsPerSms = 160;
let maxSegments = 10; // 10 message segments concatenated into 1 multipart SMS
function verifyInitialState() {
log("Verifying initial state.");
ok(sms, "mozSms");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
sendSms();
}
@ -28,9 +29,9 @@ function sendSms() {
msgText = new Array((maxCharsPerSms * maxSegments) + 1).join('a');
log("Sending multipart SMS (" + msgText.length + " chars total).");
sms.onsent = function(event) {
sms.onsent = null;
log("Received 'onsent' smsmanager event.");
manager.onsent = function(event) {
manager.onsent = null;
log("Received 'onsent' event.");
gotSmsOnSent = true;
sentSms = event.message;
@ -45,7 +46,7 @@ function sendSms() {
if (gotReqOnSuccess) { verifySmsExists(sentSms); }
};
let requestRet = sms.send(destNumber, msgText);
let requestRet = manager.send(destNumber, msgText);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -54,7 +55,7 @@ function sendSms() {
if (event.target.result) {
if (gotSmsOnSent) { verifySmsExists(sentSms); }
} else {
log("smsrequest returned false for sms.send");
log("smsrequest returned false for manager.send");
ok(false, "SMS send failed");
cleanUp();
}
@ -63,7 +64,7 @@ function sendSms() {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.send request returned unexpected error: " +
ok(false, "manager.send request returned unexpected error: " +
event.target.error.name);
cleanUp();
};
@ -71,7 +72,7 @@ function sendSms() {
function verifySmsExists(sentSms) {
log("Getting SMS (id: " + sentSms.id + ").");
let requestRet = sms.getMessage(sentSms.id);
let requestRet = manager.getMessage(sentSms.id);
ok(requestRet, "smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -98,7 +99,7 @@ function verifySmsExists(sentSms) {
function deleteSms(smsMsgObj) {
log("Deleting SMS (id: " + smsMsgObj.id + ") using smsmsg obj parameter.");
let requestRet = sms.delete(smsMsgObj);
let requestRet = manager.delete(smsMsgObj);
ok(requestRet,"smsrequest obj returned");
requestRet.onsuccess = function(event) {
@ -106,7 +107,7 @@ function deleteSms(smsMsgObj) {
if (event.target.result) {
cleanUp();
} else {
log("smsrequest returned false for sms.delete");
log("smsrequest returned false for manager.delete");
ok(false, "SMS delete failed");
cleanUp();
}
@ -115,7 +116,7 @@ function deleteSms(smsMsgObj) {
requestRet.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
ok(event.target.error, "domerror obj");
ok(false, "sms.delete request returned unexpected error: " +
ok(false, "manager.delete request returned unexpected error: " +
event.target.error.name);
cleanUp();
};

View File

@ -56,7 +56,7 @@ function getAllMessages(callback, filter, reverse) {
filter = new MozSmsFilter;
}
let messages = [];
let request = mozSms.getMessages(filter, reverse || false);
let request = manager.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
if (request.result) {
messages.push(request.result);
@ -77,7 +77,7 @@ function deleteAllMessages() {
return;
}
let request = mozSms.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -89,11 +89,11 @@ function deleteAllMessages() {
function validate(number, normalizedNumber) {
log("Checking ('" + number + "', '" + normalizedNumber + "')");
let sendRequest = mozSms.send(number, "ping");
let sendRequest = manager.send(number, "ping");
sendRequest.onsuccess = function onSendSuccess(event) {
let sentMessage = event.target.result;
mozSms.onreceived = function onreceived(event) {
manager.onreceived = function onreceived(event) {
let receivedMessage = event.message;
is(sentMessage.threadId, receivedMessage.threadId,
"message threadIds are supposed to be matched");
@ -108,10 +108,11 @@ function validate(number, normalizedNumber) {
};
}
let mozSms = window.navigator.mozSms;
let manager = window.navigator.mozMobileMessage;
tasks.push(function () {
log("Checking mozSms.");
ok(mozSms instanceof MozSmsManager);
log("Verifying initial state.");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
tasks.next();
});

View File

@ -15,8 +15,9 @@ let currentStrict7BitEncoding = false;
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", currentStrict7BitEncoding);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
function times(str, n) {
return (new Array(n + 1)).join(str);
@ -28,7 +29,7 @@ function doTest(text, strict7BitEncoding, expected) {
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", currentStrict7BitEncoding);
}
let result = sms.getSegmentInfoForText(text);
let result = manager.getSegmentInfoForText(text);
ok(result, "result of GetSegmentInfoForText is valid");
is(result.segments, expected[0], "segments");
is(result.charsPerSegment, expected[1], "charsPerSegment");

View File

@ -127,8 +127,9 @@ const SELF = "5554";
SpecialPowers.setBoolPref("dom.sms.enabled", true);
SpecialPowers.addPermission("sms", true, document);
let sms = window.navigator.mozSms;
ok(sms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let tasks = {
// List of test fuctions. Each of them should call |tasks.next()| when
@ -178,7 +179,7 @@ function testStrict7BitEncodingHelper(sent, received) {
}
}
sms.addEventListener("received", function onReceived(event) {
manager.addEventListener("received", function onReceived(event) {
event.target.removeEventListener("received", onReceived);
let message = event.message;
@ -187,7 +188,7 @@ function testStrict7BitEncodingHelper(sent, received) {
done(1);
});
let request = sms.send(SELF, sent);
let request = manager.send(SELF, sent);
request.addEventListener("success", function onRequestSuccess(event) {
let message = event.target.result;
is(message.body, sent, "sent message.body");

View File

@ -10,8 +10,9 @@ const MSGS = 3;
SpecialPowers.addPermission("sms", true, document);
SpecialPowers.setBoolPref("dom.sms.enabled", true);
let mozSms = window.navigator.mozSms;
ok(mozSms instanceof MozSmsManager);
let manager = window.navigator.mozMobileMessage;
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
let pendingEmulatorCmdCount = 0;
function sendSmsToEmulator(from, text) {
@ -63,7 +64,7 @@ function getAllMessages(callback, filter, reverse) {
filter = new MozSmsFilter;
}
let messages = [];
let cursor = mozSms.getMessages(filter, reverse || false);
let cursor = manager.getMessages(filter, reverse || false);
cursor.onsuccess = function(event) {
if (!this.done) {
messages.push(this.result);
@ -77,7 +78,7 @@ function getAllMessages(callback, filter, reverse) {
function getAllThreads(callback) {
let threads = [];
let cursor = mozSms.getThreads();
let cursor = manager.getThreads();
cursor.onsuccess = function(event) {
if (!this.done) {
threads.push(this.result);
@ -98,7 +99,7 @@ function deleteAllMessages() {
return;
}
let request = mozSms.delete(message.id);
let request = manager.delete(message.id);
request.onsuccess = deleteAll.bind(null, messages);
request.onerror = function (event) {
ok(false, "failed to delete all messages");
@ -125,7 +126,7 @@ tasks.push(getAllThreads.bind(null, function (threads) {
let gotMessagesCount = 0;
tasks.push(function () {
mozSms.onreceived = function () {
manager.onreceived = function () {
++gotMessagesCount;
};
tasks.next();
@ -169,7 +170,7 @@ tasks.push(getAllThreads.bind(null, function (threads) {
}));
tasks.push(function DeleteFirstMessage() {
let request = mozSms.delete(allMessages[0].id);
let request = manager.delete(allMessages[0].id);
request.onsuccess = function () {
getAllThreads(function (threads) {
is(threads.length, 1, "Should have only one thread");
@ -189,7 +190,7 @@ tasks.push(function DeleteFirstMessage() {
});
tasks.push(function DeleteLastMessage() {
let request = mozSms.delete(allMessages[allMessages.length - 1].id);
let request = manager.delete(allMessages[allMessages.length - 1].id);
request.onsuccess = function () {
getAllThreads(function (threads) {
is(threads.length, 1, "Should have only one thread");
@ -222,7 +223,7 @@ tasks.push(function cleanUp() {
return;
}
mozSms.onreceived = null;
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
SpecialPowers.clearUserPref("dom.sms.enabled");

View File

@ -16,9 +16,9 @@
/** Test for WebSMS **/
function checkSmsDisabled() {
ok(!('mozSms' in frames[0].navigator), "navigator.mozSms should not exist");
ok(frames[0].navigator.mozSms === undefined,
"navigator.mozSms should return undefined");
ok(!('mozMobileMessage' in frames[0].navigator), "navigator.mozMobileMessage should not exist");
ok(frames[0].navigator.mozMobileMessage === undefined,
"navigator.mozMobileMessage should return undefined");
}
function checkSmsEnabled() {
@ -28,9 +28,10 @@ function checkSmsEnabled() {
return;
}
ok('mozSms' in frames[0].navigator, "navigator.mozSms should exist");
ok(frames[0].navigator.mozSms, "navigator.mozSms returns an object");
ok(frames[0].navigator.mozSms instanceof MozSmsManager, "navigator.mozSms is an SmsManager object");
ok('mozMobileMessage' in frames[0].navigator, "navigator.mozMobileMessage should exist");
ok(frames[0].navigator.mozMobileMessage, "navigator.mozMobileMessage returns an object");
ok(frames[0].navigator.mozMobileMessage instanceof MozMobileMessageManager,
"navigator.mozMobileMessage is an MobileMessageManager object");
}
function checkInterface(aInterface) {
@ -41,7 +42,6 @@ function checkInterface(aInterface) {
function test() {
var gSmsEnabled = SpecialPowers.getBoolPref("dom.sms.enabled");
checkInterface("SmsManager");
checkInterface("SmsMessage");
checkInterface("SmsEvent");
checkInterface("SmsFilter");

View File

@ -20,8 +20,8 @@ var gData = [
{
perm: ["sms"],
needParentPerm: true,
obj: "mozSms",
idl: "nsIDOMMozSmsManager",
obj: "mozMobileMessage",
idl: "nsIDOMMozMobileMessageManager",
settings: [["dom.sms.enabled", true]],
},
]

View File

@ -270,7 +270,6 @@ var interfaceNamesInGlobalScope =
"MozSettingsEvent",
"MozSmsEvent",
"MozSmsFilter",
"MozSmsManager",
"MozSmsMessage",
"MozSmsSegmentInfo",
"MozTimeManager",

View File

@ -225,13 +225,6 @@ partial interface Navigator {
boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
};
// nsIDOMMozNavigatorSms
interface MozSmsManager;
partial interface Navigator {
[Func="Navigator::HasSmsSupport"]
readonly attribute MozSmsManager? mozSms;
};
// nsIDOMMozNavigatorMobileMessage
interface MozMobileMessageManager;
partial interface Navigator {

View File

@ -9,7 +9,71 @@
"excludetests": {
"content/xbl/":"",
"content/xul":"",
"content/media/":"",
"content/media/test/test_bug448534.html": "",
"content/media/test/test_bug495300.html":"",
"content/media/test/test_bug495300.html":"",
"content/media/test/test_bug463162.xhtml":"",
"content/media/test/test_bug495145.html": "timed out",
"content/media/test/test_bug686942.html": "timed out",
"content/media/test/test_bug686137.html": "TIMED_OUT",
"content/media/test/test_can_play_type.html":"timed out",
"content/media/test/test_chaining.html": "timed out",
"content/media/test/test_contentDuration1.html": "TIMED_OUT",
"content/media/test/test_contentDuration2.html": "TIMED_OUT",
"content/media/test/test_contentDuration3.html": "TIMED_OUT",
"content/media/test/test_contentDuration4.html": "TIMED_OUT",
"content/media/test/test_contentDuration5.html": "TIMED_OUT",
"content/media/test/test_contentDuration6.html": "TIMED_OUT",
"content/media/test/test_contentDuration7.html": "timed out",
"content/media/test/test_decoder_disable.html":"timed out",
"content/media/test/test_error_on_404.html": "timed out",
"content/media/test/test_fragment_noplay.html": "timed out",
"content/media/test/test_fragment_play.html": "",
"content/media/test/test_load.html": "Timed out after gizmo.mp4",
"content/media/test/test_load_candidates.html": "timed out",
"content/media/test/test_load_same_resource.html": "",
"content/media/test/test_media_selection.html": "",
"content/media/test/test_metadata.html": "",
"content/media/test/test_mozHasAudio.html": "",
"content/media/test/test_playback_rate_playpause.html": "",
"content/media/test/test_reactivate.html": "timed out in small-shot.mp3",
"content/media/test/test_referer.html":"",
"content/media/test/test_replay_metadata.html": "",
"content/media/test/test_seekable1.html": "",
"content/media/test/test_seek_out_of_range.html": "",
"content/media/test/test_seekLies.html": "",
"content/media/test/test_wave_data_s16.html": "",
"content/media/test/test_source.html": "",
"content/media/test/test_source_media.html": "",
"content/media/test/test_wave_data_u8.html": "",
"content/media/mediasource/test/test_MediaSource.html": " ReferenceError: MediaSource is not defined",
"content/media/test/test_bug654550.html": "timed out",
"content/media/test/test_delay_load.html": "6 failures",
"content/media/test/test_info_leak.html": "2 failures",
"content/media/test/test_play_events.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
"content/media/test/test_play_events_2.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
"content/media/test/test_playback.html": "Test timed out",
"content/media/test/test_play_events.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
"content/media/test/test_play_events_2.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
"content/media/test/test_playback.html": "Test timed out",
"content/media/test/test_streams_gc.html": "Value being assigned to HTMLMediaElement.currentTime is not a finite floating-point value",
"content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html": "Test timed out",
"content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html": " Test timed out",
"content/media/webspeech/recognition/test/test_nested_eventloop.html": "NS_ERROR_NOT_AVAILABLE: [nsIDOMWindow.showModalDialog]",
"content/media/webspeech/synth/ipc/test/test_ipc.html": "comp.classes['@mozilla.org/special-powers-observer;1'] is undefined",
"content/media/webspeech/synth/test/test_speech_queue.html": "Test timed out",
"content/media/webspeech/synth/test/test_speech_simple.html": "Test timed out",
"content/media/test/test_framebuffer.html": "timed out",
"content/media/test/test_seekable2.html": "timed out",
"content/media/test/test_seekable3.html": "timed out",
"content/media/webspeech/recognition/test/test_recognition_service_error.html": "timed out",
"content/media/test/test_can_play_type_mpeg.html":"7 failures out of 27",
"content/media/test/test_unseekable.html":"",
"content/media/webaudio/test/test_audioBufferSourceNodeOffset.html":"",
"content/media/test/test_can_play_type_ogg.html":"",
"content/media/test/test_can_play_type_no_dash.html":"",
"dom/imptests/editing/selecttest/test_addRange.html": "oom?, bug 775227",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-insertNode.html":"oom?, bug 775227",