From 40d98c026525cfe2b49f34c57f440cdfa6b38611 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Fri, 26 Jul 2013 18:40:27 +0800 Subject: [PATCH] Bug 891235: remove mozSms. rs=mounir --- dom/base/Navigator.cpp | 28 - dom/base/Navigator.h | 5 - dom/base/nsDOMClassInfo.cpp | 8 - dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 1 - dom/mobilemessage/interfaces/moz.build | 1 - .../interfaces/nsIDOMSmsManager.idl | 44 -- .../src/MobileMessageCursorCallback.h | 2 - dom/mobilemessage/src/SmsManager.cpp | 502 ------------------ dom/mobilemessage/src/SmsManager.h | 58 -- dom/mobilemessage/src/moz.build | 2 - .../marionette/test_between_emulators.py | 6 +- .../tests/marionette/test_bug814761.js | 12 +- .../marionette/test_emulator_loopback.js | 9 +- .../tests/marionette/test_filter_date.js | 25 +- .../marionette/test_filter_date_notfound.js | 23 +- .../tests/marionette/test_filter_mixed.js | 17 +- .../marionette/test_filter_number_multiple.js | 35 +- .../marionette/test_filter_number_single.js | 25 +- .../tests/marionette/test_filter_read.js | 31 +- .../tests/marionette/test_filter_received.js | 35 +- .../tests/marionette/test_filter_sent.js | 35 +- .../tests/marionette/test_filter_unread.js | 31 +- .../tests/marionette/test_getmessage.js | 35 +- .../marionette/test_getmessage_notfound.js | 19 +- .../tests/marionette/test_getmessages.js | 25 +- .../marionette/test_getsegmentinfofortext.js | 9 +- .../tests/marionette/test_getthreads.js | 21 +- .../tests/marionette/test_incoming.js | 7 +- .../tests/marionette/test_incoming_delete.js | 21 +- .../marionette/test_incoming_max_segments.js | 19 +- .../marionette/test_incoming_multipart.js | 19 +- .../tests/marionette/test_invalid_address.js | 19 +- .../tests/marionette/test_mark_msg_read.js | 31 +- .../marionette/test_mark_msg_read_error.js | 17 +- .../test_massive_incoming_delete.js | 21 +- .../tests/marionette/test_message_classes.js | 19 +- .../marionette/test_mmsmessage_attachments.js | 17 +- .../tests/marionette/test_outgoing.js | 21 +- .../tests/marionette/test_outgoing_delete.js | 27 +- .../marionette/test_outgoing_max_segments.js | 25 +- .../test_phone_number_normalization.js | 15 +- .../tests/marionette/test_segment_info.js | 7 +- .../marionette/test_strict_7bit_encoding.js | 9 +- .../test_update_thread_record_in_delete.js | 19 +- dom/mobilemessage/tests/test_sms_basics.html | 14 +- dom/permission/tests/test_sms.html | 4 +- .../mochitest/general/test_interfaces.html | 1 - dom/webidl/Navigator.webidl | 7 - 49 files changed, 381 insertions(+), 1003 deletions(-) delete mode 100644 dom/mobilemessage/interfaces/nsIDOMSmsManager.idl delete mode 100644 dom/mobilemessage/src/SmsManager.cpp delete mode 100644 dom/mobilemessage/src/SmsManager.h diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index a7e55f149ca..64ac55d6170 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -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 win = GetWindowFromGlobal(aGlobal); - return win && SmsManager::CreationIsAllowed(win); -} - /* static */ bool Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal) diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 0612194d30c..0a305262436 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -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 mNotification; nsRefPtr mBatteryManager; nsRefPtr mPowerManager; - nsRefPtr mSmsManager; nsRefPtr mMobileMessageManager; #ifdef MOZ_B2G_RIL nsCOMPtr mTelephony; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index b9ca18c0614..7b560052421 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -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 diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index d56eb1ad74a..6828d1ad8d3 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -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) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index a0b5681221f..080834488b4 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1743,7 +1743,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) diff --git a/dom/mobilemessage/interfaces/moz.build b/dom/mobilemessage/interfaces/moz.build index 77ac6c64fb5..2e7e55c3829 100644 --- a/dom/mobilemessage/interfaces/moz.build +++ b/dom/mobilemessage/interfaces/moz.build @@ -12,7 +12,6 @@ XPIDL_SOURCES += [ 'nsIDOMMozSmsEvent.idl', 'nsIDOMMozSmsMessage.idl', 'nsIDOMSmsFilter.idl', - 'nsIDOMSmsManager.idl', 'nsIDOMSmsSegmentInfo.idl', 'nsIMmsService.idl', 'nsIMobileMessageCallback.idl', diff --git a/dom/mobilemessage/interfaces/nsIDOMSmsManager.idl b/dom/mobilemessage/interfaces/nsIDOMSmsManager.idl deleted file mode 100644 index 31307b2f7ae..00000000000 --- a/dom/mobilemessage/interfaces/nsIDOMSmsManager.idl +++ /dev/null @@ -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; -}; diff --git a/dom/mobilemessage/src/MobileMessageCursorCallback.h b/dom/mobilemessage/src/MobileMessageCursorCallback.h index cfeb43f18ef..460291063a6 100644 --- a/dom/mobilemessage/src/MobileMessageCursorCallback.h +++ b/dom/mobilemessage/src/MobileMessageCursorCallback.h @@ -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 diff --git a/dom/mobilemessage/src/SmsManager.cpp b/dom/mobilemessage/src/SmsManager.cpp deleted file mode 100644 index 1d73cb700cd..00000000000 --- a/dom/mobilemessage/src/SmsManager.cpp +++ /dev/null @@ -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 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 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::CreateInstance(nsPIDOMWindow* aWindow) -{ - nsRefPtr smsMgr = new SmsManager(); - smsMgr->Init(aWindow); - - return smsMgr.forget(); -} - -void -SmsManager::Init(nsPIDOMWindow *aWindow) -{ - BindToOwner(aWindow); - - nsCOMPtr 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 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 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 aGlobal, JS::Handle aNumber, - const nsAString& aMessage, JS::Value* aRequest) -{ - nsCOMPtr smsService = do_GetService(SMS_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE); - - nsDependentJSString number; - number.init(aCx, aNumber); - - nsRefPtr request = new DOMRequest(GetOwner()); - nsCOMPtr msgCallback = - new MobileMessageCallback(request); - - nsresult rv = smsService->Send(number, aMessage, msgCallback); - NS_ENSURE_SUCCESS(rv, rv); - - JS::Rooted global(aCx, aGlobal); - rv = nsContentUtils::WrapNative(aCx, global, - static_cast(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 global(cx, sc->GetNativeGlobal()); - NS_ASSERTION(global, "Failed to get global object!"); - - JSAutoCompartment ac(cx, global); - - if (aNumber.isString()) { - JS::Rooted 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 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 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 dbService = - do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE); - - nsRefPtr request = new DOMRequest(GetOwner()); - nsCOMPtr 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 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 ids(cx, &aParam.toObject()); - - JS_ALWAYS_TRUE(JS_GetArrayLength(cx, ids, &size)); - nsAutoArrayPtr idAutoArray(new int32_t[size]); - - JS::Rooted 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 dbService = - do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE); - - nsRefPtr request = new DOMRequest(GetOwner()); - nsCOMPtr 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 dbService = - do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE); - - nsCOMPtr filter = aFilter; - if (!filter) { - filter = new SmsFilter(); - } - - nsRefPtr cursorCallback = - new MobileMessageCursorCallback(); - - nsCOMPtr 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 dbService = - do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE); - - nsRefPtr request = new DOMRequest(GetOwner()); - nsCOMPtr 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 dbService = - do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE); - - nsRefPtr cursorCallback = - new MobileMessageCursorCallback(); - - nsCOMPtr 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 event; - NS_NewDOMMozSmsEvent(getter_AddRefs(event), this, nullptr, nullptr); - NS_ASSERTION(event, "This should never fail!"); - - nsCOMPtr 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 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 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 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 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 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 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 diff --git a/dom/mobilemessage/src/SmsManager.h b/dom/mobilemessage/src/SmsManager.h deleted file mode 100644 index 62209252713..00000000000 --- a/dom/mobilemessage/src/SmsManager.h +++ /dev/null @@ -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 - 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 aGlobal, JS::Handle 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 diff --git a/dom/mobilemessage/src/moz.build b/dom/mobilemessage/src/moz.build index 687de5810eb..222b2f4e3c6 100644 --- a/dom/mobilemessage/src/moz.build +++ b/dom/mobilemessage/src/moz.build @@ -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', diff --git a/dom/mobilemessage/tests/marionette/test_between_emulators.py b/dom/mobilemessage/tests/marionette/test_between_emulators.py index f28314057ed..74197c4687c 100644 --- a/dom/mobilemessage/tests/marionette/test_between_emulators.py +++ b/dom/mobilemessage/tests/marionette/test_between_emulators.py @@ -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 diff --git a/dom/mobilemessage/tests/marionette/test_bug814761.js b/dom/mobilemessage/tests/marionette/test_bug814761.js index e46b3476229..9600a915069 100644 --- a/dom/mobilemessage/tests/marionette/test_bug814761.js +++ b/dom/mobilemessage/tests/marionette/test_bug814761.js @@ -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"); diff --git a/dom/mobilemessage/tests/marionette/test_emulator_loopback.js b/dom/mobilemessage/tests/marionette/test_emulator_loopback.js index 08b14261d5a..15f1e084da0 100644 --- a/dom/mobilemessage/tests/marionette/test_emulator_loopback.js +++ b/dom/mobilemessage/tests/marionette/test_emulator_loopback.js @@ -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 + "'"); }; diff --git a/dom/mobilemessage/tests/marionette/test_filter_date.js b/dom/mobilemessage/tests/marionette/test_filter_date.js index 8996d59f4af..ace1532e66c 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_date.js +++ b/dom/mobilemessage/tests/marionette/test_filter_date.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_date_notfound.js b/dom/mobilemessage/tests/marionette/test_filter_date_notfound.js index dbc0ed634ef..f9360d4265c 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_date_notfound.js +++ b/dom/mobilemessage/tests/marionette/test_filter_date_notfound.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_mixed.js b/dom/mobilemessage/tests/marionette/test_filter_mixed.js index 1a457d996c1..3bc4c6a6521 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_mixed.js +++ b/dom/mobilemessage/tests/marionette/test_filter_mixed.js @@ -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); diff --git a/dom/mobilemessage/tests/marionette/test_filter_number_multiple.js b/dom/mobilemessage/tests/marionette/test_filter_number_multiple.js index dde66cea756..60dd9ef117d 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_number_multiple.js +++ b/dom/mobilemessage/tests/marionette/test_filter_number_multiple.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_number_single.js b/dom/mobilemessage/tests/marionette/test_filter_number_single.js index db579e8b95f..382abb184c5 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_number_single.js +++ b/dom/mobilemessage/tests/marionette/test_filter_number_single.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_read.js b/dom/mobilemessage/tests/marionette/test_filter_read.js index 8e390173338..5ffb0d5aa71 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_read.js +++ b/dom/mobilemessage/tests/marionette/test_filter_read.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_received.js b/dom/mobilemessage/tests/marionette/test_filter_received.js index da6032f2eb0..f935ed5ed27 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_received.js +++ b/dom/mobilemessage/tests/marionette/test_filter_received.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_sent.js b/dom/mobilemessage/tests/marionette/test_filter_sent.js index 21c0b19f648..cd9655fe39b 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_sent.js +++ b/dom/mobilemessage/tests/marionette/test_filter_sent.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_filter_unread.js b/dom/mobilemessage/tests/marionette/test_filter_unread.js index c65c0dbf6a2..6d1b041cc62 100644 --- a/dom/mobilemessage/tests/marionette/test_filter_unread.js +++ b/dom/mobilemessage/tests/marionette/test_filter_unread.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_getmessage.js b/dom/mobilemessage/tests/marionette/test_getmessage.js index 697b098979d..a3ed8d7acd2 100644 --- a/dom/mobilemessage/tests/marionette/test_getmessage.js +++ b/dom/mobilemessage/tests/marionette/test_getmessage.js @@ -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"); diff --git a/dom/mobilemessage/tests/marionette/test_getmessage_notfound.js b/dom/mobilemessage/tests/marionette/test_getmessage_notfound.js index 1d5822d723d..2143ca02e95 100644 --- a/dom/mobilemessage/tests/marionette/test_getmessage_notfound.js +++ b/dom/mobilemessage/tests/marionette/test_getmessage_notfound.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_getmessages.js b/dom/mobilemessage/tests/marionette/test_getmessages.js index 370848c7172..59f8c4c1001 100644 --- a/dom/mobilemessage/tests/marionette/test_getmessages.js +++ b/dom/mobilemessage/tests/marionette/test_getmessages.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_getsegmentinfofortext.js b/dom/mobilemessage/tests/marionette/test_getsegmentinfofortext.js index 68fbcf1fcca..9c7169a8a2a 100644 --- a/dom/mobilemessage/tests/marionette/test_getsegmentinfofortext.js +++ b/dom/mobilemessage/tests/marionette/test_getsegmentinfofortext.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_getthreads.js b/dom/mobilemessage/tests/marionette/test_getthreads.js index d57a85a96eb..82c28a1409f 100644 --- a/dom/mobilemessage/tests/marionette/test_getthreads.js +++ b/dom/mobilemessage/tests/marionette/test_getthreads.js @@ -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); diff --git a/dom/mobilemessage/tests/marionette/test_incoming.js b/dom/mobilemessage/tests/marionette/test_incoming.js index 8e66b5cab80..64f2bfd60bb 100644 --- a/dom/mobilemessage/tests/marionette/test_incoming.js +++ b/dom/mobilemessage/tests/marionette/test_incoming.js @@ -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; diff --git a/dom/mobilemessage/tests/marionette/test_incoming_delete.js b/dom/mobilemessage/tests/marionette/test_incoming_delete.js index 91ceb7b39a1..77b4a4235e5 100644 --- a/dom/mobilemessage/tests/marionette/test_incoming_delete.js +++ b/dom/mobilemessage/tests/marionette/test_incoming_delete.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js b/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js index 2ab51dc8a8e..1c4b425f166 100644 --- a/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js +++ b/dom/mobilemessage/tests/marionette/test_incoming_max_segments.js @@ -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(); }; diff --git a/dom/mobilemessage/tests/marionette/test_incoming_multipart.js b/dom/mobilemessage/tests/marionette/test_incoming_multipart.js index 6eefef2c650..0a72d1f876a 100644 --- a/dom/mobilemessage/tests/marionette/test_incoming_multipart.js +++ b/dom/mobilemessage/tests/marionette/test_incoming_multipart.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_invalid_address.js b/dom/mobilemessage/tests/marionette/test_invalid_address.js index 4c43f68168f..fed47acd35e 100644 --- a/dom/mobilemessage/tests/marionette/test_invalid_address.js +++ b/dom/mobilemessage/tests/marionette/test_invalid_address.js @@ -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(); }); diff --git a/dom/mobilemessage/tests/marionette/test_mark_msg_read.js b/dom/mobilemessage/tests/marionette/test_mark_msg_read.js index 0829307b7e7..ae41373c80d 100644 --- a/dom/mobilemessage/tests/marionette/test_mark_msg_read.js +++ b/dom/mobilemessage/tests/marionette/test_mark_msg_read.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js b/dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js index c532594d966..5d6bbe85e9e 100644 --- a/dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js +++ b/dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js @@ -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(); diff --git a/dom/mobilemessage/tests/marionette/test_massive_incoming_delete.js b/dom/mobilemessage/tests/marionette/test_massive_incoming_delete.js index 70757c5445b..d6d6081447c 100644 --- a/dom/mobilemessage/tests/marionette/test_massive_incoming_delete.js +++ b/dom/mobilemessage/tests/marionette/test_massive_incoming_delete.js @@ -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!!!"); diff --git a/dom/mobilemessage/tests/marionette/test_message_classes.js b/dom/mobilemessage/tests/marionette/test_message_classes.js index b1663b688d6..cf0366b7d05 100644 --- a/dom/mobilemessage/tests/marionette/test_message_classes.js +++ b/dom/mobilemessage/tests/marionette/test_message_classes.js @@ -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. diff --git a/dom/mobilemessage/tests/marionette/test_mmsmessage_attachments.js b/dom/mobilemessage/tests/marionette/test_mmsmessage_attachments.js index 3a9a8f878f3..3fc87a0502a 100644 --- a/dom/mobilemessage/tests/marionette/test_mmsmessage_attachments.js +++ b/dom/mobilemessage/tests/marionette/test_mmsmessage_attachments.js @@ -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: [], diff --git a/dom/mobilemessage/tests/marionette/test_outgoing.js b/dom/mobilemessage/tests/marionette/test_outgoing.js index bee9d1de4b8..5f15747956d 100644 --- a/dom/mobilemessage/tests/marionette/test_outgoing.js +++ b/dom/mobilemessage/tests/marionette/test_outgoing.js @@ -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); } diff --git a/dom/mobilemessage/tests/marionette/test_outgoing_delete.js b/dom/mobilemessage/tests/marionette/test_outgoing_delete.js index 884ba345fde..200e4a9aad4 100644 --- a/dom/mobilemessage/tests/marionette/test_outgoing_delete.js +++ b/dom/mobilemessage/tests/marionette/test_outgoing_delete.js @@ -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"); diff --git a/dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js b/dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js index abe5bea7094..5ea9219a5f2 100644 --- a/dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js +++ b/dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js @@ -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(); }; diff --git a/dom/mobilemessage/tests/marionette/test_phone_number_normalization.js b/dom/mobilemessage/tests/marionette/test_phone_number_normalization.js index 546a9319c76..9c43a9930c6 100644 --- a/dom/mobilemessage/tests/marionette/test_phone_number_normalization.js +++ b/dom/mobilemessage/tests/marionette/test_phone_number_normalization.js @@ -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(); }); diff --git a/dom/mobilemessage/tests/marionette/test_segment_info.js b/dom/mobilemessage/tests/marionette/test_segment_info.js index 309863303e7..9ebeb512fd7 100644 --- a/dom/mobilemessage/tests/marionette/test_segment_info.js +++ b/dom/mobilemessage/tests/marionette/test_segment_info.js @@ -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"); diff --git a/dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js b/dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js index f4e230aa138..42f184cd0ab 100644 --- a/dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js +++ b/dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js @@ -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"); diff --git a/dom/mobilemessage/tests/marionette/test_update_thread_record_in_delete.js b/dom/mobilemessage/tests/marionette/test_update_thread_record_in_delete.js index 5f2dd5f41e1..071c9cea19f 100644 --- a/dom/mobilemessage/tests/marionette/test_update_thread_record_in_delete.js +++ b/dom/mobilemessage/tests/marionette/test_update_thread_record_in_delete.js @@ -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"); diff --git a/dom/mobilemessage/tests/test_sms_basics.html b/dom/mobilemessage/tests/test_sms_basics.html index 7a3dd3d46ac..c50d53fca00 100644 --- a/dom/mobilemessage/tests/test_sms_basics.html +++ b/dom/mobilemessage/tests/test_sms_basics.html @@ -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"); diff --git a/dom/permission/tests/test_sms.html b/dom/permission/tests/test_sms.html index 98a24f9539f..5a5e11966f0 100644 --- a/dom/permission/tests/test_sms.html +++ b/dom/permission/tests/test_sms.html @@ -20,8 +20,8 @@ var gData = [ { perm: ["sms"], needParentPerm: true, - obj: "mozSms", - idl: "nsIDOMMozSmsManager", + obj: "mozMobileMessage", + idl: "nsIDOMMozMobileMessageManager", settings: [["dom.sms.enabled", true]], }, ] diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index a3112c9ce1a..318e887ec37 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -270,7 +270,6 @@ var interfaceNamesInGlobalScope = "MozSettingsEvent", "MozSmsEvent", "MozSmsFilter", - "MozSmsManager", "MozSmsMessage", "MozSmsSegmentInfo", "MozTimeManager", diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index c7182f2ba0a..e91376080db 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -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 {