summaryrefslogtreecommitdiff
path: root/dom/icc
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2016-09-01 13:39:08 +0200
committerPale Moon <git-repo@palemoon.org>2016-09-01 13:39:08 +0200
commit3d8ce1a11a7347cc94a937719c4bc8df46fb8d14 (patch)
tree8c26ca375a6312751c00a27e1653fb6f189f0463 /dom/icc
parente449bdb1ec3a82f204bffdd9c3c54069d086eee3 (diff)
downloadpalemoon-gre-3d8ce1a11a7347cc94a937719c4bc8df46fb8d14.tar.gz
Base import of Tycho code (warning: huge commit)
Diffstat (limited to 'dom/icc')
-rw-r--r--dom/icc/Assertions.cpp127
-rw-r--r--dom/icc/Icc.cpp430
-rw-r--r--dom/icc/Icc.h126
-rw-r--r--dom/icc/IccCardLockError.cpp45
-rw-r--r--dom/icc/IccCardLockError.h46
-rw-r--r--dom/icc/IccInfo.cpp233
-rw-r--r--dom/icc/IccInfo.h128
-rw-r--r--dom/icc/IccListener.cpp131
-rw-r--r--dom/icc/IccListener.h53
-rw-r--r--dom/icc/IccManager.cpp131
-rw-r--r--dom/icc/IccManager.h64
-rw-r--r--dom/icc/gonk/StkProactiveCmdFactory.jsm1044
-rw-r--r--dom/icc/interfaces/Makefile.in14
-rw-r--r--dom/icc/interfaces/SimToolKit.idl636
-rw-r--r--dom/icc/interfaces/moz.build16
-rw-r--r--dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl24
-rw-r--r--dom/icc/interfaces/nsIDOMIccManager.idl490
-rw-r--r--dom/icc/interfaces/nsIIccInfo.idl70
-rw-r--r--dom/icc/interfaces/nsIIccMessenger.idl660
-rw-r--r--dom/icc/interfaces/nsIIccProvider.idl241
-rw-r--r--dom/icc/interfaces/nsINavigatorIccManager.idl16
-rw-r--r--dom/icc/moz.build34
-rw-r--r--dom/icc/src/IccManager.cpp249
-rw-r--r--dom/icc/src/IccManager.h49
-rw-r--r--dom/icc/src/Makefile.in25
-rw-r--r--dom/icc/src/StkCommandEvent.cpp51
-rw-r--r--dom/icc/src/StkCommandEvent.h78
-rw-r--r--dom/icc/src/moz.build15
-rw-r--r--dom/icc/tests/marionette/head.js459
-rw-r--r--dom/icc/tests/marionette/manifest.ini18
-rw-r--r--dom/icc/tests/marionette/test_icc_access_invalid_object.js101
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock.js115
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock_change_pin.js45
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock_enable_pin.js59
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock_get_retry_count.js44
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock_unlock_pin.js68
-rw-r--r--dom/icc/tests/marionette/test_icc_card_lock_unlock_puk.js97
-rw-r--r--dom/icc/tests/marionette/test_icc_card_state.js32
-rw-r--r--dom/icc/tests/marionette/test_icc_contact.js185
-rw-r--r--dom/icc/tests/marionette/test_icc_detected_undetected_event.js51
-rw-r--r--dom/icc/tests/marionette/test_icc_info.js64
-rw-r--r--dom/icc/tests/marionette/test_icc_match_mvno.js57
-rw-r--r--dom/icc/tests/marionette/test_icc_service_state.js28
-rw-r--r--dom/icc/tests/marionette/test_stk_bip_command.js137
-rw-r--r--dom/icc/tests/marionette/test_stk_display_text.js326
-rw-r--r--dom/icc/tests/marionette/test_stk_get_inkey.js265
-rw-r--r--dom/icc/tests/marionette/test_stk_get_input.js336
-rw-r--r--dom/icc/tests/marionette/test_stk_launch_browser.js412
-rw-r--r--dom/icc/tests/marionette/test_stk_local_info.js69
-rw-r--r--dom/icc/tests/marionette/test_stk_play_tone.js120
-rw-r--r--dom/icc/tests/marionette/test_stk_poll_interval.js68
-rw-r--r--dom/icc/tests/marionette/test_stk_poll_off.js91
-rw-r--r--dom/icc/tests/marionette/test_stk_proactive_command.js244
-rw-r--r--dom/icc/tests/marionette/test_stk_refresh.js104
-rw-r--r--dom/icc/tests/marionette/test_stk_select_item.js641
-rw-r--r--dom/icc/tests/marionette/test_stk_send_dtmf.js307
-rw-r--r--dom/icc/tests/marionette/test_stk_send_sms.js461
-rw-r--r--dom/icc/tests/marionette/test_stk_send_ss.js349
-rw-r--r--dom/icc/tests/marionette/test_stk_send_ussd.js392
-rw-r--r--dom/icc/tests/marionette/test_stk_setup_call.js492
-rw-r--r--dom/icc/tests/marionette/test_stk_setup_event_list.js138
-rw-r--r--dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js316
-rw-r--r--dom/icc/tests/marionette/test_stk_setup_menu.js510
-rw-r--r--dom/icc/tests/marionette/test_stk_timer_management.js76
-rw-r--r--dom/icc/tests/moz.build8
65 files changed, 7518 insertions, 4993 deletions
diff --git a/dom/icc/Assertions.cpp b/dom/icc/Assertions.cpp
new file mode 100644
index 000000000..0f9c7a07a
--- /dev/null
+++ b/dom/icc/Assertions.cpp
@@ -0,0 +1,127 @@
+/* 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 "mozilla/dom/MozIccBinding.h"
+#include "nsIIccProvider.h"
+
+namespace mozilla {
+namespace dom {
+namespace icc {
+
+#define ASSERT_EQUALITY(webidlType, webidlState, xpidlState) \
+ static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsIIccProvider::xpidlState, \
+ #webidlType "::" #webidlState " should equal to nsIIccProvider::" #xpidlState)
+
+/**
+ * Enum IccCardState
+ */
+#define ASSERT_ICC_CARD_STATE_EQUALITY(webidlState, xpidlState) \
+ ASSERT_EQUALITY(IccCardState, webidlState, xpidlState)
+
+ASSERT_ICC_CARD_STATE_EQUALITY(Unknown, CARD_STATE_UNKNOWN);
+ASSERT_ICC_CARD_STATE_EQUALITY(Ready, CARD_STATE_READY);
+ASSERT_ICC_CARD_STATE_EQUALITY(PinRequired, CARD_STATE_PIN_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(PukRequired, CARD_STATE_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(PermanentBlocked, CARD_STATE_PERMANENT_BLOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(PersonalizationInProgress, CARD_STATE_PERSONALIZATION_IN_PROGRESS);
+ASSERT_ICC_CARD_STATE_EQUALITY(PersonalizationReady, CARD_STATE_PERSONALIZATION_READY);
+ASSERT_ICC_CARD_STATE_EQUALITY(NetworkLocked, CARD_STATE_NETWORK_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(NetworkSubsetLocked, CARD_STATE_NETWORK_SUBSET_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(CorporateLocked, CARD_STATE_CORPORATE_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(ServiceProviderLocked, CARD_STATE_SERVICE_PROVIDER_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(SimPersonalizationLocked, CARD_STATE_SIM_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(NetworkPukRequired, CARD_STATE_NETWORK_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(NetworkSubsetPukRequired, CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(CorporatePukRequired, CARD_STATE_CORPORATE_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(ServiceProviderPukRequired, CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(SimPersonalizationPukRequired, CARD_STATE_SIM_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(Network1Locked, CARD_STATE_NETWORK1_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(Network2Locked, CARD_STATE_NETWORK2_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(HrpdNetworkLocked, CARD_STATE_HRPD_NETWORK_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimCorporateLocked, CARD_STATE_RUIM_CORPORATE_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimServiceProviderLocked, CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimPersonalizationLocked, CARD_STATE_RUIM_LOCKED);
+ASSERT_ICC_CARD_STATE_EQUALITY(Network1PukRequired, CARD_STATE_NETWORK1_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(Network2PukRequired, CARD_STATE_NETWORK2_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(HrpdNetworkPukRequired, CARD_STATE_HRPD_NETWORK_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimCorporatePukRequired, CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimServiceProviderPukRequired, CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(RuimPersonalizationPukRequired, CARD_STATE_RUIM_PUK_REQUIRED);
+ASSERT_ICC_CARD_STATE_EQUALITY(Illegal, CARD_STATE_ILLEGAL);
+
+#undef ASSERT_ICC_CARD_STATE_EQUALITY
+
+/**
+ * Enum IccLockType
+ */
+#define ASSERT_ICC_LOCK_TYPE_EQUALITY(webidlState, xpidlState) \
+ ASSERT_EQUALITY(IccLockType, webidlState, xpidlState)
+
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Pin, CARD_LOCK_TYPE_PIN);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Pin2, CARD_LOCK_TYPE_PIN2);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Puk, CARD_LOCK_TYPE_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Puk2, CARD_LOCK_TYPE_PUK2);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nck, CARD_LOCK_TYPE_NCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nsck, CARD_LOCK_TYPE_NSCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nck1, CARD_LOCK_TYPE_NCK1);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nck2, CARD_LOCK_TYPE_NCK2);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Hnck, CARD_LOCK_TYPE_HNCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Cck, CARD_LOCK_TYPE_CCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Spck, CARD_LOCK_TYPE_SPCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Pck, CARD_LOCK_TYPE_PCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Rcck, CARD_LOCK_TYPE_RCCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Rspck, CARD_LOCK_TYPE_RSPCK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(NckPuk, CARD_LOCK_TYPE_NCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(NsckPuk, CARD_LOCK_TYPE_NSCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nck1Puk, CARD_LOCK_TYPE_NCK1_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Nck2Puk, CARD_LOCK_TYPE_NCK2_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(HnckPuk, CARD_LOCK_TYPE_HNCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(CckPuk, CARD_LOCK_TYPE_CCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(SpckPuk, CARD_LOCK_TYPE_SPCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(PckPuk, CARD_LOCK_TYPE_PCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(RcckPuk, CARD_LOCK_TYPE_RCCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(RspckPuk, CARD_LOCK_TYPE_RSPCK_PUK);
+ASSERT_ICC_LOCK_TYPE_EQUALITY(Fdn, CARD_LOCK_TYPE_FDN);
+
+#undef ASSERT_ICC_LOCK_TYPE_EQUALITY
+
+/**
+ * Enum IccContactType
+ */
+#define ASSERT_ICC_CONTACT_TYPE_EQUALITY(webidlState, xpidlState) \
+ ASSERT_EQUALITY(IccContactType, webidlState, xpidlState)
+
+ASSERT_ICC_CONTACT_TYPE_EQUALITY(Adn, CARD_CONTACT_TYPE_ADN);
+ASSERT_ICC_CONTACT_TYPE_EQUALITY(Fdn, CARD_CONTACT_TYPE_FDN);
+ASSERT_ICC_CONTACT_TYPE_EQUALITY(Sdn, CARD_CONTACT_TYPE_SDN);
+
+#undef ASSERT_ICC_CONTACT_TYPE_EQUALITY
+
+/**
+ * Enum IccMvnoType
+ */
+#define ASSERT_ICC_MVNO_TYPE_EQUALITY(webidlState, xpidlState) \
+ ASSERT_EQUALITY(IccMvnoType, webidlState, xpidlState)
+
+ASSERT_ICC_MVNO_TYPE_EQUALITY(Imsi, CARD_MVNO_TYPE_IMSI);
+ASSERT_ICC_MVNO_TYPE_EQUALITY(Spn, CARD_MVNO_TYPE_SPN);
+ASSERT_ICC_MVNO_TYPE_EQUALITY(Gid, CARD_MVNO_TYPE_GID);
+
+#undef ASSERT_ICC_MVNO_TYPE_EQUALITY
+
+/**
+ * Enum IccService
+ */
+#define ASSERT_ICC_SERVICE_EQUALITY(webidlState, xpidlState) \
+ ASSERT_EQUALITY(IccService, webidlState, xpidlState)
+
+ASSERT_ICC_SERVICE_EQUALITY(Fdn, CARD_SERVICE_FDN);
+
+#undef ASSERT_ICC_SERVICE_EQUALITY
+
+#undef ASSERT_EQUALITY
+
+} // namespace icc
+} // namespace dom
+} // namespace mozilla
diff --git a/dom/icc/Icc.cpp b/dom/icc/Icc.cpp
new file mode 100644
index 000000000..93a7d01c7
--- /dev/null
+++ b/dom/icc/Icc.cpp
@@ -0,0 +1,430 @@
+/* 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 "mozilla/dom/Icc.h"
+
+#include "mozilla/dom/DOMRequest.h"
+#include "mozilla/dom/IccInfo.h"
+#include "mozilla/dom/MozStkCommandEvent.h"
+#include "mozilla/dom/Promise.h"
+#include "mozilla/dom/ScriptSettings.h"
+#include "nsIIccInfo.h"
+#include "nsIIccProvider.h"
+#include "nsJSON.h"
+#include "nsRadioInterfaceLayer.h"
+#include "nsServiceManagerUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+namespace {
+
+bool
+IsPukCardLockType(IccLockType aLockType)
+{
+ switch(aLockType) {
+ case IccLockType::Puk:
+ case IccLockType::Puk2:
+ case IccLockType::NckPuk:
+ case IccLockType::Nck1Puk:
+ case IccLockType::Nck2Puk:
+ case IccLockType::HnckPuk:
+ case IccLockType::CckPuk:
+ case IccLockType::SpckPuk:
+ case IccLockType::RcckPuk:
+ case IccLockType::RspckPuk:
+ return true;
+ default:
+ return false;
+ }
+}
+
+} // anonymous namespace
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED(Icc, DOMEventTargetHelper, mIccInfo)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Icc)
+NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
+
+NS_IMPL_ADDREF_INHERITED(Icc, DOMEventTargetHelper)
+NS_IMPL_RELEASE_INHERITED(Icc, DOMEventTargetHelper)
+
+Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo)
+ : mLive(true)
+ , mClientId(aClientId)
+{
+ BindToOwner(aWindow);
+
+ mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+
+ if (aIccInfo) {
+ aIccInfo->GetIccid(mIccId);
+ UpdateIccInfo(aIccInfo);
+ }
+
+ // Not being able to acquire the provider isn't fatal since we check
+ // for it explicitly below.
+ if (!mProvider) {
+ NS_WARNING("Could not acquire nsIIccProvider!");
+ }
+}
+
+void
+Icc::Shutdown()
+{
+ mIccInfo.SetNull();
+ mProvider = nullptr;
+ mLive = false;
+}
+
+nsresult
+Icc::NotifyEvent(const nsAString& aName)
+{
+ return DispatchTrustedEvent(aName);
+}
+
+nsresult
+Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage)
+{
+ AutoJSAPI jsapi;
+ if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetOwner()))) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ JSContext* cx = jsapi.cx();
+ JS::Rooted<JS::Value> value(cx);
+
+ if (!aMessage.IsEmpty()) {
+ nsCOMPtr<nsIJSON> json(new nsJSON());
+ nsresult rv = json->DecodeToJSVal(aMessage, cx, &value);
+ NS_ENSURE_SUCCESS(rv, rv);
+ } else {
+ value = JS::NullValue();
+ }
+
+ MozStkCommandEventInit init;
+ init.mBubbles = false;
+ init.mCancelable = false;
+ init.mCommand = value;
+
+ nsRefPtr<MozStkCommandEvent> event =
+ MozStkCommandEvent::Constructor(this, aName, init);
+
+ return DispatchTrustedEvent(event);
+}
+
+void
+Icc::UpdateIccInfo(nsIIccInfo* aIccInfo)
+{
+ if (!aIccInfo) {
+ mIccInfo.SetNull();
+ return;
+ }
+
+ nsCOMPtr<nsIGsmIccInfo> gsmIccInfo(do_QueryInterface(aIccInfo));
+ if (gsmIccInfo) {
+ if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozGsmIccInfo()) {
+ mIccInfo.SetValue().SetAsMozGsmIccInfo() = new GsmIccInfo(GetOwner());
+ }
+ mIccInfo.Value().GetAsMozGsmIccInfo().get()->Update(gsmIccInfo);
+ return;
+ }
+
+ nsCOMPtr<nsICdmaIccInfo> cdmaIccInfo(do_QueryInterface(aIccInfo));
+ if (cdmaIccInfo) {
+ if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozCdmaIccInfo()) {
+ mIccInfo.SetValue().SetAsMozCdmaIccInfo() = new CdmaIccInfo(GetOwner());
+ }
+ mIccInfo.Value().GetAsMozCdmaIccInfo().get()->Update(cdmaIccInfo);
+ return;
+ }
+
+ if (mIccInfo.IsNull() || !mIccInfo.Value().IsMozIccInfo()) {
+ mIccInfo.SetValue().SetAsMozIccInfo() = new IccInfo(GetOwner());
+ }
+ mIccInfo.Value().GetAsMozIccInfo().get()->Update(aIccInfo);
+}
+
+// WrapperCache
+
+JSObject*
+Icc::WrapObject(JSContext* aCx)
+{
+ return MozIccBinding::Wrap(aCx, this);
+}
+
+// MozIcc WebIDL
+
+void
+Icc::GetIccInfo(Nullable<OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo>& aIccInfo) const
+{
+ aIccInfo = mIccInfo;
+}
+
+Nullable<IccCardState>
+Icc::GetCardState() const
+{
+ Nullable<IccCardState> result;
+
+ uint32_t cardState = nsIIccProvider::CARD_STATE_UNDETECTED;
+ if (mProvider &&
+ NS_SUCCEEDED(mProvider->GetCardState(mClientId, &cardState)) &&
+ cardState != nsIIccProvider::CARD_STATE_UNDETECTED) {
+ MOZ_ASSERT(cardState < static_cast<uint32_t>(IccCardState::EndGuard_));
+ result.SetValue(static_cast<IccCardState>(cardState));
+ }
+
+ return result;
+}
+
+void
+Icc::SendStkResponse(const JSContext* aCx, JS::Handle<JS::Value> aCommand,
+ JS::Handle<JS::Value> aResponse, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return;
+ }
+
+ nsresult rv = mProvider->SendStkResponse(mClientId, GetOwner(), aCommand,
+ aResponse);
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ }
+}
+
+void
+Icc::SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested,
+ ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return;
+ }
+
+ nsresult rv = mProvider->SendStkMenuSelection(mClientId,
+ GetOwner(),
+ aItemIdentifier,
+ aHelpRequested);
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ }
+}
+
+void
+Icc::SendStkTimerExpiration(const JSContext* aCx, JS::Handle<JS::Value> aTimer,
+ ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return;
+ }
+
+ nsresult rv = mProvider->SendStkTimerExpiration(mClientId, GetOwner(),
+ aTimer);
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ }
+}
+
+void
+Icc::SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
+ ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return;
+ }
+
+ nsresult rv = mProvider->SendStkEventDownload(mClientId, GetOwner(), aEvent);
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ }
+}
+
+already_AddRefed<DOMRequest>
+Icc::GetCardLock(IccLockType aLockType, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ nsresult rv = mProvider->GetCardLockEnabled(mClientId, GetOwner(),
+ static_cast<uint32_t>(aLockType),
+ getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::UnlockCardLock(const IccUnlockCardLockOptions& aOptions, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ const nsString& password = IsPukCardLockType(aOptions.mLockType)
+ ? aOptions.mPuk : aOptions.mPin;
+ nsresult rv = mProvider->UnlockCardLock(mClientId, GetOwner(),
+ static_cast<uint32_t>(aOptions.mLockType),
+ password, aOptions.mNewPin,
+ getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsresult rv;
+ nsRefPtr<nsIDOMDOMRequest> request;
+
+ if (aOptions.mEnabled.WasPassed()) {
+ // Enable card lock.
+ const nsString& password = (aOptions.mLockType == IccLockType::Fdn) ?
+ aOptions.mPin2 : aOptions.mPin;
+
+ rv = mProvider->SetCardLockEnabled(mClientId, GetOwner(),
+ static_cast<uint32_t>(aOptions.mLockType),
+ password, aOptions.mEnabled.Value(),
+ getter_AddRefs(request));
+ } else {
+ // Change card lock password.
+ rv = mProvider->ChangeCardLockPassword(mClientId, GetOwner(),
+ static_cast<uint32_t>(aOptions.mLockType),
+ aOptions.mPin, aOptions.mNewPin,
+ getter_AddRefs(request));
+ }
+
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::GetCardLockRetryCount(IccLockType aLockType, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ nsresult rv = mProvider->GetCardLockRetryCount(mClientId, GetOwner(),
+ static_cast<uint32_t>(aLockType),
+ getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::ReadContacts(IccContactType aContactType, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ nsresult rv = mProvider->ReadContacts(mClientId, GetOwner(),
+ static_cast<uint32_t>(aContactType),
+ getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::UpdateContact(const JSContext* aCx, IccContactType aContactType,
+ JS::Handle<JS::Value> aContact, const nsAString& aPin2,
+ ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ nsresult rv = mProvider->UpdateContact(mClientId, GetOwner(),
+ static_cast<uint32_t>(aContactType),
+ aContact, aPin2,
+ getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<DOMRequest>
+Icc::MatchMvno(IccMvnoType aMvnoType, const nsAString& aMvnoData,
+ ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<nsIDOMDOMRequest> request;
+ nsresult rv = mProvider->MatchMvno(mClientId, GetOwner(),
+ static_cast<uint32_t>(aMvnoType),
+ aMvnoData, getter_AddRefs(request));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ return request.forget().downcast<DOMRequest>();
+}
+
+already_AddRefed<Promise>
+Icc::GetServiceState(IccService aService, ErrorResult& aRv)
+{
+ if (!mProvider) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsCOMPtr<nsISupports> supports;
+ nsresult rv = mProvider->GetServiceState(mClientId, GetOwner(),
+ static_cast<uint32_t>(aService),
+ getter_AddRefs(supports));
+ if (NS_FAILED(rv)) {
+ aRv.Throw(rv);
+ return nullptr;
+ }
+
+ nsCOMPtr<Promise> promise = do_QueryInterface(supports);
+ return promise.forget();
+}
+
+} // namespace dom
+} // namespace mozilla
diff --git a/dom/icc/Icc.h b/dom/icc/Icc.h
new file mode 100644
index 000000000..a0de29b37
--- /dev/null
+++ b/dom/icc/Icc.h
@@ -0,0 +1,126 @@
+/* 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_Icc_h
+#define mozilla_dom_Icc_h
+
+#include "mozilla/dom/MozIccBinding.h"
+#include "mozilla/DOMEventTargetHelper.h"
+
+class nsIIccInfo;
+class nsIIccProvider;
+
+namespace mozilla {
+namespace dom {
+
+class DOMRequest;
+class OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo;
+class Promise;
+
+class Icc final : public DOMEventTargetHelper
+{
+public:
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Icc, DOMEventTargetHelper)
+ NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
+
+ Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo);
+
+ void
+ Shutdown();
+
+ nsresult
+ NotifyEvent(const nsAString& aName);
+
+ nsresult
+ NotifyStkEvent(const nsAString& aName, const nsAString& aMessage);
+
+ nsString
+ GetIccId()
+ {
+ return mIccId;
+ }
+
+ void
+ UpdateIccInfo(nsIIccInfo* aIccInfo);
+
+ nsPIDOMWindow*
+ GetParentObject() const
+ {
+ return GetOwner();
+ }
+
+ // WrapperCache
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+ // MozIcc WebIDL
+ void
+ GetIccInfo(Nullable<OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo>& aIccInfo) const;
+
+ Nullable<IccCardState>
+ GetCardState() const;
+
+ void
+ SendStkResponse(const JSContext* aCx, JS::Handle<JS::Value> aCommand,
+ JS::Handle<JS::Value> aResponse, ErrorResult& aRv);
+
+ void
+ SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested,
+ ErrorResult& aRv);
+
+ void
+ SendStkTimerExpiration(const JSContext* aCx, JS::Handle<JS::Value> aTimer,
+ ErrorResult& aRv);
+
+ void
+ SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
+ ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ GetCardLock(IccLockType aLockType, ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ UnlockCardLock(const IccUnlockCardLockOptions& aOptions, ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ GetCardLockRetryCount(IccLockType aLockType, ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ ReadContacts(IccContactType aContactType, ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ UpdateContact(const JSContext* aCx, IccContactType aContactType,
+ JS::Handle<JS::Value> aContact, const nsAString& aPin2,
+ ErrorResult& aRv);
+
+ already_AddRefed<DOMRequest>
+ MatchMvno(IccMvnoType aMvnoType, const nsAString& aMatchData,
+ ErrorResult& aRv);
+
+ already_AddRefed<Promise>
+ GetServiceState(IccService aService, ErrorResult& aRv);
+
+ IMPL_EVENT_HANDLER(iccinfochange)
+ IMPL_EVENT_HANDLER(cardstatechange)
+ IMPL_EVENT_HANDLER(stkcommand)
+ IMPL_EVENT_HANDLER(stksessionend)
+
+private:
+ bool mLive;
+ uint32_t mClientId;
+ nsString mIccId;
+ // mProvider is a xpcom service and will be released at shutdown, so it
+ // doesn't need to be cycle collected.
+ nsCOMPtr<nsIIccProvider> mProvider;
+ Nullable<OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo> mIccInfo;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_icc_Icc_h
diff --git a/dom/icc/IccCardLockError.cpp b/dom/icc/IccCardLockError.cpp
new file mode 100644
index 000000000..6bad24f7c
--- /dev/null
+++ b/dom/icc/IccCardLockError.cpp
@@ -0,0 +1,45 @@
+/* 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 "mozilla/dom/IccCardLockError.h"
+#include "mozilla/dom/IccCardLockErrorBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_ISUPPORTS_INHERITED0(IccCardLockError, DOMError)
+
+/* static */ already_AddRefed<IccCardLockError>
+IccCardLockError::Constructor(const GlobalObject& aGlobal,
+ const nsAString& aName,
+ int16_t aRetryCount,
+ ErrorResult& aRv)
+{
+ nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+ if (!window) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
+ nsRefPtr<IccCardLockError> result =
+ new IccCardLockError(window, aName, aRetryCount);
+ return result.forget();
+}
+
+IccCardLockError::IccCardLockError(nsPIDOMWindow* aWindow,
+ const nsAString& aName,
+ int16_t aRetryCount)
+ : DOMError(aWindow, aName)
+ , mRetryCount(aRetryCount)
+{
+}
+
+JSObject*
+IccCardLockError::WrapObject(JSContext* aCx)
+{
+ return IccCardLockErrorBinding::Wrap(aCx, this);
+}
+
+} // namespace dom
+} // namespace mozilla
diff --git a/dom/icc/IccCardLockError.h b/dom/icc/IccCardLockError.h
new file mode 100644
index 000000000..c4e87058c
--- /dev/null
+++ b/dom/icc/IccCardLockError.h
@@ -0,0 +1,46 @@
+/* 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_IccCardLockError_h
+#define mozilla_dom_IccCardLockError_h
+
+#include "mozilla/dom/DOMError.h"
+
+namespace mozilla {
+namespace dom {
+
+class IccCardLockError final : public DOMError
+{
+public:
+ NS_DECL_ISUPPORTS_INHERITED
+
+ IccCardLockError(nsPIDOMWindow* aWindow, const nsAString& aName,
+ int16_t aRetryCount);
+
+ static already_AddRefed<IccCardLockError>
+ Constructor(const GlobalObject& aGlobal, const nsAString& aName,
+ int16_t aRetryCount, ErrorResult& aRv);
+
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+ // WebIDL interface
+
+ int16_t
+ RetryCount() const
+ {
+ return mRetryCount;
+ }
+
+private:
+ ~IccCardLockError() {}
+
+private:
+ int16_t mRetryCount;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_IccCardLockError_h
diff --git a/dom/icc/IccInfo.cpp b/dom/icc/IccInfo.cpp
new file mode 100644
index 000000000..cbe4493c8
--- /dev/null
+++ b/dom/icc/IccInfo.cpp
@@ -0,0 +1,233 @@
+/* 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 "mozilla/dom/IccInfo.h"
+
+#include "nsPIDOMWindow.h"
+
+#define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum) \
+{ \
+ uint32_t i = 0; \
+ for (const EnumEntry* entry = _enumType##Values::strings; \
+ entry->value; \
+ ++entry, ++i) { \
+ if (_string.EqualsASCII(entry->value)) { \
+ _enum.SetValue(static_cast<_enumType>(i)); \
+ } \
+ } \
+}
+
+using namespace mozilla::dom;
+
+// IccInfo
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IccInfo, mWindow, mIccInfo)
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(IccInfo)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(IccInfo)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IccInfo)
+ NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+ NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+IccInfo::IccInfo(nsPIDOMWindow* aWindow)
+ : mWindow(aWindow)
+{
+}
+
+void
+IccInfo::Update(nsIIccInfo* aInfo)
+{
+ mIccInfo = aInfo;
+}
+
+JSObject*
+IccInfo::WrapObject(JSContext* aCx)
+{
+ return MozIccInfoBinding::Wrap(aCx, this);
+}
+
+Nullable<IccType>
+IccInfo::GetIccType() const
+{
+ if (!mIccInfo) {
+ return Nullable<IccType>();
+ }
+
+ nsAutoString type;
+ Nullable<IccType> iccType;
+
+ mIccInfo->GetIccType(type);
+ CONVERT_STRING_TO_NULLABLE_ENUM(type, IccType, iccType);
+
+ return iccType;
+}
+
+void
+IccInfo::GetIccid(nsAString& aIccId) const
+{
+ if (!mIccInfo) {
+ aIccId.SetIsVoid(true);
+ return;
+ }
+
+ mIccInfo->GetIccid(aIccId);
+}
+
+void
+IccInfo::GetMcc(nsAString& aMcc) const
+{
+ if (!mIccInfo) {
+ aMcc.SetIsVoid(true);
+ return;
+ }
+
+ mIccInfo->GetMcc(aMcc);
+}
+
+void
+IccInfo::GetMnc(nsAString& aMnc) const
+{
+ if (!mIccInfo) {
+ aMnc.SetIsVoid(true);
+ return;
+ }
+
+ mIccInfo->GetMnc(aMnc);
+}
+
+void
+IccInfo::GetSpn(nsAString& aSpn) const
+{
+ if (!mIccInfo) {
+ aSpn.SetIsVoid(true);
+ return;
+ }
+
+ mIccInfo->GetSpn(aSpn);
+}
+
+bool
+IccInfo::IsDisplayNetworkNameRequired() const
+{
+ if (!mIccInfo) {
+ return false;
+ }
+
+ bool isDisplayNetworkNameRequired;
+ mIccInfo->GetIsDisplayNetworkNameRequired(&isDisplayNetworkNameRequired);
+
+ return isDisplayNetworkNameRequired;
+}
+
+bool
+IccInfo::IsDisplaySpnRequired() const
+{
+ if (!mIccInfo) {
+ return false;
+ }
+
+ bool isDisplaySpnRequired;
+ mIccInfo->GetIsDisplaySpnRequired(&isDisplaySpnRequired);
+
+ return isDisplaySpnRequired;
+}
+
+// GsmIccInfo
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED(GsmIccInfo, IccInfo, mGsmIccInfo)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GsmIccInfo)
+NS_INTERFACE_MAP_END_INHERITING(IccInfo)
+
+NS_IMPL_ADDREF_INHERITED(GsmIccInfo, IccInfo)
+NS_IMPL_RELEASE_INHERITED(GsmIccInfo, IccInfo)
+
+GsmIccInfo::GsmIccInfo(nsPIDOMWindow* aWindow)
+ : IccInfo(aWindow)
+{
+}
+
+void
+GsmIccInfo::Update(nsIGsmIccInfo* aInfo)
+{
+ nsCOMPtr<nsIIccInfo> iccInfo = do_QueryInterface(aInfo);
+ MOZ_ASSERT(iccInfo);
+
+ IccInfo::Update(iccInfo);
+ mGsmIccInfo = aInfo;
+}
+
+JSObject*
+GsmIccInfo::WrapObject(JSContext* aCx)
+{
+ return MozGsmIccInfoBinding::Wrap(aCx, this);
+}
+
+void
+GsmIccInfo::GetMsisdn(nsAString& aMsisdn) const
+{
+ if (!mGsmIccInfo) {
+ aMsisdn.SetIsVoid(true);
+ return;
+ }
+
+ mGsmIccInfo->GetMsisdn(aMsisdn);
+}
+
+// CdmaIccInfo
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED(CdmaIccInfo, IccInfo, mCdmaIccInfo)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CdmaIccInfo)
+NS_INTERFACE_MAP_END_INHERITING(IccInfo)
+
+NS_IMPL_ADDREF_INHERITED(CdmaIccInfo, IccInfo)
+NS_IMPL_RELEASE_INHERITED(CdmaIccInfo, IccInfo)
+
+CdmaIccInfo::CdmaIccInfo(nsPIDOMWindow* aWindow)
+ : IccInfo(aWindow)
+{
+}
+
+void
+CdmaIccInfo::Update(nsICdmaIccInfo* aInfo)
+{
+ nsCOMPtr<nsIIccInfo> iccInfo = do_QueryInterface(aInfo);
+ MOZ_ASSERT(iccInfo);
+
+ IccInfo::Update(iccInfo);
+ mCdmaIccInfo = aInfo;
+}
+
+JSObject*
+CdmaIccInfo::WrapObject(JSContext* aCx)
+{
+ return MozCdmaIccInfoBinding::Wrap(aCx, this);
+}
+
+void
+CdmaIccInfo::GetMdn(nsAString& aMdn) const
+{
+ if (!mCdmaIccInfo) {
+ aMdn.SetIsVoid(true);
+ return;
+ }
+
+ mCdmaIccInfo->GetMdn(aMdn);
+}
+
+int32_t
+CdmaIccInfo::PrlVersion() const
+{
+ if (!mCdmaIccInfo) {
+ return 0;
+ }
+
+ int32_t prlVersion;
+ mCdmaIccInfo->GetPrlVersion(&prlVersion);
+
+ return prlVersion;
+}
diff --git a/dom/icc/IccInfo.h b/dom/icc/IccInfo.h
new file mode 100644
index 000000000..725b2163a
--- /dev/null
+++ b/dom/icc/IccInfo.h
@@ -0,0 +1,128 @@
+/* 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_IccInfo_h
+#define mozilla_dom_IccInfo_h
+
+#include "MozIccInfoBinding.h"
+#include "nsIIccInfo.h"
+#include "nsWrapperCache.h"
+
+class nsPIDOMWindow;
+
+namespace mozilla {
+namespace dom {
+
+class IccInfo : public nsISupports
+ , public nsWrapperCache
+{
+public:
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IccInfo)
+
+ explicit IccInfo(nsPIDOMWindow* aWindow);
+
+ void
+ Update(nsIIccInfo* aInfo);
+
+ nsPIDOMWindow*
+ GetParentObject() const
+ {
+ return mWindow;
+ }
+
+ // WrapperCache
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+ // WebIDL interface
+ Nullable<IccType>
+ GetIccType() const;
+
+ void
+ GetIccid(nsAString& aIccId) const;
+
+ void
+ GetMcc(nsAString& aMcc) const;
+
+ void
+ GetMnc(nsAString& aMnc) const;
+
+ void
+ GetSpn(nsAString& aSpn) const;
+
+ bool
+ IsDisplayNetworkNameRequired() const;
+
+ bool
+ IsDisplaySpnRequired() const;
+
+protected:
+ virtual ~IccInfo() {}
+
+protected:
+ nsCOMPtr<nsPIDOMWindow> mWindow;
+ nsCOMPtr<nsIIccInfo> mIccInfo;
+};
+
+class GsmIccInfo final : public IccInfo
+{
+public:
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GsmIccInfo, IccInfo)
+
+ explicit GsmIccInfo(nsPIDOMWindow* aWindow);
+
+ void
+ Update(nsIGsmIccInfo* aInfo);
+
+ // WrapperCache
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+ // MozCdmaIccInfo WebIDL
+ void
+ GetMsisdn(nsAString& aMsisdn) const;
+
+private:
+ ~GsmIccInfo() {}
+
+private:
+ nsCOMPtr<nsIGsmIccInfo> mGsmIccInfo;
+};
+
+class CdmaIccInfo final : public IccInfo
+{
+public:
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CdmaIccInfo, IccInfo)
+
+ explicit CdmaIccInfo(nsPIDOMWindow* aWindow);
+
+ void
+ Update(nsICdmaIccInfo* aInfo);
+
+ // WrapperCache
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+ // MozCdmaIccInfo WebIDL
+ void
+ GetMdn(nsAString& aMdn) const;
+
+ int32_t
+ PrlVersion() const;
+
+private:
+ ~CdmaIccInfo() {}
+
+private:
+ nsCOMPtr<nsICdmaIccInfo> mCdmaIccInfo;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_IccInfo_h
+
diff --git a/dom/icc/IccListener.cpp b/dom/icc/IccListener.cpp
new file mode 100644
index 000000000..911974c9b
--- /dev/null
+++ b/dom/icc/IccListener.cpp
@@ -0,0 +1,131 @@
+/* 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 "IccListener.h"
+
+#include "Icc.h"
+#include "IccManager.h"
+#include "nsIDOMClassInfo.h"
+#include "nsIIccInfo.h"
+#include "nsRadioInterfaceLayer.h"
+
+using namespace mozilla::dom;
+
+NS_IMPL_ISUPPORTS(IccListener, nsIIccListener)
+
+IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
+ : mClientId(aClientId)
+ , mIccManager(aIccManager)
+{
+ MOZ_ASSERT(mIccManager);
+
+ mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+
+ if (!mProvider) {
+ NS_WARNING("Could not acquire nsIIccProvider!");
+ return;
+ }
+
+ nsCOMPtr<nsIIccInfo> iccInfo;
+ mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
+ if (iccInfo) {
+ nsString iccId;
+ iccInfo->GetIccid(iccId);
+ if (!iccId.IsEmpty()) {
+ mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
+ }
+ }
+
+ DebugOnly<nsresult> rv = mProvider->RegisterIccMsg(mClientId, this);
+ NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
+ "Failed registering icc messages with provider");
+}
+
+IccListener::~IccListener()
+{
+ Shutdown();
+}
+
+void
+IccListener::Shutdown()
+{
+ if (mProvider) {
+ mProvider->UnregisterIccMsg(mClientId, this);
+ mProvider = nullptr;
+ }
+
+ if (mIcc) {
+ mIcc->Shutdown();
+ mIcc = nullptr;
+ }
+
+ mIccManager = nullptr;
+}
+
+// nsIIccListener
+
+NS_IMETHODIMP
+IccListener::NotifyStkCommand(const nsAString& aMessage)
+{
+ if (!mIcc) {
+ return NS_OK;
+ }
+
+ return mIcc->NotifyStkEvent(NS_LITERAL_STRING("stkcommand"), aMessage);
+}
+
+NS_IMETHODIMP
+IccListener::NotifyStkSessionEnd()
+{
+ if (!mIcc) {
+ return NS_OK;
+ }
+
+ return mIcc->NotifyEvent(NS_LITERAL_STRING("stksessionend"));
+}
+
+NS_IMETHODIMP
+IccListener::NotifyCardStateChanged()
+{
+ if (!mIcc) {
+ return NS_OK;
+ }
+
+ return mIcc->NotifyEvent(NS_LITERAL_STRING("cardstatechange"));
+}
+
+NS_IMETHODIMP
+IccListener::NotifyIccInfoChanged()
+{
+ nsCOMPtr<nsIIccInfo> iccInfo;
+ mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
+
+ // Create/delete icc object based on current iccInfo.
+ // 1. If the mIcc is nullptr and iccInfo has valid data, create icc object and
+ // notify mIccManager a new icc is added.
+ // 2. If the mIcc is not nullptr and iccInfo becomes to null, delete existed
+ // icc object and notify mIccManager the icc is removed.
+ if (!mIcc) {
+ if (iccInfo) {
+ nsString iccId;
+ iccInfo->GetIccid(iccId);
+ if (!iccId.IsEmpty()) {
+ mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
+ mIccManager->NotifyIccAdd(iccId);
+ mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange"));
+ }
+ }
+ } else {
+ mIcc->UpdateIccInfo(iccInfo);
+ mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange"));
+ if (!iccInfo) {
+ nsString iccId = mIcc->GetIccId();
+ mIcc->Shutdown();
+ mIcc = nullptr;
+ mIccManager->NotifyIccRemove(iccId);
+ }
+ }
+
+ return NS_OK;
+}
diff --git a/dom/icc/IccListener.h b/dom/icc/IccListener.h
new file mode 100644
index 000000000..c55c27ae2
--- /dev/null
+++ b/dom/icc/IccListener.h
@@ -0,0 +1,53 @@
+/* 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_IccListener_h
+#define mozilla_dom_IccListener_h
+
+#include "nsAutoPtr.h"
+#include "nsIIccProvider.h"
+
+namespace mozilla {
+namespace dom {
+
+class IccManager;
+class Icc;
+
+class IccListener final : public nsIIccListener
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIICCLISTENER
+
+ IccListener(IccManager* aIccManager, uint32_t aClientId);
+
+ void
+ Shutdown();
+
+ Icc*
+ GetIcc()
+ {
+ return mIcc;
+ }
+
+private:
+ ~IccListener();
+
+private:
+ uint32_t mClientId;
+ // We did not setup 'mIcc' and 'mIccManager' being a participant of cycle
+ // collection is because in Navigator->Invalidate() it will call
+ // mIccManager->Shutdown(), then IccManager will call Shutdown() of each
+ // IccListener, this will release the reference and break the cycle.
+ nsRefPtr<Icc> mIcc;
+ nsRefPtr<IccManager> mIccManager;
+ // mProvider is a xpcom service and will be released at shutdown, so it
+ // doesn't need to be cycle collected.
+ nsCOMPtr<nsIIccProvider> mProvider;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_IccListener_h
diff --git a/dom/icc/IccManager.cpp b/dom/icc/IccManager.cpp
new file mode 100644
index 000000000..193941a27
--- /dev/null
+++ b/dom/icc/IccManager.cpp
@@ -0,0 +1,131 @@
+/* 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 "IccManager.h"
+#include "mozilla/dom/MozIccManagerBinding.h"
+#include "Icc.h"
+#include "IccListener.h"
+#include "mozilla/AsyncEventDispatcher.h"
+#include "mozilla/dom/IccChangeEvent.h"
+#include "mozilla/Preferences.h"
+#include "nsIIccInfo.h"
+
+using namespace mozilla::dom;
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(IccManager)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IccManager,
+ DOMEventTargetHelper)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IccManager,
+ DOMEventTargetHelper)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+// QueryInterface implementation for IccManager
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IccManager)
+NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
+
+NS_IMPL_ADDREF_INHERITED(IccManager, DOMEventTargetHelper)
+NS_IMPL_RELEASE_INHERITED(IccManager, DOMEventTargetHelper)
+
+IccManager::IccManager(nsPIDOMWindow* aWindow)
+ : DOMEventTargetHelper(aWindow)
+{
+ uint32_t numberOfServices =
+ mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
+
+ for (uint32_t i = 0; i < numberOfServices; i++) {
+ nsRefPtr<IccListener> iccListener = new IccListener(this, i);
+ mIccListeners.AppendElement(iccListener);
+ }
+}
+
+IccManager::~IccManager()
+{
+ Shutdown();
+}
+
+JSObject*
+IccManager::WrapObject(JSContext* aCx)
+{
+ return MozIccManagerBinding::Wrap(aCx, this);
+}
+
+void
+IccManager::Shutdown()
+{
+ for (uint32_t i = 0; i < mIccListeners.Length(); i++) {
+ mIccListeners[i]->Shutdown();
+ mIccListeners[i] = nullptr;
+ }
+ mIccListeners.Clear();
+}
+
+nsresult
+IccManager::NotifyIccAdd(const nsAString& aIccId)
+{
+ MozIccManagerBinding::ClearCachedIccIdsValue(this);
+
+ IccChangeEventInit init;
+ init.mBubbles = false;
+ init.mCancelable = false;
+ init.mIccId = aIccId;
+
+ nsRefPtr<IccChangeEvent> event =
+ IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccdetected"), init);
+ event->SetTrusted(true);
+
+ nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
+ new AsyncEventDispatcher(this, event);
+
+ return asyncDispatcher->PostDOMEvent();
+}
+
+nsresult
+IccManager::NotifyIccRemove(const nsAString& aIccId)
+{
+ MozIccManagerBinding::ClearCachedIccIdsValue(this);
+
+ IccChangeEventInit init;
+ init.mBubbles = false;
+ init.mCancelable = false;
+ init.mIccId = aIccId;
+
+ nsRefPtr<IccChangeEvent> event =
+ IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccundetected"), init);
+ event->SetTrusted(true);
+
+ nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
+ new AsyncEventDispatcher(this, event);
+
+ return asyncDispatcher->PostDOMEvent();
+}
+
+// MozIccManager
+
+void
+IccManager::GetIccIds(nsTArray<nsString>& aIccIds)
+{
+ nsTArray<nsRefPtr<IccListener>>::size_type i;
+ for (i = 0; i < mIccListeners.Length(); ++i) {
+ Icc* icc = mIccListeners[i]->GetIcc();
+ if (icc) {
+ aIccIds.AppendElement(icc->GetIccId());
+ }
+ }
+}
+
+Icc*
+IccManager::GetIccById(const nsAString& aIccId) const
+{
+ nsTArray<nsRefPtr<IccListener>>::size_type i;
+ for (i = 0; i < mIccListeners.Length(); ++i) {
+ Icc* icc = mIccListeners[i]->GetIcc();
+ if (icc && aIccId == icc->GetIccId()) {
+ return icc;
+ }
+ }
+ return nullptr;
+}
diff --git a/dom/icc/IccManager.h b/dom/icc/IccManager.h
new file mode 100644
index 000000000..cc575a6d2
--- /dev/null
+++ b/dom/icc/IccManager.h
@@ -0,0 +1,64 @@
+/* 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_IccManager_h
+#define mozilla_dom_IccManager_h
+
+#include "mozilla/DOMEventTargetHelper.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsIIccProvider.h"
+#include "nsTArrayHelpers.h"
+
+namespace mozilla {
+namespace dom {
+
+class Icc;
+class IccListener;
+
+class IccManager final : public DOMEventTargetHelper
+{
+public:
+ NS_DECL_ISUPPORTS_INHERITED
+
+ NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
+
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IccManager, DOMEventTargetHelper)
+
+ IccManager(nsPIDOMWindow* aWindow);
+
+ void
+ Shutdown();
+
+ nsresult
+ NotifyIccAdd(const nsAString& aIccId);
+
+ nsresult
+ NotifyIccRemove(const nsAString& aIccId);
+
+ IMPL_EVENT_HANDLER(iccdetected)
+ IMPL_EVENT_HANDLER(iccundetected)
+
+ void
+ GetIccIds(nsTArray<nsString>& aIccIds);
+
+ Icc*
+ GetIccById(const nsAString& aIccId) const;
+
+ nsPIDOMWindow*
+ GetParentObject() const { return GetOwner(); }
+
+ virtual JSObject*
+ WrapObject(JSContext* aCx) override;
+
+private:
+ ~IccManager();
+
+private:
+ nsTArray<nsRefPtr<IccListener>> mIccListeners;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_IccManager_h
diff --git a/dom/icc/gonk/StkProactiveCmdFactory.jsm b/dom/icc/gonk/StkProactiveCmdFactory.jsm
new file mode 100644
index 000000000..ef16cffa9
--- /dev/null
+++ b/dom/icc/gonk/StkProactiveCmdFactory.jsm
@@ -0,0 +1,1044 @@
+/* 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/. */
+
+"use strict";
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+let RIL = {};
+Cu.import("resource://gre/modules/ril_consts.js", RIL);
+
+/**
+ * Helper Utilities to convert JS Objects to IDL Objects.
+ */
+
+/**
+ * To map { timeUnit, timeInterval } into StkDuration.
+ */
+function mapDurationToStkDuration(aDuration) {
+ return (aDuration)
+ ? new StkDuration(aDuration.timeUnit, aDuration.timeInterval)
+ : null;
+}
+
+/**
+ * To map { iconSelfExplanatory, icons } into StkIconInfo.
+ */
+function mapIconInfoToStkIconInfo(aIconInfo) {
+ let mapIconToStkIcon = function(aIcon) {
+ return new StkIcon(aIcon.width, aIcon.height,
+ aIcon.codingScheme, aIcon.pixels);
+ };
+
+ return (aIconInfo &&
+ aIconInfo.icons !== undefined &&
+ aIconInfo.iconSelfExplanatory !== undefined)
+ ? new StkIconInfo(aIconInfo.iconSelfExplanatory,
+ aIconInfo.icons.map(mapIconToStkIcon))
+ : null;
+}
+
+/**
+ * Helper Utilities to append the STK attributes to System Message.
+ */
+
+function appendDuration(aTarget, aStkDuration) {
+ aTarget.timeUnit = aStkDuration.timeUnit;
+ aTarget.timeInterval = aStkDuration.timeInterval;
+}
+
+function appendIconInfo(aTarget, aStkIconInfo) {
+ aTarget.iconSelfExplanatory = aStkIconInfo.iconSelfExplanatory;
+ aTarget.icons = aStkIconInfo.getIcons().map(function(aStkIcon) {
+ return {
+ width: aStkIcon.width,
+ height: aStkIcon.height,
+ codingScheme: RIL.ICC_IMG_CODING_SCHEME_TO_GECKO[aStkIcon.codingScheme],
+ pixels: aStkIcon.getPixels()
+ };
+ });
+}
+
+/**
+ * The implementation of the data types used in variant types of
+ * StkProactiveCommand.
+ */
+
+function StkDuration(aTimeUnit, aTimeInterval) {
+ this.timeUnit = aTimeUnit;
+ this.timeInterval = aTimeInterval;
+}
+StkDuration.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkDuration]),
+
+ // nsIStkDuration
+ timeUnit: 0,
+ timeInterval: 0
+};
+
+function StkIcon(aWidth, aHeight, aCodingScheme, aPixels) {
+ this.width = aWidth;
+ this.height = aHeight;
+ this.codingScheme = this.IMG_CODING_SCHEME[aCodingScheme];
+ this.pixels = aPixels.slice();
+}
+StkIcon.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkIcon]),
+
+ // Cache pixels for getPixels()
+ pixels: null,
+
+ // Scheme mapping.
+ IMG_CODING_SCHEME: {
+ "basic": Ci.nsIStkIcon.CODING_SCHEME_BASIC,
+ "color": Ci.nsIStkIcon.CODING_SCHEME_COLOR,
+ "color-transparency": Ci.nsIStkIcon.CODING_SCHEME_COLOR_TRANSPARENCY
+ },
+
+ // StkIcon
+ width: 0,
+ height: 0,
+ codingScheme: 0,
+ getPixels: function(aCount) {
+ if (!this.pixels) {
+ if (aCount) {
+ aCount.value = 0;
+ }
+ return null;
+ }
+
+ if (aCount) {
+ aCount.value = this.pixels.length;
+ }
+
+ return this.pixels.slice();
+ }
+};
+
+function StkIconInfo(aIconSelfExplanatory, aStkIcons) {
+ this.iconSelfExplanatory = aIconSelfExplanatory;
+ this.icons = aStkIcons;
+}
+StkIconInfo.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkIconInfo]),
+
+ // Cache the list of StkIcon(s) for getIcons()
+ icons: null,
+
+ // nsIStkIconInfo
+ iconSelfExplanatory: false,
+
+ getIcons: function(aCount) {
+ if (!this.icons) {
+ if (aCount) {
+ aCount.value = 0;
+ }
+ return null;
+ }
+
+ if (aCount) {
+ aCount.value = this.icons.length;
+ }
+
+ return this.icons.slice();
+ }
+};
+
+function StkItem(aIdentifier, aText, aStkIconInfo) {
+ this.identifier = aIdentifier;
+ if (aText !== undefined) {
+ this.text = aText;
+ }
+ this.iconInfo = aStkIconInfo;
+}
+StkItem.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkItem]),
+
+ // nsIStkItem
+ identifier: 0,
+ text: null,
+ iconInfo: null
+};
+
+function StkTimer(aTimerId, aTimerValue, aTimerAction) {
+ this.timerId = aTimerId;
+ if (aTimerValue !== undefined &&
+ aTimerValue !== null) {
+ this.timerValue = aTimerValue;
+ }
+ this.timerAction = aTimerAction;
+}
+StkTimer.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkTimer]),
+
+ // nsIStkTimer
+ timerId: 0,
+ timerValue: Ci.nsIStkTimer.TIMER_VALUE_INVALID,
+ timerAction: 0
+};
+
+/**
+ * The implementation of nsIStkProactiveCommand Set and STK System Message Set.
+ */
+function StkProactiveCommand(aCommandDetails) {
+ this.commandNumber = aCommandDetails.commandNumber;
+ this.typeOfCommand = aCommandDetails.typeOfCommand;
+ this.commandQualifier = aCommandDetails.commandQualifier;
+}
+StkProactiveCommand.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd]),
+
+ // nsIStkProactiveCmd
+ commandNumber: 0,
+ typeOfCommand: 0,
+ commandQualifier: 0
+};
+
+function StkCommandMessage(aStkProactiveCmd) {
+ this.commandNumber = aStkProactiveCmd.commandNumber;
+ this.typeOfCommand = aStkProactiveCmd.typeOfCommand;
+ this.commandQualifier = aStkProactiveCmd.commandQualifier;
+}
+StkCommandMessage.prototype = {
+ commandNumber: 0,
+ typeOfCommand: 0,
+ commandQualifier: 0,
+ options: null
+};
+
+function StkPollIntervalCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ this.duration = mapDurationToStkDuration(aCommandDetails.options);
+}
+StkPollIntervalCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkPollIntervalCmd])
+ },
+
+ // nsIStkPollIntervalCmd
+ duration: { value: null, writable: true }
+});
+
+function StkPollIntervalMessage(aStkPollIntervalCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkPollIntervalCmd);
+
+ this.options = {};
+ appendDuration(this.options, aStkPollIntervalCmd.duration);
+}
+StkPollIntervalMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkProvideLocalInfoCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ this.localInfoType = aCommandDetails.options.localInfoType;
+}
+StkProvideLocalInfoCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkProvideLocalInfoCmd])
+ },
+
+ // nsIStkPollIntervalCmd
+ localInfoType: { value: 0x00, writable: true }
+});
+
+function StkProvideLocalInfoMessage(aStkProvideLocalInfoCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkProvideLocalInfoCmd);
+
+ this.options = {
+ localInfoType: aStkProvideLocalInfoCmd.localInfoType
+ };
+}
+StkProvideLocalInfoMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkSetupEventListCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+ let eventList = aCommandDetails.options.eventList;
+ if (eventList) {
+ this.eventList = eventList.slice();
+ }
+}
+StkSetupEventListCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkSetupEventListCmd])
+ },
+
+ // Cache eventList for getEventList()
+ eventList: { value: null, writable: true },
+
+ // nsIStkSetupEventListCmd
+ getEventList: {
+ value: function(aCount) {
+ if (!this.eventList) {
+ if (aCount) {
+ aCount.value = 0;
+ }
+ return null;
+ }
+
+ if (aCount) {
+ aCount.value = this.eventList.length;
+ }
+
+ return this.eventList.slice();
+ }
+ }
+});
+
+function StkSetupEventListMessage(aStkSetupEventListCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkSetupEventListCmd);
+
+ this.options = {
+ eventList: null
+ };
+
+ let eventList = aStkSetupEventListCmd.getEventList();
+
+ if (eventList && eventList.length > 0) {
+ this.options.eventList = eventList;
+ }
+}
+StkSetupEventListMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkSetUpMenuCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ if (options.title !== undefined) {
+ this.title = options.title;
+ }
+
+ this.items = options.items.map(function(aItem) {
+ // For |SET-UP MENU|, the 1st item in |aItems| could be null as an
+ // indication to the ME to remove the existing menu from the menu
+ // system in the ME.
+ return (aItem) ? new StkItem(aItem.identifier,
+ aItem.text,
+ mapIconInfoToStkIconInfo(aItem))
+ : null;
+ });
+
+ if (options.nextActionList) {
+ this.nextActionList = options.nextActionList.slice();
+ }
+
+ this.iconInfo = mapIconInfoToStkIconInfo(options);
+
+ this.isHelpAvailable = !!(options.isHelpAvailable);
+}
+StkSetUpMenuCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkSetUpMenuCmd])
+ },
+
+ // Cache items for getItems()
+ items: { value: null, writable: true },
+
+ // Cache items for getNextActionList()
+ nextActionList: { value: null, writable: true },
+
+ // nsIStkSetUpMenuCmd
+ title: { value: null, writable: true },
+
+ getItems: {
+ value: function(aCount) {
+ if (!this.items) {
+ if (aCount) {
+ aCount.value = 0;
+ }
+ return null;
+ }
+
+ if (aCount) {
+ aCount.value = this.items.length;
+ }
+
+ return this.items.slice();
+ }
+ },
+
+ getNextActionList: {
+ value: function(aCount) {
+ if (!this.nextActionList) {
+ if (aCount) {
+ aCount.value = 0;
+ }
+ return null;
+ }
+
+ if (aCount) {
+ aCount.value = this.nextActionList.length;
+ }
+
+ return this.nextActionList.slice();
+ }
+ },
+
+ iconInfo: { value: null, writable: true },
+ isHelpAvailable: { value: false, writable: true }
+});
+
+function StkSetUpMenuMessage(aStkSetUpMenuCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkSetUpMenuCmd);
+
+ this.options = {
+ items: aStkSetUpMenuCmd.getItems().map(function(aStkItem) {
+ if (!aStkItem) {
+ return null;
+ }
+
+ let item = {
+ identifier: aStkItem.identifier,
+ text: aStkItem.text
+ };
+
+ if (aStkItem.iconInfo) {
+ appendIconInfo(item, aStkItem.iconInfo);
+ }
+
+ return item;
+ }),
+ isHelpAvailable: aStkSetUpMenuCmd.isHelpAvailable,
+ title: aStkSetUpMenuCmd.title
+ };
+
+ let nextActionList = aStkSetUpMenuCmd.getNextActionList();
+ if (nextActionList && nextActionList.length > 0) {
+ this.options.nextActionList = nextActionList;
+ }
+
+ if (aStkSetUpMenuCmd.iconInfo) {
+ appendIconInfo(this.options, aStkSetUpMenuCmd.iconInfo);
+ }
+}
+StkSetUpMenuMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkSelectItemCmd(aCommandDetails) {
+ // Call |StkSetUpMenuCmd| constructor.
+ StkSetUpMenuCmd.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ this.presentationType = options.presentationType;
+
+ if (options.defaultItem !== undefined &&
+ options.defaultItem !== null) {
+ this.defaultItem = options.defaultItem;
+ }
+}
+StkSelectItemCmd.prototype = Object.create(StkSetUpMenuCmd.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkSetUpMenuCmd,
+ Ci.nsIStkSelectItemCmd])
+ },
+
+ // nsIStkSelectItemCmd
+ presentationType: {
+ value: 0,
+ writable: true
+ },
+
+ defaultItem: {
+ value: Ci.nsIStkSelectItemCmd.DEFAULT_ITEM_INVALID,
+ writable: true
+ }
+});
+
+function StkSelectItemMessage(aStkSelectItemCmd) {
+ // Call |StkSetUpMenuMessage| constructor.
+ StkSetUpMenuMessage.call(this, aStkSelectItemCmd);
+
+ this.options.presentationType = aStkSelectItemCmd.presentationType;
+
+ if (aStkSelectItemCmd.defaultItem !== Ci.nsIStkSelectItemCmd.DEFAULT_ITEM_INVALID) {
+ this.options.defaultItem = aStkSelectItemCmd.defaultItem;
+ }
+}
+StkSelectItemMessage.prototype = Object.create(StkSetUpMenuMessage.prototype);
+
+function StkTextMessageCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ if (options.text !== undefined) {
+ this.text = options.text;
+ }
+
+ this.iconInfo = mapIconInfoToStkIconInfo(options);
+}
+StkTextMessageCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkTextMessageCmd])
+ },
+
+ // nsIStkTextMessageCmd
+ text: { value: null, writable: true },
+ iconInfo: { value: null, writable: true }
+});
+
+function StkTextMessage(aStkTextMessageCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkTextMessageCmd);
+
+ this.options = {
+ text: aStkTextMessageCmd.text
+ };
+
+ if (aStkTextMessageCmd.iconInfo) {
+ appendIconInfo(this.options, aStkTextMessageCmd.iconInfo);
+ }
+}
+StkTextMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkDisplayTextCmd(aCommandDetails) {
+ // Call |StkTextMessageCmd| constructor.
+ StkTextMessageCmd.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ this.duration = mapDurationToStkDuration(options.duration);
+
+ this.isHighPriority = !!(options.isHighPriority);
+ this.userClear = !!(options.userClear);
+ this.responseNeeded = !!(options.responseNeeded);
+}
+StkDisplayTextCmd.prototype = Object.create(StkTextMessageCmd.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkTextMessageCmd,
+ Ci.nsIStkDisplayTextCmd])
+ },
+
+ // nsIStkDisplayTextCmd
+ duration: { value: null, writable: true },
+ isHighPriority: { value: false, writable: true },
+ userClear: { value: false, writable: true },
+ responseNeeded: { value: false, writable: true }
+});
+
+function StkDisplayTextMessage(aStkDisplayTextCmd) {
+ // Call |StkTextMessage| constructor.
+ StkTextMessage.call(this, aStkDisplayTextCmd);
+
+ this.options.isHighPriority = aStkDisplayTextCmd.isHighPriority;
+ this.options.userClear = aStkDisplayTextCmd.userClear;
+ this.options.responseNeeded = aStkDisplayTextCmd.responseNeeded;
+
+ if (aStkDisplayTextCmd.duration) {
+ this.options.duration = {};
+ appendDuration(this.options.duration, aStkDisplayTextCmd.duration);
+ }
+}
+StkDisplayTextMessage.prototype = Object.create(StkTextMessage.prototype);
+
+function StkInputCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ if (options.text !== undefined) {
+ this.text = options.text;
+ }
+
+ this.duration = mapDurationToStkDuration(options.duration);
+
+ if (options.defaultText !== undefined) {
+ this.defaultText = options.defaultText;
+ }
+
+ this.isAlphabet = !!(options.isAlphabet);
+ this.isUCS2 = !!(options.isUCS2);
+ this.isHelpAvailable = !!(options.isHelpAvailable);
+
+ this.iconInfo = mapIconInfoToStkIconInfo(options);
+}
+StkInputCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkInputCmd])
+ },
+
+ // nsIStkInputCmd
+ text: { value: null, writable: true },
+ duration: { value: null, writable: true },
+ minLength: { value: 1, writable: true },
+ maxLength: { value: 1, writable: true },
+ defaultText: { value: null, writable: true },
+ isAlphabet: { value: false, writable: true },
+ isUCS2: { value: false, writable: true },
+ isHelpAvailable: { value: false, writable: true },
+ iconInfo: { value: null, writable: true }
+});
+
+function StkInputMessage(aStkInputCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkInputCmd);
+
+ this.options = {
+ text: aStkInputCmd.text,
+ minLength: aStkInputCmd.minLength,
+ maxLength: aStkInputCmd.maxLength,
+ isAlphabet: aStkInputCmd.isAlphabet,
+ isUCS2: aStkInputCmd.isUCS2,
+ isHelpAvailable: aStkInputCmd.isHelpAvailable,
+ defaultText: aStkInputCmd.defaultText
+ };
+
+ if (aStkInputCmd.duration) {
+ this.options.duration = {};
+ appendDuration(this.options.duration, aStkInputCmd.duration);
+ }
+
+ if (aStkInputCmd.iconInfo) {
+ appendIconInfo(this.options, aStkInputCmd.iconInfo);
+ }
+}
+StkInputMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkInputKeyCmd(aCommandDetails) {
+ // Call |StkInputCmd| constructor.
+ StkInputCmd.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ // Note: For STK_CMD_INKEY,
+ // this.minLength = this.maxLength = 1;
+
+ this.isYesNoRequested = !!(options.isYesNoRequested);
+}
+StkInputKeyCmd.prototype = Object.create(StkInputCmd.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkInputCmd,
+ Ci.nsIStkInputKeyCmd])
+ },
+
+ // nsIStkInputKeyCmd
+ isYesNoRequested: { value: false, writable: true }
+});
+
+function StkInputKeyMessage(aStkInputKeyCmd) {
+ // Call |StkInputMessage| constructor.
+ StkInputMessage.call(this, aStkInputKeyCmd);
+
+ this.options.isYesNoRequested = aStkInputKeyCmd.isYesNoRequested;
+}
+StkInputKeyMessage.prototype = Object.create(StkInputMessage.prototype);
+
+function StkInputTextCmd(aCommandDetails) {
+ // Call |StkInputCmd| constructor.
+ StkInputCmd.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ this.minLength = options.minLength;
+ this.maxLength = options.maxLength;
+
+ this.hideInput = !!(options.hideInput);
+ this.isPacked = !!(options.isPacked);
+}
+StkInputTextCmd.prototype = Object.create(StkInputCmd.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkInputCmd,
+ Ci.nsIStkInputTextCmd])
+ },
+
+ // nsIStkInputTextCmd
+ hideInput: { value: false, writable: true },
+ isPacked: { value: false, writable: true }
+});
+
+function StkInputTextMessage(aStkInputTextCmd) {
+ // Call |StkInputMessage| constructor.
+ StkInputMessage.call(this, aStkInputTextCmd);
+
+ this.options.hideInput = aStkInputTextCmd.hideInput;
+ this.options.isPacked = aStkInputTextCmd.isPacked;
+}
+StkInputTextMessage.prototype = Object.create(StkInputMessage.prototype);
+
+function StkSetUpCallCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ let confirmMessage = options.confirmMessage;
+ let callMessage = options.callMessage;
+
+ this.address = options.address;
+
+ if(confirmMessage) {
+ if (confirmMessage.text !== undefined) {
+ this.confirmText = confirmMessage.text;
+ }
+ this.confirmIconInfo = mapIconInfoToStkIconInfo(confirmMessage);
+ }
+
+ if(callMessage) {
+ if (callMessage.text !== undefined) {
+ this.callText = callMessage.text;
+ }
+ this.callIconInfo = mapIconInfoToStkIconInfo(callMessage);
+ }
+
+ this.duration = mapDurationToStkDuration(options.duration);
+}
+StkSetUpCallCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkSetUpCallCmd])
+ },
+
+ // nsIStkSetUpCallCmd
+ address: { value: null, writable: true },
+ confirmText: { value: null, writable: true },
+ confirmIconInfo: { value: null, writable: true },
+ callText: { value: null, writable: true },
+ callIconInfo: { value: null, writable: true },
+ duration: { value: null, writable: true }
+});
+
+function StkSetUpCallMessage(aStkSetUpCallCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkSetUpCallCmd);
+
+ this.options = {
+ address: aStkSetUpCallCmd.address
+ };
+
+ if (aStkSetUpCallCmd.confirmText !== null ||
+ aStkSetUpCallCmd.confirmIconInfo) {
+ let confirmMessage = {
+ text: aStkSetUpCallCmd.confirmText
+ };
+ if (aStkSetUpCallCmd.confirmIconInfo) {
+ appendIconInfo(confirmMessage, aStkSetUpCallCmd.confirmIconInfo);
+ }
+ this.options.confirmMessage = confirmMessage;
+ }
+
+ if (aStkSetUpCallCmd.callText !== null ||
+ aStkSetUpCallCmd.callIconInfo) {
+ let callMessage = {
+ text: aStkSetUpCallCmd.callText
+ };
+ if (aStkSetUpCallCmd.callIconInfo) {
+ appendIconInfo(callMessage, aStkSetUpCallCmd.callIconInfo);
+ }
+ this.options.callMessage = callMessage;
+ }
+
+ if (aStkSetUpCallCmd.duration) {
+ this.options.duration = {};
+ appendDuration(this.options.duration, aStkSetUpCallCmd.duration);
+ }
+}
+StkSetUpCallMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkBrowserSettingCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ this.url = options.url;
+
+ this.mode = options.mode;
+
+ let confirmMessage = options.confirmMessage;
+
+ if(confirmMessage) {
+ if (confirmMessage.text !== undefined) {
+ this.confirmText = confirmMessage.text;
+ }
+ this.confirmIconInfo = mapIconInfoToStkIconInfo(confirmMessage);
+ }
+}
+StkBrowserSettingCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkBrowserSettingCmd])
+ },
+
+ // nsIStkBrowserSettingCmd
+ url: { value: null, writable: true },
+ mode: { value: 0, writable: true },
+ confirmText: { value: null, writable: true },
+ confirmIconInfo: { value: null, writable: true }
+});
+
+function StkBrowserSettingMessage(aStkBrowserSettingCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkBrowserSettingCmd);
+
+ this.options = {
+ url: aStkBrowserSettingCmd.url,
+ mode: aStkBrowserSettingCmd.mode
+ };
+
+ if (aStkBrowserSettingCmd.confirmText !== null ||
+ aStkBrowserSettingCmd.confirmIconInfo) {
+ let confirmMessage = {
+ text: aStkBrowserSettingCmd.confirmText
+ };
+ if (aStkBrowserSettingCmd.confirmIconInfo) {
+ appendIconInfo(confirmMessage, aStkBrowserSettingCmd.confirmIconInfo);
+ }
+ this.options.confirmMessage = confirmMessage;
+ }
+}
+StkBrowserSettingMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkPlayToneCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ if(options.text !== undefined) {
+ this.text = options.text;
+ }
+
+ if (options.tone !== undefined &&
+ options.tone !== null) {
+ this.tone = options.tone;
+ }
+
+ if (options.isVibrate) {
+ this.isVibrate = true;
+ }
+
+ this.duration = mapDurationToStkDuration(options.duration);
+
+ this.iconInfo = mapIconInfoToStkIconInfo(options);
+}
+StkPlayToneCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkPlayToneCmd])
+ },
+
+ // nsIStkPlayToneCmd
+ text: { value: null, writable: true },
+ tone: { value: Ci.nsIStkPlayToneCmd.TONE_TYPE_INVALID, writable: true },
+ duration: { value: null, writable: true },
+ isVibrate: { value: false, writable: true },
+ iconInfo: { value: null, writable: true }
+});
+
+function StkPlayToneMessage(aStkPlayToneCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkPlayToneCmd);
+
+ this.options = {
+ isVibrate: aStkPlayToneCmd.isVibrate,
+ text: aStkPlayToneCmd.text
+ };
+
+ if (aStkPlayToneCmd.tone != Ci.nsIStkPlayToneCmd.TONE_TYPE_INVALID) {
+ this.options.tone = aStkPlayToneCmd.tone;
+ }
+
+ if (aStkPlayToneCmd.duration) {
+ this.options.duration = {};
+ appendDuration(this.options.duration, aStkPlayToneCmd.duration);
+ }
+
+ if (aStkPlayToneCmd.iconInfo) {
+ appendIconInfo(this.options, aStkPlayToneCmd.iconInfo);
+ }
+}
+StkPlayToneMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+function StkTimerManagementCmd(aCommandDetails) {
+ // Call |StkProactiveCommand| constructor.
+ StkProactiveCommand.call(this, aCommandDetails);
+
+ let options = aCommandDetails.options;
+
+ this.timerInfo = new StkTimer(options.timerId,
+ options.timerValue,
+ options.timerAction);
+
+}
+StkTimerManagementCmd.prototype = Object.create(StkProactiveCommand.prototype, {
+ QueryInterface: {
+ value: XPCOMUtils.generateQI([Ci.nsIStkProactiveCmd,
+ Ci.nsIStkTimerManagementCmd])
+ },
+
+ // nsIStkTimerManagementCmd
+ timerInfo: { value: null, writable: true }
+});
+
+function StkTimerMessage(aStkTimerManagementCmd) {
+ // Call |StkCommandMessage| constructor.
+ StkCommandMessage.call(this, aStkTimerManagementCmd);
+
+ let timerInfo = aStkTimerManagementCmd.timerInfo;
+
+ this.options = {
+ timerId: timerInfo.timerId,
+ timerAction: timerInfo.timerAction
+ };
+
+ if (timerInfo.timerValue !== Ci.nsIStkTimer.TIMER_VALUE_INVALID) {
+ this.options.timerValue = timerInfo.timerValue;
+ }
+}
+StkTimerMessage.prototype = Object.create(StkCommandMessage.prototype);
+
+/**
+ * Command Prototype Mappings.
+ */
+let CmdPrototypes = {};
+CmdPrototypes[RIL.STK_CMD_REFRESH] = StkProactiveCommand;
+CmdPrototypes[RIL.STK_CMD_POLL_INTERVAL] = StkPollIntervalCmd;
+CmdPrototypes[RIL.STK_CMD_POLL_OFF] = StkProactiveCommand;
+CmdPrototypes[RIL.STK_CMD_PROVIDE_LOCAL_INFO] = StkProvideLocalInfoCmd;
+CmdPrototypes[RIL.STK_CMD_SET_UP_EVENT_LIST] = StkSetupEventListCmd;
+CmdPrototypes[RIL.STK_CMD_SET_UP_MENU] = StkSetUpMenuCmd;
+CmdPrototypes[RIL.STK_CMD_SELECT_ITEM] = StkSelectItemCmd;
+CmdPrototypes[RIL.STK_CMD_DISPLAY_TEXT] = StkDisplayTextCmd;
+CmdPrototypes[RIL.STK_CMD_SET_UP_IDLE_MODE_TEXT] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_SEND_SS] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_SEND_USSD] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_SEND_SMS] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_SEND_DTMF] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_GET_INKEY] = StkInputKeyCmd;
+CmdPrototypes[RIL.STK_CMD_GET_INPUT] = StkInputTextCmd;
+CmdPrototypes[RIL.STK_CMD_SET_UP_CALL] = StkSetUpCallCmd;
+CmdPrototypes[RIL.STK_CMD_LAUNCH_BROWSER] = StkBrowserSettingCmd;
+CmdPrototypes[RIL.STK_CMD_PLAY_TONE] = StkPlayToneCmd;
+CmdPrototypes[RIL.STK_CMD_TIMER_MANAGEMENT] = StkTimerManagementCmd;
+CmdPrototypes[RIL.STK_CMD_OPEN_CHANNEL] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_CLOSE_CHANNEL] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_SEND_DATA] = StkTextMessageCmd;
+CmdPrototypes[RIL.STK_CMD_RECEIVE_DATA] = StkTextMessageCmd;
+
+/**
+ * Message Prototype Mappings.
+ */
+let MsgPrototypes = {};
+MsgPrototypes[RIL.STK_CMD_REFRESH] = StkCommandMessage;
+MsgPrototypes[RIL.STK_CMD_POLL_INTERVAL] = StkPollIntervalMessage;
+MsgPrototypes[RIL.STK_CMD_POLL_OFF] = StkCommandMessage;
+MsgPrototypes[RIL.STK_CMD_PROVIDE_LOCAL_INFO] = StkProvideLocalInfoMessage;
+MsgPrototypes[RIL.STK_CMD_SET_UP_EVENT_LIST] = StkSetupEventListMessage;
+MsgPrototypes[RIL.STK_CMD_SET_UP_MENU] = StkSetUpMenuMessage;
+MsgPrototypes[RIL.STK_CMD_SELECT_ITEM] = StkSelectItemMessage;
+MsgPrototypes[RIL.STK_CMD_DISPLAY_TEXT] = StkDisplayTextMessage;
+MsgPrototypes[RIL.STK_CMD_SET_UP_IDLE_MODE_TEXT] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_SEND_SS] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_SEND_USSD] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_SEND_SMS] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_SEND_DTMF] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_GET_INKEY] = StkInputKeyMessage;
+MsgPrototypes[RIL.STK_CMD_GET_INPUT] = StkInputTextMessage;
+MsgPrototypes[RIL.STK_CMD_SET_UP_CALL] = StkSetUpCallMessage;
+MsgPrototypes[RIL.STK_CMD_LAUNCH_BROWSER] = StkBrowserSettingMessage;
+MsgPrototypes[RIL.STK_CMD_PLAY_TONE] = StkPlayToneMessage;
+MsgPrototypes[RIL.STK_CMD_TIMER_MANAGEMENT] = StkTimerMessage;
+MsgPrototypes[RIL.STK_CMD_OPEN_CHANNEL] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_CLOSE_CHANNEL] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_SEND_DATA] = StkTextMessage;
+MsgPrototypes[RIL.STK_CMD_RECEIVE_DATA] = StkTextMessage;
+
+/**
+ * QueryInterface Mappings.
+ */
+let QueriedIFs = {};
+QueriedIFs[RIL.STK_CMD_REFRESH] = Ci.nsIStkProactiveCmd;
+QueriedIFs[RIL.STK_CMD_POLL_INTERVAL] = Ci.nsIStkPollIntervalCmd;
+QueriedIFs[RIL.STK_CMD_POLL_OFF] = Ci.nsIStkProactiveCmd;
+QueriedIFs[RIL.STK_CMD_PROVIDE_LOCAL_INFO] = Ci.nsIStkProvideLocalInfoCmd;
+QueriedIFs[RIL.STK_CMD_SET_UP_EVENT_LIST] = Ci.nsIStkSetupEventListCmd;
+QueriedIFs[RIL.STK_CMD_SET_UP_MENU] = Ci.nsIStkSetUpMenuCmd;
+QueriedIFs[RIL.STK_CMD_SELECT_ITEM] = Ci.nsIStkSelectItemCmd;
+QueriedIFs[RIL.STK_CMD_DISPLAY_TEXT] = Ci.nsIStkDisplayTextCmd;
+QueriedIFs[RIL.STK_CMD_SET_UP_IDLE_MODE_TEXT] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_SEND_SS] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_SEND_USSD] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_SEND_SMS] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_SEND_DTMF] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_GET_INKEY] = Ci.nsIStkInputKeyCmd;
+QueriedIFs[RIL.STK_CMD_GET_INPUT] = Ci.nsIStkInputTextCmd;
+QueriedIFs[RIL.STK_CMD_SET_UP_CALL] = Ci.nsIStkSetUpCallCmd;
+QueriedIFs[RIL.STK_CMD_LAUNCH_BROWSER] = Ci.nsIStkBrowserSettingCmd;
+QueriedIFs[RIL.STK_CMD_PLAY_TONE] = Ci.nsIStkPlayToneCmd;
+QueriedIFs[RIL.STK_CMD_TIMER_MANAGEMENT] = Ci.nsIStkTimerManagementCmd;
+QueriedIFs[RIL.STK_CMD_OPEN_CHANNEL] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_CLOSE_CHANNEL] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_SEND_DATA] = Ci.nsIStkTextMessageCmd;
+QueriedIFs[RIL.STK_CMD_RECEIVE_DATA] = Ci.nsIStkTextMessageCmd;
+
+/**
+ * StkProactiveCmdFactory
+ */
+this.StkProactiveCmdFactory = {
+ /**
+ * @param aCommandDetails
+ * The CommandDetails decoded from ril_worker.js.
+ * @return a nsIStkProactiveCmd instance.
+ */
+ createCommand: function(aCommandDetails) {
+ let cmdType = CmdPrototypes[aCommandDetails.typeOfCommand];
+
+ if (typeof cmdType != "function") {
+ throw new Error("Unknown Command Type: " + aCommandDetails.typeOfCommand);
+ }
+
+ return new cmdType(aCommandDetails);
+ },
+
+ /**
+ * @param nsIStkProactiveCmd instance.
+ * @return a Javascript object with the same structure to MozStkCommandEvent.
+ */
+ createCommandMessage: function(aStkProactiveCmd) {
+ let cmd = null;
+
+ let msgType = MsgPrototypes[aStkProactiveCmd.typeOfCommand];
+
+ if (typeof msgType != "function") {
+ throw new Error("Unknown Command Type: " + aStkProactiveCmd.typeOfCommand);
+ }
+
+ // convert aStkProactiveCmd to it's concrete interface before creating
+ // system message.
+ try {
+ cmd = aStkProactiveCmd.QueryInterface(QueriedIFs[aStkProactiveCmd.typeOfCommand]);
+ } catch (e) {
+ throw new Error("Failed to convert command into concrete class: " + e);
+ }
+
+ return new msgType(cmd);
+ },
+};
+
+this.EXPORTED_SYMBOLS = [
+ 'StkProactiveCmdFactory'
+];
diff --git a/dom/icc/interfaces/Makefile.in b/dom/icc/interfaces/Makefile.in
deleted file mode 100644
index 09c8567a7..000000000
--- a/dom/icc/interfaces/Makefile.in
+++ /dev/null
@@ -1,14 +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/.
-
-DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-include $(topsrcdir)/dom/dom-config.mk
-
-include $(topsrcdir)/config/rules.mk
diff --git a/dom/icc/interfaces/SimToolKit.idl b/dom/icc/interfaces/SimToolKit.idl
deleted file mode 100644
index b13b31aea..000000000
--- a/dom/icc/interfaces/SimToolKit.idl
+++ /dev/null
@@ -1,636 +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 "nsIDOMEvent.idl"
-
-interface nsIDOMEvent;
-
-dictionary MozStkTextMessage
-{
- /**
- * Text String.
- *
- * @see TS 11.14, clause 12.15, Text String.
- */
- DOMString text;
-
- /**
- * The length of time for which the ME shall display the dialog.
- *
- * @see MozStkDuration
- */
- jsval duration;
-
- /**
- * Indicate this text message is high priority or normal priority.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 1.
- *
- * High priority text shall be displayed on the screen immediately, except if
- * there is a conflict of priority level of alerting such as incoming calls
- * or a low battery warning. In that situation, the resolution is left to
- * the terminal. If the command is rejected in spite of the high priority,
- * the terminal shall inform the ICC with resultCode is
- * TERMINAL_CRNTLY_UNABLE_TO_PROCESS in MozStkResponse.
- *
- * true: high priority
- * false: normal priority
- */
- boolean isHighPriority;
-
- /**
- * Need to wait for user to clear message or not.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 8.
- *
- * If this attribute is true, but user doesn't give any input within a period
- * of time(said 30 secs), the terminal shall inform the ICC with resultCode
- * is NO_RESPONSE_FROM_USER in MozStkResponse.
- *
- * true: Wait for user to clear message.
- * false: clear message after a delay.
- */
- boolean userClear;
-
- /**
- * Need to response immediately or not.
- *
- * @see TS 11.14, clause 12.43, Immediate response.
- *
- * When this attribute is true, the terminal shall immediately send
- * MozStkResponse with resultCode is OK.
- *
- * true: The terminal shall send response immediately.
- * false: otherwise.
- */
- boolean responseNeeded;
-};
-
-dictionary MozStkItem
-{
- /**
- * Identifier of item.
- *
- * The identifier is a single byte between '01' and 'FF'. Each item shall
- * have a unique identifier within an Item list.
- */
- unsigned short identifier;
-
- /**
- * Text string of item.
- */
- DOMString text;
-};
-
-dictionary MozStkMenu
-{
- /**
- * Array of MozStkItem.
- *
- * @see TS 11.14, clause 12.9
- */
- jsval items; // MozStkItem[]
-
- /**
- * Presentation type, one of TYPE_*.
- */
- unsigned short presentationType;
-
- /**
- * Title of the menu.
- */
- DOMString title;
-
- /**
- * Default item identifier of the menu.
- */
- unsigned short defaultItem;
-
- /**
- * Help information available or not.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 8.
- *
- * true: help information available.
- * false: no help information available.
- */
- boolean isHelpAvailable;
-};
-
-dictionary MozStkInput
-{
- /**
- * Text for the ME to display in conjunction with asking the user to respond.
- */
- DOMString text;
-
- /**
- * The length of time for which the ME shall display the dialog. This field
- * is used only for GET INKEY.
- *
- * @see TS 11.14, clause 11.8, duration, GET INKEY T.C 27.22.4.2.8.4.2
- */
- jsval duration;
-
- /**
- * Minimum length of response.
- */
- unsigned short minLength;
-
- /**
- * Maximum length of response.
- */
- unsigned short maxLength;
-
- /**
- * Text for the ME to display, corresponds to a default text string offered
- * by the ICC.
- */
- DOMString defaultText;
-
- /**
- * Input format.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 1.
- *
- * true: Alphabet set.
- * false: Digits only.
- */
- boolean isAlphabet;
-
- /**
- * Alphabet encoding.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 2.
- *
- * true: UCS2 alphabet.
- * false: default SMS alphabet.
- */
- boolean isUCS2;
-
- /**
- * Visibility of input.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 3.
- *
- * true: User input shall not be revealed in any way.
- * false: ME may echo user input on the display.
- */
- boolean hideInput;
-
- /**
- * Yes/No response is requested.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.
- *
- * true: Yes/No response is requested, and character sets
- * (Alphabet set and UCS2) are disabled.
- * false: Character sets (Alphabet set and UCS2) are enabled.
- */
- boolean isYesNoRequested;
-
- /**
- * User input in packed or unpacked format.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 4.
- *
- * true: User input to be in SMS packed format.
- * false: User input to be in unpacked format.
- */
- boolean isPacked;
-
- /**
- * Help information available or not.
- *
- * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 8.
- *
- * true: help information available.
- * false: no help information available.
- */
- boolean isHelpAvailable;
-};
-
-dictionary MozStkBrowserSetting
-{
- /**
- * Confirm message to launch browser.
- *
- * @see MozStkTextMessage for the detail specification of
- * confirmMessage.
- */
- jsval confirmMessage;
-
- /**
- * The URL to be opened by browser.
- */
- DOMString url;
-
- /**
- * One of STK_BROWSER_MODE_*.
- *
- * @see nsIDOMMozIccManager.STK_BROWSER_MODE_*
- */
- unsigned short mode;
-};
-
-dictionary MozStkSetUpCall
-{
- /**
- * The Dialling number.
- */
- DOMString address;
-
- /**
- * The text message used in user confirmation phase.
- *
- * @see MozStkTextMessage for the detail specification of
- * confirmMessage.
- */
- jsval confirmMessage;
-
- /**
- * The text message used in call set up phase.
- *
- * @see MozStkTextMessage for the detail specification of
- * callMessage.
- */
- jsval callMessage;
-
- /**
- * The Optional maximum duration for the redial mechanism.
- * The time elapsed since the first call set-up attempt has exceeded the duration
- * requested by the UICC, the redial mechanism is terminated.
- */
- jsval duration;
-};
-
-dictionary MozStkSetUpEventList
-{
- /**
- * The list of events that needs to provide details to ICC when they happen.
- * When this valus is null, means an indication to remove the existing list
- * of events in ME.
- *
- * @see nsIDOMMozIccManager.STK_EVENT_TYPE_*
- */
- jsval eventList; // unsigned short []
-};
-
-dictionary MozStkLocationInfo
-{
- /**
- * Mobile Country Code (MCC) of the current serving operator.
- */
- unsigned short mcc;
-
- /**
- * Mobile Network Code (MNC) of the current serving operator.
- */
- unsigned short mnc;
-
- /**
- * Mobile Location Area Code (LAC) for the current serving operator.
- */
- unsigned short gsmLocationAreaCode;
-
- /**
- * Mobile Cell ID for the current serving operator.
- */
- unsigned long gsmCellId;
-};
-
-dictionary MozStkDuration
-{
- /**
- * Time unit used, should be one of STK_TIME_UNIT_*.
- */
- unsigned short timeUnit;
-
- /**
- * The length of time required, expressed in timeUnit.
- */
- octet timeInterval;
-};
-
-dictionary MozStkPlayTone
-{
- /**
- * Text String.
- */
- DOMString text;
-
- /**
- * One of STK_TONE_TYPE_*.
- */
- unsigned short tone;
-
- /**
- * The length of time for which the ME shall generate the tone.
- *
- * @see MozStkDuration
- */
- jsval duration;
-
- /**
- * Need to vibrate or not.
- * true: vibrate alert, if available, with the tone.
- * false: use of vibrate alert is up to the ME.
- */
- boolean isVibrate;
-};
-
-dictionary MozStkProvideLocalInfo
-{
- /**
- * Indicate which local information is required.
- * It shall be one of following:
- * - nsIDOMMozIccManager.STK_LOCAL_INFO_LOCATION_INFO
- * - nsIDOMMozIccManager.STK_LOCAL_INFO_IMEI
- * - nsIDOMMozIccManager.STK_LOCAL_INFO_DATE_TIME_ZONE
- * - nsIDOMMozIccManager.STK_LOCAL_INFO_LANGUAGE
- */
- unsigned short localInfoType;
-};
-
-dictionary MozStkLocationEvent
-{
- /**
- * The type of this event.
- * It shall be nsIDOMMozIccManager.STK_EVENT_TYPE_LOCATION_STATUS;
- */
- unsigned short eventType;
-
- /**
- * Indicate current service state of the MS with one of the values listed
- * below:
- * - nsIDOMMozIccManager.STK_SERVICE_STATE_NORMAL
- * - nsIDOMMozIccManager.STK_SERVICE_STATE_LIMITED
- * - nsIDOMMozIccManager.STK_SERVICE_STATE_UNAVAILABLE
- */
- unsigned short locationStatus;
-
- /**
- * See MozStkLocationInfo.
- * This value shall only be provided if the locationStatus indicates
- * 'STK_SERVICE_STATE_NORMAL'.
- */
- jsval locationInfo;
-};
-
-dictionary MozStkTimer
-{
- /**
- * Identifier of a timer.
- */
- octet timerId;
-
- /**
- * Length of time during which the timer has to run.
- * The resolution of a timer is 1 second.
- */
- unsigned long timerValue;
-
- /**
- * The action requested from UICC.
- * It shall be one of below:
- * - nsIDOMMozIccManager.STK_TIMER_START
- * - nsIDOMMozIccManager.STK_TIMER_DEACTIVATE
- * - nsIDOMMozIccManager.STK_TIMER_GET_CURRENT_VALUE
- */
- unsigned short timerAction;
-};
-
-dictionary MozStkCommand
-{
- /**
- * The number of command issued by ICC. And it is assigned
- * by ICC may take any hexadecimal value betweean '01' and 'FE'.
- *
- * @see TS 11.14, clause 6.5.1
- */
- unsigned short commandNumber;
-
- /**
- * One of STK_CMD_*
- */
- unsigned short typeOfCommand;
-
- /**
- * Qualifiers specific to the command.
- */
- unsigned short commandQualifier;
-
- /**
- * options varies accrording to the typeOfCommand in MozStkCommand.
- *
- * When typeOfCommand is
- * - STK_CMD_DISPLAY_TEXT
- * - STK_CMD_SET_UP_IDLE_MODE_TEXT
- * - STK_CMD_SEND_{SS|USSD|SMS|DTMF},
- * options is MozStkTextMessage.
- *
- * When typeOfCommand is
- * - STK_CMD_SELECT_ITEM
- * - STK_CMD_SET_UP_MENU
- * options is MozStkMenu.
- *
- * When typeOfCommand is
- * - STK_CMD_GET_INKEY
- * - STK_CMD_GET_INPUT,
- * options is MozStkInput.
- *
- * When typeOfCommand is
- * - STK_CMD_LAUNCH_BROWSER
- * options is MozStkBrowserSetting.
- *
- * When typeOfCommand is
- * - STK_CMD_SET_UP_CALL
- * options is MozStkSetUpCall.
- *
- * When typeOfCommand is
- * - STK_CMD_SET_UP_EVENT_LIST
- * options is MozStkSetUpEventList.
- *
- * When typeOfCommand is
- * - STK_CMD_PLAY_TONE
- * options is MozStkPlayTone.
- *
- * When typeOfCommand is
- * - STK_CMD_POLL_INTERVAL
- * options is MozStkDuration.
- *
- * When typeOfCommand is
- * - STK_CMD_PROVIDE_LOCAL_INFO
- * options is MozStkProvideLocalInfo.
- *
- * When typeOfCommand is
- * - STK_CMD_TIMER_MANAGEMENT
- * option is MozStkTimer
- *
- * When typeOfCommand is
- * - STK_CMD_POLL_OFF
- * options is null.
- *
- * When typeOfCommand is
- * - STK_CMD_REFRESH
- * options is null.
- */
- jsval options;
-};
-
-[scriptable, builtinclass, uuid(21cd2f25-ebea-43f8-8255-eaa4e1182858)]
-interface nsIDOMMozStkCommandEvent : nsIDOMEvent
-{
- /**
- * See nsIDOMMozStkCommand for the detail of command.
- */
- [implicit_jscontext]
- readonly attribute jsval command;
-};
-
-dictionary MozStkResponse
-{
- /**
- * One of RESULT_*
- */
- unsigned short resultCode;
-
- /**
- * The identifier of the item selected by user.
- *
- * @see MozStkItem.identifier
- */
- unsigned short itemIdentifier;
-
- /**
- * User input.
- */
- DOMString input;
-
- /**
- * YES/NO response.
- *
- * @see MozStkInput.isYesNoRequested
- */
- boolean isYesNo;
-
- /**
- * User has confirmed or rejected the call during STK_CMD_CALL_SET_UP.
- *
- * @see RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
- *
- * true: Confirmed by User.
- * false: Rejected by User.
- */
- boolean hasConfirmed;
-
- /**
- * The response for STK_CMD_PROVIDE_LOCAL_INFO
- *
- * @see MozStkLocalInfo
- */
- jsval localInfo;
-
- /**
- * The response for STK_CMD_TIMER_MANAGEMENT.
- * The 'timerValue' is needed if the action of STK_CMD_TIMER_MANAGEMENT is
- * 'STK_TIMER_DEACTIVATE' or 'STK_TIMER_GET_CURRENT_VALUE'. It shall state
- * the current value of a timer. And the resolution is 1 second.
- *
- * @see MozStkTimer
- */
- jsval timer;
-};
-
-dictionary MozStkCallEvent
-{
- /**
- * The type of this event.
- * It shall be one of following:
- * - nsIDOMMozIccManager.STK_EVENT_TYPE_MT_CALL,
- * - nsIDOMMozIccManager.STK_EVENT_TYPE_CALL_CONNECTED,
- * - nsIDOMMozIccManager.STK_EVENT_TYPE_CALL_DISCONNECTED.
- */
- unsigned short eventType;
-
- /**
- * Remote party number.
- */
- DOMString number;
-
- /**
- * This field is available in 'STK_EVENT_TYPE_CALL_CONNECTED' and
- * 'STK_EVENT_TYPE_CALL_DISCONNECTED' events.
- * For the STK_EVENT_TYPE_CALL_CONNECTED event, setting this to true means the
- * connection is answered by remote end, that is, this is an outgoing call.
- * For the STK_EVENT_TYPE_CALL_DISCONNECTED event, setting this to true
- * indicates the connection is hung up by remote.
- */
- boolean isIssuedByRemote;
-
- /**
- * This field is available in Call Disconnected event to indicate the cause
- * of disconnection. The cause string is passed to gaia through the error
- * listener of nsIDOMCallEvent. Null if there's no error.
- */
- DOMString error;
-};
-
-dictionary MozStkLocalInfo
-{
- /**
- * IMEI information
- */
- DOMString imei;
-
- /**
- * Location Information
- *
- * @see MozStkLocationInfo.
- */
- jsval locationInfo;
-
- /**
- * Date information
- *
- * @see Date
- */
- jsval date;
-
- /**
- * Language Information
- *
- * @see ISO 639-1, Alpha-2 code
- */
- DOMString language;
-};
-
-dictionary MozStkLanguageSelectionEvent
-{
- /**
- * The type of this event.
- * It shall be nsIDOMMozIccManager.STK_EVENT_TYPE_LANGUAGE_SELECTION.
- */
- unsigned short eventType;
-
- /**
- * Language Information
- *
- * @see ISO 639-1, Alpha-2 code
- * "de" for German, "en" for English, "zh" for Chinese, etc.
- */
- DOMString language;
-};
-
-dictionary MozStkGeneralEvent
-{
- /**
- * The type of this event, MozStkGeneralEvent can be used for all Stk Event
- * requires no more parameter than event type, including
- * nsIDOMMozIccManager.STK_EVENT_TYPE_USER_ACTIVITY.
- * nsIDOMMozIccManager.STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE.
- * HCI Connectivity Event(Not defined in interface yet).
- */
- unsigned short eventType;
-};
diff --git a/dom/icc/interfaces/moz.build b/dom/icc/interfaces/moz.build
index caf6a9d6b..1bd27608e 100644
--- a/dom/icc/interfaces/moz.build
+++ b/dom/icc/interfaces/moz.build
@@ -5,17 +5,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
- 'SimToolKit.idl',
- 'nsIDOMIccCardLockErrorEvent.idl',
- 'nsIDOMIccManager.idl',
+ 'nsIIccInfo.idl',
'nsIIccProvider.idl',
- 'nsINavigatorIccManager.idl',
]
-XPIDL_MODULE = 'dom_icc'
-
-XPIDL_FLAGS += [
- '-I$(topsrcdir)/dom/interfaces/base',
- '-I$(topsrcdir)/dom/interfaces/events',
-]
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+ XPIDL_SOURCES += [
+ 'nsIIccMessenger.idl',
+ ]
+XPIDL_MODULE = 'dom_icc'
diff --git a/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl b/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl
deleted file mode 100644
index 50fb98aec..000000000
--- a/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl
+++ /dev/null
@@ -1,24 +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 "nsIDOMEvent.idl"
-
-[scriptable, builtinclass, uuid(47d4db10-a258-11e2-9e96-0800200c9a66)]
-interface nsIDOMIccCardLockErrorEvent : nsIDOMEvent
-{
- readonly attribute DOMString lockType;
- readonly attribute long retryCount;
-
- [noscript] void initIccCardLockErrorEvent(in DOMString aType,
- in boolean aCanBubble,
- in boolean aCancelable,
- in DOMString aLockType,
- in int32_t aRetryCount);
-};
-
-dictionary IccCardLockErrorEventInit : EventInit
-{
- DOMString lockType;
- long retryCount;
-};
diff --git a/dom/icc/interfaces/nsIDOMIccManager.idl b/dom/icc/interfaces/nsIDOMIccManager.idl
deleted file mode 100644
index 540ee1038..000000000
--- a/dom/icc/interfaces/nsIDOMIccManager.idl
+++ /dev/null
@@ -1,490 +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"
-#include "SimToolKit.idl"
-
-interface nsIDOMEventListener;
-interface nsIDOMDOMRequest;
-interface nsIDOMContact;
-
-[scriptable, builtinclass, uuid(b4e16bb0-a258-11e2-9e96-0800200c9a66)]
-interface nsIDOMMozIccManager : nsIDOMEventTarget
-{
- /**
- * STK Menu Presentation types.
- */
- const unsigned short STK_MENU_TYPE_NOT_SPECIFIED = 0x00;
- const unsigned short STK_MENU_TYPE_DATA_VALUES = 0x01;
- const unsigned short STK_MENU_TYPE_NAVIGATION_OPTIONS = 0x03;
-
- /**
- * Browser launch mode.
- */
- const unsigned short STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED = 0x00;
- const unsigned short STK_BROWSER_MODE_USING_EXISTING_BROWSER = 0x02;
- const unsigned short STK_BROWSER_MODE_USING_NEW_BROWSER = 0x03;
-
- /**
- * STK Proactive commands.
- *
- * @see TS 11.14, clause 13.4
- */
- const unsigned short STK_CMD_REFRESH = 0x01;
- const unsigned short STK_CMD_POLL_INTERVAL = 0x03;
- const unsigned short STK_CMD_POLL_OFF = 0x04;
- const unsigned short STK_CMD_SET_UP_EVENT_LIST = 0x05;
- const unsigned short STK_CMD_SET_UP_CALL = 0x10;
- const unsigned short STK_CMD_SEND_SS = 0x11;
- const unsigned short STK_CMD_SEND_USSD = 0x12;
- const unsigned short STK_CMD_SEND_SMS = 0x13;
- const unsigned short STK_CMD_SEND_DTMF = 0x14;
- const unsigned short STK_CMD_LAUNCH_BROWSER = 0x15;
- const unsigned short STK_CMD_PLAY_TONE = 0x20;
- const unsigned short STK_CMD_DISPLAY_TEXT = 0x21;
- const unsigned short STK_CMD_GET_INKEY = 0x22;
- const unsigned short STK_CMD_GET_INPUT = 0x23;
- const unsigned short STK_CMD_SELECT_ITEM = 0x24;
- const unsigned short STK_CMD_SET_UP_MENU = 0x25;
- const unsigned short STK_CMD_PROVIDE_LOCAL_INFO = 0x26;
- const unsigned short STK_CMD_TIMER_MANAGEMENT = 0x27;
- const unsigned short STK_CMD_SET_UP_IDLE_MODE_TEXT = 0x28;
-
- /**
- * STK Result code.
- *
- * @see TS 11.14, clause 12.12
- *
- * Results '0X' and '1X' indicate that the command has been performed.
- */
- /** Command performed successfully */
- const unsigned short STK_RESULT_OK = 0x00;
-
- /** Command performed with partial comprehension */
- const unsigned short STK_RESULT_PRFRMD_WITH_PARTIAL_COMPREHENSION = 0x01;
-
- /** Command performed, with missing information */
- const unsigned short STK_RESULT_PRFRMD_WITH_MISSING_INFO = 0x02;
-
- /** REFRESH performed with additional EFs read */
- const unsigned short STK_RESULT_PRFRMD_WITH_ADDITIONAL_EFS_READ = 0x03;
-
- /** Command performed successfully, limited service */
- const unsigned short STK_RESULT_PRFRMD_LIMITED_SERVICE = 0x06;
-
- /** Proactive UICC session terminated by the user */
- const unsigned short STK_RESULT_UICC_SESSION_TERM_BY_USER = 0x10;
-
- /** Backward move in the proactive UICC session requested by the user */
- const unsigned short STK_RESULT_BACKWARD_MOVE_BY_USER = 0x11;
-
- /** No response from user */
- const unsigned short STK_RESULT_NO_RESPONSE_FROM_USER = 0x12;
-
- /** Help information required by the user */
- const unsigned short STK_RESULT_HELP_INFO_REQUIRED = 0x13;
-
- /** USSD or SS transaction terminated by the user */
- const unsigned short STK_RESULT_USSD_SS_SESSION_TERM_BY_USER = 0x14;
-
- /**
- * Results '2X' indicate to the UICC that it may be worth re-trying the
- * command at a later opportunity.
- */
- /** Terminal currently unable to process command */
- const unsigned short STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS = 0x20;
-
- /** Network currently unable to process command */
- const unsigned short STK_RESULT_NETWORK_CRNTLY_UNABLE_TO_PROCESS = 0x21;
-
- /** User did not accept the proactive command */
- const unsigned short STK_RESULT_USER_NOT_ACCEPT = 0x22;
-
- /** User cleared down call before connection or network release */
- const unsigned short STK_RESULT_USER_CLEAR_DOWN_CALL = 0x23;
-
- /** Launch browser generic error code */
- const unsigned short STK_RESULT_LAUNCH_BROWSER_ERROR = 0x26;
-
- /**
- * Results '3X' indicate that it is not worth the UICC re-trying with an
- * identical command, as it will only get the same response. However, the
- * decision to retry lies with the application.
- */
- /** Command beyond terminal's capabilities */
- const unsigned short STK_RESULT_BEYOND_TERMINAL_CAPABILITY = 0x30;
-
- /** Command type not understood by terminal */
- const unsigned short STK_RESULT_CMD_TYPE_NOT_UNDERSTOOD = 0x31;
-
- /** Command data not understood by terminal */
- const unsigned short STK_RESULT_CMD_DATA_NOT_UNDERSTOOD = 0x32;
-
- /** Command number not known by terminal */
- const unsigned short STK_RESULT_CMD_NUM_NOT_KNOWN = 0x33;
-
- /** SS Return Error */
- const unsigned short STK_RESULT_SS_RETURN_ERROR = 0x34;
-
- /** SMS RP-ERROR */
- const unsigned short STK_RESULT_SMS_RP_ERROR = 0x35;
-
- /** Error, required values are missing */
- const unsigned short STK_RESULT_REQUIRED_VALUES_MISSING = 0x36;
-
- /** USSD Return Error */
- const unsigned short STK_RESULT_USSD_RETURN_ERROR = 0x37;
-
- /** MultipleCard commands error */
- const unsigned short STK_RESULT_MULTI_CARDS_CMD_ERROR = 0x38;
-
- /**
- * Interaction with call control by USIM or MO short message control by
- * USIM, permanent problem
- */
- const unsigned short STK_RESULT_USIM_CALL_CONTROL_PERMANENT = 0x39;
-
- /** Bearer Independent Protocol error */
- const unsigned short STK_RESULT_BIP_ERROR = 0x3a;
-
- /**
- * STK Event List
- */
- const unsigned short STK_EVENT_TYPE_MT_CALL = 0x00;
- const unsigned short STK_EVENT_TYPE_CALL_CONNECTED = 0x01;
- const unsigned short STK_EVENT_TYPE_CALL_DISCONNECTED = 0x02;
- const unsigned short STK_EVENT_TYPE_LOCATION_STATUS = 0x03;
- const unsigned short STK_EVENT_TYPE_USER_ACTIVITY = 0x04;
- const unsigned short STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE = 0x05;
- const unsigned short STK_EVENT_TYPE_CARD_READER_STATUS = 0x06;
- const unsigned short STK_EVENT_TYPE_LANGUAGE_SELECTION = 0x07;
- const unsigned short STK_EVENT_TYPE_BROWSER_TERMINATION = 0x08;
- const unsigned short STK_EVENT_TYPE_DATA_AVAILABLE = 0x09;
- const unsigned short STK_EVENT_TYPE_CHANNEL_STATUS = 0x0a;
- const unsigned short STK_EVENT_TYPE_SINGLE_ACCESS_TECHNOLOGY_CHANGED = 0x0b;
- const unsigned short STK_EVENT_TYPE_DISPLAY_PARAMETER_CHANGED = 0x0c;
- const unsigned short STK_EVENT_TYPE_LOCAL_CONNECTION = 0x0d;
- const unsigned short STK_EVENT_TYPE_NETWORK_SEARCH_MODE_CHANGED = 0x0e;
- const unsigned short STK_EVENT_TYPE_BROWSING_STATUS = 0x0f;
- const unsigned short STK_EVENT_TYPE_FRAMES_INFORMATION_CHANGED = 0x10;
-
- /**
- * The service state of STK Location Status.
- */
- const unsigned short STK_SERVICE_STATE_NORMAL = 0x00;
- const unsigned short STK_SERVICE_STATE_LIMITED = 0x01;
- const unsigned short STK_SERVICE_STATE_UNAVAILABLE = 0x02;
-
- /**
- * Tone type.
- */
- const unsigned short STK_TONE_TYPE_DIAL_TONE = 0x01;
- const unsigned short STK_TONE_TYPE_CALLED_SUBSCRIBER_BUSY = 0x02;
- const unsigned short STK_TONE_TYPE_CONGESTION = 0x03;
- const unsigned short STK_TONE_TYPE_RADIO_PATH_ACK = 0x04;
- const unsigned short STK_TONE_TYPE_RADIO_PATH_NOT_AVAILABLE = 0x05;
- const unsigned short STK_TONE_TYPE_ERROR = 0x06;
- const unsigned short STK_TONE_TYPE_CALL_WAITING_TONE = 0x07;
- const unsigned short STK_TONE_TYPE_RINGING_TONE = 0x08;
- const unsigned short STK_TONE_TYPE_GENERAL_BEEP = 0x10;
- const unsigned short STK_TONE_TYPE_POSITIVE_ACK_TONE = 0x11;
- const unsigned short STK_TONE_TYPE_NEGATIVE_ACK_TONE = 0x12;
-
- /**
- * Time unit
- */
- const unsigned short STK_TIME_UNIT_MINUTE = 0x00;
- const unsigned short STK_TIME_UNIT_SECOND = 0x01;
- const unsigned short STK_TIME_UNIT_TENTH_SECOND = 0x02;
-
- /**
- * Local Information list
- *
- * @see TS 102.223, clause 8.6
- */
- const unsigned short STK_LOCAL_INFO_LOCATION_INFO = 0x00;
- const unsigned short STK_LOCAL_INFO_IMEI = 0x01;
- const unsigned short STK_LOCAL_INFO_DATE_TIME_ZONE = 0x03;
- const unsigned short STK_LOCAL_INFO_LANGUAGE = 0x04;
-
- /**
- * Timer Management
- */
- const unsigned short STK_TIMER_START = 0x00;
- const unsigned short STK_TIMER_DEACTIVATE = 0x01;
- const unsigned short STK_TIMER_GET_CURRENT_VALUE = 0x02;
-
- /**
- * Send the response back to ICC after an attempt to execute STK Proactive
- * Command.
- *
- * @param command
- * Command received from ICC. See MozStkCommand.
- * @param response
- * The response that will be sent to ICC.
- * @see MozStkResponse for the detail of response.
- */
- void sendStkResponse(in jsval command, in jsval response);
-
- /**
- * Send the "Menu Selection" Envelope command to ICC for menu selection.
- *
- * @param itemIdentifier
- * The identifier of the item selected by user.
- * @param helpRequested
- * true if user requests to provide help information, false otherwise.
- */
- void sendStkMenuSelection(in unsigned short itemIdentifier,
- in boolean helpRequested);
-
- /**
- * Send the "Timer Expiration" Envelope command to ICC for TIMER MANAGEMENT.
- `*
- * @param timer
- * The identifier and value for a timer.
- * timerId: Identifier of the timer that has expired.
- * timerValue: Different between the time when this command is issued
- * and when the timer was initially started.
- * @see MozStkTimer
- */
- void sendStkTimerExpiration(in jsval timer);
-
- /**
- * Send "Event Download" Envelope command to ICC.
- * ICC will not respond with any data for this command.
- *
- * @param event
- * one of events below:
- * - MozStkLocationEvent
- * - MozStkCallEvent
- * - MozStkLanguageSelectionEvent
- * - MozStkGeneralEvent
- */
- void sendStkEventDownload(in jsval event);
-
- /**
- * The 'stkcommand' event is notified whenever STK Proactive Command is
- * issued from ICC.
- */
- [implicit_jscontext] attribute jsval onstkcommand;
-
- /**
- * 'stksessionend' event is notified whenever STK Session is terminated by
- * ICC.
- */
- [implicit_jscontext] attribute jsval onstksessionend;
-
- // UICC Card Lock interfaces.
-
- /**
- * Find out about the status of an ICC lock (e.g. the PIN lock).
- *
- * @param lockType
- * Identifies the lock type, e.g. "pin" for the PIN lock, "fdn" for
- * the FDN lock.
- *
- * @return a DOM Request.
- * The request's result will be an object containing
- * information about the specified lock's status,
- * e.g. {lockType: "pin", enabled: true}.
- */
- nsIDOMDOMRequest getCardLock(in DOMString lockType);
-
- /**
- * Unlock a card lock.
- *
- * @param info
- * An object containing the information necessary to unlock
- * the given lock. At a minimum, this object must have a
- * "lockType" attribute which specifies the type of lock, e.g.
- * "pin" for the PIN lock. Other attributes are dependent on
- * the lock type.
- *
- * Examples:
- *
- * (1) Unlocking the PIN:
- *
- * unlockCardLock({lockType: "pin",
- * pin: "..."});
- *
- * (2) Unlocking the PUK and supplying a new PIN:
- *
- * unlockCardLock({lockType: "puk",
- * puk: "...",
- * newPin: "..."});
- *
- * (3) Network depersonalization. Unlocking the network control key (NCK).
- *
- * unlockCardLock({lockType: "nck",
- * pin: "..."});
- *
- * (4) Corporate depersonalization. Unlocking the corporate control key (CCK).
- *
- * unlockCardLock({lockType: "cck",
- * pin: "..."});
- *
- * (5) Service Provider depersonalization. Unlocking the service provider
- * control key (SPCK).
- *
- * unlockCardLock({lockType: "spck",
- * pin: "..."});
- *
- * @return a nsIDOMDOMRequest.
- * The request's result will be an object containing
- * information about the unlock operation.
- *
- * Examples:
- *
- * (1) Unlocking failed:
- *
- * {
- * lockType: "pin",
- * success: false,
- * retryCount: 2
- * }
- *
- * (2) Unlocking succeeded:
- *
- * {
- * lockType: "pin",
- * success: true
- * }
- */
- nsIDOMDOMRequest unlockCardLock(in jsval info);
-
- /**
- * Modify the state of a card lock.
- *
- * @param info
- * An object containing information about the lock and
- * how to modify its state. At a minimum, this object
- * must have a "lockType" attribute which specifies the
- * type of lock, e.g. "pin" for the PIN lock. Other
- * attributes are dependent on the lock type.
- *
- * Examples:
- *
- * (1a) Disabling the PIN lock:
- *
- * setCardLock({lockType: "pin",
- * pin: "...",
- * enabled: false});
- *
- * (1b) Disabling the FDN lock:
- *
- * setCardLock({lockType: "fdn",
- * pin2: "...",
- * enabled: false});
- *
- * (2) Changing the PIN:
- *
- * setCardLock({lockType: "pin",
- * pin: "...",
- * newPin: "..."});
- *
- * @return a nsIDOMDOMRequest.
- * The request's result will be an object containing
- * information about the operation.
- *
- * Examples:
- *
- * (1) Enabling/Disabling card lock failed or change card lock failed.
- *
- * {
- * lockType: "pin",
- * success: false,
- * retryCount: 2
- * }
- *
- * (2) Enabling/Disabling card lock succeed or change card lock succeed.
- *
- * {
- * lockType: "pin",
- * success: true
- * }
- */
- nsIDOMDOMRequest setCardLock(in jsval info);
-
- /**
- * The 'icccardlockerror' event is notified whenever 'unlockCardLock' or
- * 'setCardLock' fails.
- *
- * The result will be an object containing information
- * about the specified lock's status,
- * e.g. {lockType: "pin", retryCount: 2}.
- */
- [implicit_jscontext] attribute jsval onicccardlockerror;
-
- // UICC Phonebook Interfaces.
-
- /**
- * Read ICC contacts.
- *
- * @param contactType
- * One of type as below,
- * - 'adn': Abbreviated Dialling Number
- * - 'fdn': Fixed Dialling Number
- */
- nsIDOMDOMRequest readContacts(in DOMString contactType);
-
- /**
- * Update ICC Phonebook contact.
- *
- * @param contactType
- * One of type as below,
- * - 'adn': Abbreviated Dialling Number
- * - 'fdn': Fixed Dialling Number
- * @param contact
- * The contact will be updated in ICC
- * @param [optional] pin2
- * PIN2 is only required for 'fdn'.
- */
- nsIDOMDOMRequest updateContact(in DOMString contactType,
- in nsIDOMContact contact,
- [optional] in DOMString pin2);
-
- // End of UICC Phonebook Interfaces.
-
- // UICC Secure Element Interfaces
-
- /**
- * A secure element is a smart card chip that can hold
- * several different applications with the necessary security.
- * The most known secure element is the Universal Integrated Circuit Card (UICC)
- */
-
- /**
- * Send request to open a logical channel defined by its
- * application identifier (AID)
- *
- * @param aid
- * The Application Identifier of the Applet to be selected on this channel
- * return value : An instance of Channel (channelID) if available or null.
- */
- nsIDOMDOMRequest iccOpenChannel(in DOMString aid);
-
- /**
- * Interface, used to communicate with an applet through the
- * Application Data Protocol Units (APDUs) and is
- * used for all data that is exchanged between the UICC card and the terminal (ME).
- *
- * @param channel
- * The Application Identifier of the Applet to which APDU is directed
- * @param apdu
- * Application Protocol Data Unit
- * return value : Response APDU
- */
- nsIDOMDOMRequest iccExchangeAPDU(in long channel, in jsval apdu);
-
- /**
- * Send request to close the selected logical channel identified by its
- * application identifier (AID)
- *
- * @param aid
- * The Application Identifier of the Applet , to be closed
- */
- nsIDOMDOMRequest iccCloseChannel(in long channel);
-
- // End of UICC Secure Element Interfaces
-};
diff --git a/dom/icc/interfaces/nsIIccInfo.idl b/dom/icc/interfaces/nsIIccInfo.idl
new file mode 100644
index 000000000..8dc26d855
--- /dev/null
+++ b/dom/icc/interfaces/nsIIccInfo.idl
@@ -0,0 +1,70 @@
+/* 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 "nsISupports.idl"
+
+[scriptable, uuid(3ba11a90-34e0-11e4-8c21-0800200c9a66)]
+interface nsIIccInfo : nsISupports
+{
+ /**
+ * Integrated Circuit Card Type.
+ *
+ * Possible values: null(unknown), "sim", "usim", "csim", ruim".
+ */
+ readonly attribute DOMString iccType;
+
+ /**
+ * Integrated Circuit Card Identifier.
+ */
+ readonly attribute DOMString iccid;
+
+ /**
+ * Mobile Country Code (MCC) of the subscriber's home network.
+ */
+ readonly attribute DOMString mcc;
+
+ /**
+ * Mobile Network Code (MNC) of the subscriber's home network.
+ */
+ readonly attribute DOMString mnc;
+
+ /**
+ * Service Provider Name (SPN) of the subscriber's home network.
+ */
+ readonly attribute DOMString spn;
+
+ /**
+ * Network name must be a part of displayed carrier name.
+ */
+ readonly attribute boolean isDisplayNetworkNameRequired;
+
+ /**
+ * Service provider name must be a part of displayed carrier name.
+ */
+ readonly attribute boolean isDisplaySpnRequired;
+};
+
+[scriptable, uuid(6c9c78b0-34e0-11e4-8c21-0800200c9a66)]
+interface nsIGsmIccInfo : nsIIccInfo
+{
+ /**
+ * Mobile Station ISDN Number (MSISDN) of the subscriber, aka
+ * his phone number.
+ */
+ readonly attribute DOMString msisdn;
+};
+
+[scriptable, uuid(7452f570-34e0-11e4-8c21-0800200c9a66)]
+interface nsICdmaIccInfo : nsIIccInfo
+{
+ /**
+ * Mobile Directory Number (MDN) of the subscriber, aka his phone number.
+ */
+ readonly attribute DOMString mdn;
+
+ /**
+ * Preferred Roaming List (PRL) version of the subscriber.
+ */
+ readonly attribute long prlVersion;
+};
diff --git a/dom/icc/interfaces/nsIIccMessenger.idl b/dom/icc/interfaces/nsIIccMessenger.idl
new file mode 100644
index 000000000..93c30c04c
--- /dev/null
+++ b/dom/icc/interfaces/nsIIccMessenger.idl
@@ -0,0 +1,660 @@
+/* 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 "nsISupports.idl"
+
+[scriptable, uuid(1510cf0c-5db6-11e4-9869-6bf419e26642)]
+interface nsIStkDuration : nsISupports
+{
+ /**
+ * The value of Time units defined in 12.8 Duration of TS 11.14.
+ */
+ readonly attribute unsigned short timeUnit;
+
+ /**
+ * The length of time required, expressed in timeUnit.
+ *
+ * Note: the range is from 1 unit to 255 units.
+ */
+ readonly attribute unsigned short timeInterval;
+};
+
+[scriptable, uuid(c7b6e57a-696d-11e4-bcaa-bfe8386e75a9)]
+interface nsIStkIcon : nsISupports
+{
+ /**
+ * The color coding schemes defined in 4.6.1.1 of TS 31.102.
+ */
+ const unsigned short CODING_SCHEME_BASIC = 0x11;
+ const unsigned short CODING_SCHEME_COLOR = 0x21;
+ const unsigned short CODING_SCHEME_COLOR_TRANSPARENCY = 0x22;
+
+ /**
+ * Width of the icon.
+ */
+ readonly attribute unsigned long width;
+
+ /**
+ * Height of the icon.
+ */
+ readonly attribute unsigned long height;
+
+ /**
+ * Image coding scheme of the icon.
+ * One of CODING_SCHEME_*.
+ */
+ readonly attribute unsigned short codingScheme;
+
+ /**
+ * Array of pixels. Each pixel represents a color in the RGBA format made up
+ * of four bytes, that is, the Red sample in the highest 8 bits, followed by
+ * the Green sample, Blue sample and the Alpha sample in the lowest 8 bits.
+ *
+ * @param aCount
+ * The number of pixels.
+ *
+ * @returns a copy of the array of pixels.
+ */
+ void getPixels([optional] out unsigned long aCount,
+ [array, size_is(aCount), retval] out unsigned long aPixels);
+};
+
+[scriptable, uuid(4a6d173e-5e8b-11e4-9d78-071bb3d6ba8f)]
+interface nsIStkIconInfo : nsISupports
+{
+ /**
+ * Indicates how the icon is to be used.
+ *
+ * @see TS 11.14, clause 12.31, Icon Identifier.
+ *
+ * true: icon replaces the text string.
+ * false: icon shall be displayed together with the text string.
+ */
+ readonly attribute boolean iconSelfExplanatory;
+
+ /**
+ * Icon(s) that replaces or accompanies the text string.
+ *
+ * @see TS 11.14, clause 12.31, Icon Identifier.
+ *
+ * Array of icons, basically of a same image, that may differ in size,
+ * resolution or coding scheme. The first icon should be the default one.
+ *
+ * @param aCount
+ * The number of icons.
+ *
+ * @returns a copy of the list of icons.
+ */
+ void getIcons([optional] out unsigned long aCount,
+ [array, size_is(aCount), retval] out nsIStkIcon aIcons);
+};
+
+[scriptable, uuid(ea95d25c-5e84-11e4-bd96-07285c50c1f2)]
+interface nsIStkItem : nsISupports
+{
+ /**
+ * Identifier of item.
+ *
+ * The identifier is a single byte between '01' and 'FF'. Each item shall
+ * have a unique identifier within an Item list.
+ */
+ readonly attribute unsigned short identifier;
+
+ /**
+ * Text string of item.
+ */
+ readonly attribute DOMString text;
+
+ /**
+ * (Optional)
+ * Icon info of item.
+ */
+ readonly attribute nsIStkIconInfo iconInfo;
+};
+
+[scriptable, uuid(222651f0-6976-11e4-accf-736a9c6e7d19)]
+interface nsIStkTimer : nsISupports
+{
+ /**
+ * Identifier of a timer.
+ */
+ readonly attribute unsigned short timerId;
+
+ const unsigned long TIMER_VALUE_INVALID = 0xFFFFFFFF;
+
+ /**
+ * Length of time during which the timer has to run.
+ *
+ * The possible duration of a timer is between 1 s and 24 h.
+ * The resolution of a timer is 1 second.
+ *
+ * Note: In TS 11.14, clause 6.6.21 TIMER MANAGEMENT,
+ * "
+ * The SIM shall supply this data object only when a timer has to
+ * be started.
+ * "
+ * Hence, set to TIMER_VALUE_INVALID when |timerAction| is not equal to
+ * TIMER_ACTION_START.
+ */
+ readonly attribute unsigned long timerValue;
+
+ /*
+ * Times actions defined in TS 11.14, clause 12.6,
+ * Command Qualifier, TIMER MANAGEMENT
+ */
+ const unsigned short TIMER_ACTION_START = 0x00;
+ const unsigned short TIMER_ACTION_DEACTIVATE = 0x01;
+ const unsigned short TIMER_ACTION_GET_CURRENT_VALUE = 0x02;
+
+ /**
+ * The action requested from UICC.
+ * It shall be one of TIMER_ACTION_*.
+ */
+ readonly attribute unsigned short timerAction;
+};
+
+/**
+ * The base class of all STK Proactive Commands.
+ *
+ * This interface is to be applied by the commands that provide info no more than:
+ * |commandNumber|, |typeOfCommand|, |commandQualifier|.
+ *
+ * The commands in this category are:
+ * - STK_CMD_REFRESH
+ * - STK_CMD_POLL_OFF
+ */
+[scriptable, uuid(f47f25b2-5d84-11e4-8637-7f59ea6da82f)]
+interface nsIStkProactiveCmd : nsISupports
+{
+ /**
+ * The number of command issued by ICC. And it is assigned
+ * by ICC may take any hexadecimal value betweean '01' and 'FE'.
+ *
+ * @see TS 11.14, clause 6.5.1
+ */
+ readonly attribute unsigned short commandNumber;
+
+ /**
+ * The value of |Type of Command| defined in TS 11.14, clause 13.4
+ */
+ readonly attribute unsigned short typeOfCommand;
+
+ /**
+ * Qualifiers specific to the command.
+ */
+ readonly attribute unsigned short commandQualifier;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_POLL_INTERVAL.
+ */
+[scriptable, uuid(0a27c090-5dbc-11e4-92eb-ebc26db3db29)]
+interface nsIStkPollIntervalCmd : nsIStkProactiveCmd
+{
+ /**
+ * The maximum interval between two STATUS commands related to
+ * Proactive Polling.
+ *
+ * Note: Mandatory for STK_CMD_POLL_INTERVAL.
+ *
+ * @See TS 11.14, clause 6.6.6 POLL INTERVAL
+ */
+ readonly attribute nsIStkDuration duration;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_PROVIDE_LOCAL_INFO.
+ */
+[scriptable, uuid(89a304ce-5dc6-11e4-8dce-23723fb242b4)]
+interface nsIStkProvideLocalInfoCmd : nsIStkProactiveCmd
+{
+ /**
+ * Values defined in TS 11.14, clause 12.6, Command Qualifier,
+ * PROVIDE LOCAL INFORMATION
+ */
+ readonly attribute unsigned short localInfoType;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_SET_UP_EVENT_LIST.
+ */
+[scriptable, uuid(5f796dec-5e6a-11e4-aaf3-bb675cb36df5)]
+interface nsIStkSetupEventListCmd : nsIStkProactiveCmd
+{
+ /**
+ * (Optional)
+ * Get the list of events.
+ * Each event could be one of values defined in TS 11.14, clause 8.25, Event list.
+ *
+ * Note: It could be null as an indication to the terminal to remove the
+ * existing list of events in the terminal.
+ *
+ * @param aCount
+ * The number of events.
+ *
+ * @returns a copy of the list of events.
+ */
+ void getEventList([optional] out unsigned long aCount,
+ [array, size_is(aCount), retval] out unsigned short aEventList);
+};
+
+/**
+ * This interface is to be applied by STK_CMD_SET_UP_MENU.
+ */
+[scriptable, uuid(d7a66664-a602-11e4-9cc7-c7ce5fdade7d)]
+interface nsIStkSetUpMenuCmd : nsIStkProactiveCmd
+{
+ /**
+ * (Optional for STK_CMD_SELECT_ITEM)
+ * Title of the menu.
+ */
+ readonly attribute DOMString title;
+
+ /**
+ * Get the list of menu items.
+ *
+ * Note: The minimal number of items is 1.
+ * See TS 11.14, clause 6.6.7 SET-UP MENU and 6.6.8 SELECT ITEM.
+ *
+ * @param aCount
+ * The number of items.
+ *
+ * @returns a copy of the list of menu items.
+ * For |SET-UP MENU|, the 1st item in |aItems| could be null as an
+ * indication to the ME to remove the existing menu from the menu
+ * system in the ME.
+ */
+ void getItems([optional] out unsigned long aCount,
+ [array, size_is(aCount), retval] out nsIStkItem aItems);
+
+ /**
+ * (Optional)
+ * Get the list of Next Action Indicators.
+ *
+ * Each element should be the value of |Next Action Indicator| in TS 11.14,
+ * clause 13.4.
+ *
+ * @see TS 11.14, clause 12.24, Items Next Action Indicator.
+ *
+ * @param aCount
+ * The number of indicators.
+ *
+ * @returns a copy of the list of Next Action Indicators.
+ */
+ void getNextActionList([optional] out unsigned long aCount,
+ [array, size_is(aCount), retval] out unsigned short aActions);
+
+ /**
+ * (Optional)
+ * Icon info of the menu.
+ */
+ readonly attribute nsIStkIconInfo iconInfo;
+
+ /**
+ * Help information available or not.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 8.
+ *
+ * true: help information available.
+ * false: no help information available.
+ *
+ */
+ readonly attribute boolean isHelpAvailable;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_SELECT_ITEM.
+ */
+[scriptable, uuid(eb71f0fa-a602-11e4-926f-a3814461d218)]
+interface nsIStkSelectItemCmd : nsIStkSetUpMenuCmd
+{
+ /**
+ * Presentation type, one of PRESENTATION_TYPE_*.
+ *
+ * @See TS 11.14, clause 12.6, Command Qualifier: Select Item
+ */
+ const unsigned short PRESENTATION_TYPE_NOT_SPECIFIED = 0x00;
+ const unsigned short PRESENTATION_TYPE_DATA_VALUES = 0x01;
+ const unsigned short PRESENTATION_TYPE_NAVIGATION_OPTIONS = 0x03;
+
+ readonly attribute unsigned short presentationType;
+
+ const unsigned short DEFAULT_ITEM_INVALID = 0xFFFF;
+
+ /**
+ * (Optional)
+ * Default item identifier of the menu.
+ *
+ * Set to DEFAULT_ITEM_INVALID if null.
+ */
+ readonly attribute unsigned short defaultItem;
+};
+
+/**
+ * This interface is to be applied by
+ * - STK_CMD_SET_UP_IDLE_MODE_TEXT
+ * - STK_CMD_SEND_{SS|USSD|SMS|DTMF}
+ * - STK_CMD_OPEN_CHANNEL
+ * - STK_CMD_CLOSE_CHANNEL
+ * - STK_CMD_SEND_DATA
+ * - STK_CMD_RECEIVE_DATA
+ */
+[scriptable, uuid(61c42b3c-6324-11e4-959e-7fb2dc9a3f0d)]
+interface nsIStkTextMessageCmd : nsIStkProactiveCmd
+{
+ /**
+ * Text String.
+ */
+ readonly attribute DOMString text;
+
+ /**
+ * (Optional)
+ * Icon to be displayed.
+ */
+ readonly attribute nsIStkIconInfo iconInfo;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_DISPLAY_TEXT.
+ */
+[scriptable, uuid(66a83f0a-6322-11e4-a773-9382de87a74a)]
+interface nsIStkDisplayTextCmd : nsIStkTextMessageCmd
+{
+ /**
+ * (Optional)
+ * The length of time for which the ME shall display the dialog.
+ */
+ readonly attribute nsIStkDuration duration;
+
+ /**
+ * Indicate this text message is high priority or normal priority.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 1.
+ *
+ * true: high priority
+ * false: normal priority
+ */
+ readonly attribute boolean isHighPriority;
+
+ /**
+ * Need to wait for user to clear message or not.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 8.
+ *
+ * true: Wait for user to clear message.
+ * false: clear message after a delay.
+ */
+ readonly attribute boolean userClear;
+
+ /**
+ * Need to response immediately or not.
+ *
+ * @see TS 11.14, clause 12.43, Immediate response.
+ *
+ * true: The terminal shall send response immediately.
+ * false: otherwise.
+ */
+ readonly attribute boolean responseNeeded;
+};
+
+/**
+ * The base interface of nsIStkInputKeyCmd, nsIStkInputTextCmd.
+ */
+[scriptable, uuid(ed16a67e-6022-11e4-a8fd-c34fe6e6bb11)]
+interface nsIStkInputCmd : nsIStkProactiveCmd
+{
+ /**
+ * Text for the ME to display in conjunction with asking the user to respond.
+ */
+ readonly attribute DOMString text;
+
+ /**
+ * (Optional)
+ * The length of time for which the ME shall display the dialog.
+ */
+ readonly attribute nsIStkDuration duration;
+
+ /**
+ * Minimum length of response.
+ * Set to 1 for STK_CMD_GET_INKEY.
+ */
+ readonly attribute unsigned short minLength;
+
+ /**
+ * Maximum length of response.
+ * Set to 1 for STK_CMD_GET_INKEY.
+ */
+ readonly attribute unsigned short maxLength;
+
+ /**
+ * (Optional)
+ * Text for the ME to display, corresponds to a default text string offered
+ * by the ICC.
+ */
+ readonly attribute DOMString defaultText;
+
+ /**
+ * Input format.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 1.
+ *
+ * true: Alphabet set.
+ * false: Digits only.
+ */
+ readonly attribute boolean isAlphabet;
+
+ /**
+ * Alphabet encoding.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 2.
+ *
+ * true: UCS2 alphabet.
+ * false: default SMS alphabet.
+ */
+ readonly attribute boolean isUCS2;
+
+ /**
+ * Help information available or not.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 8.
+ *
+ * true: help information available.
+ * false: no help information available.
+ */
+ readonly attribute boolean isHelpAvailable;
+
+ /**
+ * (Optional)
+ * Icon to be displayed.
+ */
+ readonly attribute nsIStkIconInfo iconInfo;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_GET_INKEY.
+ */
+[scriptable, uuid(27a4078a-6025-11e4-a9ab-bf39252bfaf1)]
+interface nsIStkInputKeyCmd : nsIStkInputCmd
+{
+ /**
+ * Yes/No response is requested.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.
+ *
+ * true: Yes/No response is requested, and character sets
+ * (Alphabet set and UCS2) are disabled.
+ * false: Character sets (Alphabet set and UCS2) are enabled.
+ */
+ readonly attribute boolean isYesNoRequested;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_GET_INPUT.
+ */
+[scriptable, uuid(f3c33ae8-60d4-11e4-9da8-4ff4cb8566c3)]
+interface nsIStkInputTextCmd : nsIStkInputCmd
+{
+ /**
+ * Visibility of input.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 3.
+ *
+ * true: User input shall not be revealed in any way.
+ * false: ME may echo user input on the display.
+ */
+ readonly attribute boolean hideInput;
+
+ /**
+ * User input in packed or unpacked format.
+ *
+ * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 4.
+ *
+ * true: User input to be in SMS packed format.
+ * false: User input to be in unpacked format.
+ */
+ readonly attribute boolean isPacked;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_SET_UP_CALL.
+ */
+[scriptable, uuid(6abbf688-6956-11e4-a9d3-4b07f063ef21)]
+interface nsIStkSetUpCallCmd : nsIStkProactiveCmd
+{
+ /**
+ * The Dialling number.
+ */
+ readonly attribute DOMString address;
+
+ /**
+ * (Optional)
+ * The text message used in user confirmation phase.
+ */
+ readonly attribute DOMString confirmText;
+
+ /**
+ * (Optional)
+ * Icon to be displayed in user confirmation phase.
+ */
+ readonly attribute nsIStkIconInfo confirmIconInfo;
+
+ /**
+ * (Optional)
+ * The text message used in call set up phase.
+ */
+ readonly attribute DOMString callText;
+
+ /**
+ * (Optional)
+ * Icon to be displayed in call set up phase.
+ */
+ readonly attribute nsIStkIconInfo callIconInfo;
+
+ /**
+ * (Optional)
+ * The maximum duration for the redial mechanism.
+ * The time elapsed since the first call set-up attempt has exceeded the duration
+ * requested by the UICC, the redial mechanism is terminated.
+ */
+ readonly attribute nsIStkDuration duration;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_LAUNCH_BROWSER.
+ */
+[scriptable, uuid(b9bca548-695b-11e4-8c1f-cfb850f421ab)]
+interface nsIStkBrowserSettingCmd : nsIStkProactiveCmd
+{
+ /**
+ * The URL to be opened by browser.
+ */
+ readonly attribute DOMString url;
+
+ /**
+ * Browser launch mode.
+ * @See TS 11.14, clause 12.6, Command Qualifier, LAUNCH BROWSER.
+ */
+ readonly attribute unsigned short mode;
+
+ /**
+ * (Optional)
+ * Confirm message to launch browser.
+ */
+ readonly attribute DOMString confirmText;
+
+ /**
+ * (Optional)
+ * Icon to be displayed in user confirmation phase.
+ */
+ readonly attribute nsIStkIconInfo confirmIconInfo;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_PLAY_TONE.
+ */
+[scriptable, uuid(f49dd148-60ee-11e4-af46-6b938538de51)]
+interface nsIStkPlayToneCmd : nsIStkProactiveCmd
+{
+ const unsigned short TONE_TYPE_INVALID = 0xFFFF;
+
+ /**
+ * (Optional)
+ * Text String.
+ */
+ readonly attribute DOMString text;
+
+ /**
+ * (Optional)
+ * One of the tone value coded in TS 11.14, clause 12.16, Tone.
+ *
+ * Set to TONE_TYPE_INVALID if null.
+ */
+ readonly attribute unsigned short tone;
+
+ /**
+ * (Optional)
+ * The length of time for which the ME shall generate the tone.
+ */
+ readonly attribute nsIStkDuration duration;
+
+ /**
+ * Need to vibrate or not.
+ * true: vibrate alert, if available, with the tone.
+ * false: use of vibrate alert is up to the ME.
+ */
+ readonly attribute boolean isVibrate;
+
+ /**
+ * (Optional)
+ * Icon to be displayed.
+ */
+ readonly attribute nsIStkIconInfo iconInfo;
+};
+
+/**
+ * This interface is to be applied by STK_CMD_TIMER_MANAGEMENT.
+ */
+[scriptable, uuid(e421b122-60f3-11e4-b8d7-bfe75825a796)]
+interface nsIStkTimerManagementCmd : nsIStkProactiveCmd
+{
+ /**
+ * Timer Information.
+ */
+ readonly attribute nsIStkTimer timerInfo;
+};
+
+[scriptable, uuid(000696fe-5d85-11e4-8da2-2fdf3880276b)]
+interface nsIIccMessenger : nsISupports
+{
+ /**
+ * To broadcast 'icc-stkcommand' system message
+ *
+ * @param aIccId
+ * Integrated Circuit Card Identifier.
+ * @param aCommand
+ * An instance of nsIStkProactiveCmd or its sub-class.
+ */
+ void notifyStkProactiveCommand(in DOMString aIccId,
+ in nsIStkProactiveCmd aCommand);
+};
diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl
index 3c42f9a7d..94f09d05d 100644
--- a/dom/icc/interfaces/nsIIccProvider.idl
+++ b/dom/icc/interfaces/nsIIccProvider.idl
@@ -4,75 +4,250 @@
#include "nsISupports.idl"
-interface nsIDOMWindow;
interface nsIDOMDOMRequest;
-interface nsIDOMContact;
+interface nsIDOMWindow;
+interface nsIIccInfo;
-[scriptable, uuid(dca08580-a25a-11e2-9e96-0800200c9a66)]
+[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
interface nsIIccListener : nsISupports
{
void notifyStkCommand(in DOMString aMessage);
void notifyStkSessionEnd();
- void notifyIccCardLockError(in DOMString lockType,
- in unsigned long retryCount);
+ void notifyCardStateChanged();
+ void notifyIccInfoChanged();
+};
+
+[scriptable, uuid(6136acab-b50e-494a-a86d-df392a032897)]
+interface nsIIccChannelCallback : nsISupports
+{
+ /**
+ * Callback function to notify on successfully opening a logical channel.
+ *
+ * @param channel
+ * The Channel Number/Handle that is successfully opened.
+ */
+ void notifyOpenChannelSuccess(in long channel);
+
+ /**
+ * Callback function to notify on successfully closing the logical channel.
+ *
+ */
+ void notifyCloseChannelSuccess();
+
+ /**
+ * Callback function to notify the status of 'iccExchangeAPDU' command.
+ *
+ * @param sw1
+ * Response's First Status Byte
+ * @param sw2
+ * Response's Second Status Byte
+ * @param data
+ * Response's data
+ */
+ void notifyExchangeAPDUResponse(in octet sw1,
+ in octet sw2,
+ in DOMString data);
+
+ /**
+ * Callback function to notify error
+ *
+ */
+ void notifyError(in DOMString error);
};
/**
* XPCOM component (in the content process) that provides the ICC information.
*/
-[scriptable, uuid(e60ec460-a25a-11e2-9e96-0800200c9a66)]
+[scriptable, uuid(a203cd2e-2280-4d8e-a687-42b745d322c1)]
interface nsIIccProvider : nsISupports
{
+ // MUST match enum IccCardState in MozIcc.webidl!
+ const unsigned long CARD_STATE_UNKNOWN = 0;
+ const unsigned long CARD_STATE_READY = 1;
+ const unsigned long CARD_STATE_PIN_REQUIRED = 2;
+ const unsigned long CARD_STATE_PUK_REQUIRED = 3;
+ const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
+ const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5;
+ const unsigned long CARD_STATE_PERSONALIZATION_READY = 6;
+ const unsigned long CARD_STATE_NETWORK_LOCKED = 7;
+ const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8;
+ const unsigned long CARD_STATE_CORPORATE_LOCKED = 9;
+ const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10;
+ const unsigned long CARD_STATE_SIM_LOCKED = 11;
+ const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12;
+ const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13;
+ const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14;
+ const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15;
+ const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16;
+ const unsigned long CARD_STATE_NETWORK1_LOCKED = 17;
+ const unsigned long CARD_STATE_NETWORK2_LOCKED = 18;
+ const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19;
+ const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20;
+ const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21;
+ const unsigned long CARD_STATE_RUIM_LOCKED = 22;
+ const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23;
+ const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24;
+ const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
+ const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
+ const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
+ const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
+ const unsigned long CARD_STATE_ILLEGAL = 29;
+
+ const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
+
+ // MUST match with enum IccLockType in MozIcc.webidl
+ const unsigned long CARD_LOCK_TYPE_PIN = 0;
+ const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
+ const unsigned long CARD_LOCK_TYPE_PUK = 2;
+ const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
+ const unsigned long CARD_LOCK_TYPE_NCK = 4;
+ const unsigned long CARD_LOCK_TYPE_NSCK = 5;
+ const unsigned long CARD_LOCK_TYPE_NCK1 = 6;
+ const unsigned long CARD_LOCK_TYPE_NCK2 = 7;
+ const unsigned long CARD_LOCK_TYPE_HNCK = 8;
+ const unsigned long CARD_LOCK_TYPE_CCK = 9;
+ const unsigned long CARD_LOCK_TYPE_SPCK = 10;
+ const unsigned long CARD_LOCK_TYPE_PCK = 11;
+ const unsigned long CARD_LOCK_TYPE_RCCK = 12;
+ const unsigned long CARD_LOCK_TYPE_RSPCK = 13;
+ const unsigned long CARD_LOCK_TYPE_NCK_PUK = 14;
+ const unsigned long CARD_LOCK_TYPE_NSCK_PUK = 15;
+ const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 16;
+ const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 17;
+ const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 18;
+ const unsigned long CARD_LOCK_TYPE_CCK_PUK = 19;
+ const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 20;
+ const unsigned long CARD_LOCK_TYPE_PCK_PUK = 21;
+ const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 22;
+ const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 23;
+ const unsigned long CARD_LOCK_TYPE_FDN = 24;
+
+ // MUST match with enum IccContactType in MozIcc.webidl
+ const unsigned long CARD_CONTACT_TYPE_ADN = 0;
+ const unsigned long CARD_CONTACT_TYPE_FDN = 1;
+ const unsigned long CARD_CONTACT_TYPE_SDN = 2;
+
+ // MUST match with enum IccMvnoType in MozIcc.webidl
+ const unsigned long CARD_MVNO_TYPE_IMSI = 0;
+ const unsigned long CARD_MVNO_TYPE_SPN = 1;
+ const unsigned long CARD_MVNO_TYPE_GID = 2;
+
+ // MUST match with enum IccService in MozIcc.webidl
+ const unsigned long CARD_SERVICE_FDN = 0;
+
/**
* Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has
* the 'mobileconnection' permission is allowed to register.
*/
- void registerIccMsg(in nsIIccListener listener);
- void unregisterIccMsg(in nsIIccListener listener);
+ void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
+ void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
+
+ /**
+ * UICC Information
+ */
+ nsIIccInfo getIccInfo(in unsigned long clientId);
+
+ /**
+ * Card State
+ *
+ * One of the nsIIccProvider.CARD_STATE_* values.
+ */
+ unsigned long getCardState(in unsigned long clientId);
/**
* STK interfaces.
*/
- void sendStkResponse(in nsIDOMWindow window,
- in jsval command,
- in jsval response);
- void sendStkMenuSelection(in nsIDOMWindow window,
+ void sendStkResponse(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in jsval command,
+ in jsval response);
+ void sendStkMenuSelection(in unsigned long clientId,
+ in nsIDOMWindow window,
in unsigned short itemIdentifier,
- in boolean helpRequested);
- void sendStkTimerExpiration(in nsIDOMWindow window,
- in jsval timer);
- void sendStkEventDownload(in nsIDOMWindow window,
- in jsval event);
+ in boolean helpRequested);
+ void sendStkTimerExpiration(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in jsval timer);
+ void sendStkEventDownload(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in jsval event);
/**
* Card lock interfaces.
*/
- nsIDOMDOMRequest getCardLockState(in nsIDOMWindow window, in DOMString lockType);
- nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info);
- nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info);
+ nsIDOMDOMRequest getCardLockEnabled(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long lockType);
+ nsIDOMDOMRequest unlockCardLock(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long lockType,
+ in DOMString password,
+ [optional] in DOMString newPin);
+ nsIDOMDOMRequest setCardLockEnabled(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long lockType,
+ in DOMString password,
+ in boolean enabled);
+ nsIDOMDOMRequest changeCardLockPassword(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long lockType,
+ in DOMString password,
+ in DOMString newPassword);
+ nsIDOMDOMRequest getCardLockRetryCount(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long lockType);
/**
* Phonebook interfaces.
*/
- nsIDOMDOMRequest readContacts(in nsIDOMWindow window,
- in DOMString contactType);
+ nsIDOMDOMRequest readContacts(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long contactType);
- nsIDOMDOMRequest updateContact(in nsIDOMWindow window,
- in DOMString contactType,
- in nsIDOMContact contact,
+ nsIDOMDOMRequest updateContact(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long contactType,
+ in jsval contact,
in DOMString pin2);
- /**
+/**
* Secure Card Icc communication channel
*/
- nsIDOMDOMRequest iccOpenChannel(in nsIDOMWindow window,
- in DOMString aid);
+ void iccOpenChannel(in unsigned long clientId,
+ in DOMString aid,
+ in nsIIccChannelCallback callback);
- nsIDOMDOMRequest iccExchangeAPDU(in nsIDOMWindow window,
- in long channel,
- in jsval apdu);
+ /**
+ * Exchange Command APDU (C-APDU) with SIM on the given logical channel.
+ * Note that 'P3' parameter could be Le/Lc depending on command APDU case.
+ * For Case 1 scenario (when only command header is present), the value
+ * of 'P3' should be set to '-1' explicitly.
+ * Refer to 3G TS 31.101 , 10.2 'Command APDU Structure' for all the cases.
+ */
+ void iccExchangeAPDU(in unsigned long clientId,
+ in long channel,
+ in octet cla,
+ in octet ins,
+ in octet p1,
+ in octet p2,
+ in short p3,
+ in DOMString data,
+ in nsIIccChannelCallback callback);
+
+ void iccCloseChannel(in unsigned long clientId,
+ in long channel,
+ in nsIIccChannelCallback callback);
+
+ /**
+ * Helpers
+ */
+ nsIDOMDOMRequest matchMvno(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long mvnoType,
+ in DOMString mvnoData);
- nsIDOMDOMRequest iccCloseChannel(in nsIDOMWindow window,
- in long channel);
+ nsISupports getServiceState(in unsigned long clientId,
+ in nsIDOMWindow window,
+ in unsigned long service);
};
diff --git a/dom/icc/interfaces/nsINavigatorIccManager.idl b/dom/icc/interfaces/nsINavigatorIccManager.idl
deleted file mode 100644
index 71f427b5a..000000000
--- a/dom/icc/interfaces/nsINavigatorIccManager.idl
+++ /dev/null
@@ -1,16 +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 "nsISupports.idl"
-
-interface nsIDOMMozIccManager;
-
-[scriptable, uuid(17a48e10-9c16-11e2-9e96-0800200c9a65)]
-interface nsIMozNavigatorIccManager : nsISupports
-{
- /**
- * IccManager provides access to ICC related funcionality.
- */
- readonly attribute nsIDOMMozIccManager mozIccManager;
-};
diff --git a/dom/icc/moz.build b/dom/icc/moz.build
index 6834f77cb..9421feb10 100644
--- a/dom/icc/moz.build
+++ b/dom/icc/moz.build
@@ -4,5 +4,35 @@
# 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/.
-PARALLEL_DIRS += ['interfaces', 'src']
-TEST_DIRS += ['tests']
+DIRS += ['interfaces']
+
+EXPORTS.mozilla.dom += [
+ 'Icc.h',
+ 'IccCardLockError.h',
+ 'IccInfo.h',
+ 'IccManager.h',
+]
+
+UNIFIED_SOURCES += [
+ 'Assertions.cpp',
+ 'Icc.cpp',
+ 'IccCardLockError.cpp',
+ "IccInfo.cpp",
+ 'IccListener.cpp',
+ 'IccManager.cpp',
+]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+ EXTRA_JS_MODULES += [
+ 'gonk/StkProactiveCmdFactory.jsm',
+ ]
+
+FAIL_ON_WARNINGS = True
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul'
+
+LOCAL_INCLUDES += [
+ '/dom/system/gonk',
+]
diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp
deleted file mode 100644
index 31a561ac2..000000000
--- a/dom/icc/src/IccManager.cpp
+++ /dev/null
@@ -1,249 +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 "mozilla/Services.h"
-#include "nsIDOMClassInfo.h"
-#include "nsIDOMIccCardLockErrorEvent.h"
-#include "GeneratedEvents.h"
-#include "IccManager.h"
-#include "SimToolKit.h"
-#include "StkCommandEvent.h"
-
-#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
-
-using namespace mozilla::dom::icc;
-
-class IccManager::Listener : public nsIIccListener
-{
- IccManager* mIccManager;
-
-public:
- NS_DECL_ISUPPORTS
- NS_FORWARD_SAFE_NSIICCLISTENER(mIccManager)
-
- Listener(IccManager* aIccManager)
- : mIccManager(aIccManager)
- {
- MOZ_ASSERT(mIccManager);
- }
-
- void
- Disconnect()
- {
- MOZ_ASSERT(mIccManager);
- mIccManager = nullptr;
- }
-};
-
-NS_IMPL_ISUPPORTS1(IccManager::Listener, nsIIccListener)
-
-DOMCI_DATA(MozIccManager, mozilla::dom::icc::IccManager)
-
-NS_INTERFACE_MAP_BEGIN(IccManager)
- NS_INTERFACE_MAP_ENTRY(nsIDOMMozIccManager)
- NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozIccManager)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(IccManager, nsDOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(IccManager, nsDOMEventTargetHelper)
-
-IccManager::IccManager()
-{
- mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
-
- // Not being able to acquire the provider isn't fatal since we check
- // for it explicitly below.
- if (!mProvider) {
- NS_WARNING("Could not acquire nsIIccProvider!");
- return;
- }
-
- mListener = new Listener(this);
- DebugOnly<nsresult> rv = mProvider->RegisterIccMsg(mListener);
- NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
- "Failed registering icc messages with provider");
-}
-
-void
-IccManager::Init(nsPIDOMWindow* aWindow)
-{
- BindToOwner(aWindow);
-}
-
-void
-IccManager::Shutdown()
-{
- if (mProvider && mListener) {
- mListener->Disconnect();
- mProvider->UnregisterIccMsg(mListener);
- mProvider = nullptr;
- mListener = nullptr;
- }
-}
-
-// nsIDOMMozIccManager
-
-NS_IMETHODIMP
-IccManager::SendStkResponse(const JS::Value& aCommand,
- const JS::Value& aResponse)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- mProvider->SendStkResponse(GetOwner(), aCommand, aResponse);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-IccManager::SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- mProvider->SendStkMenuSelection(GetOwner(), aItemIdentifier, aHelpRequested);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-IccManager::SendStkTimerExpiration(const JS::Value& aTimer)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- mProvider->SendStkTimerExpiration(GetOwner(), aTimer);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-IccManager::SendStkEventDownload(const JS::Value& aEvent)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- mProvider->SendStkEventDownload(GetOwner(), aEvent);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-IccManager::GetCardLock(const nsAString& aLockType, nsIDOMDOMRequest** aDomRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->GetCardLockState(GetOwner(), aLockType, aDomRequest);
-}
-
-NS_IMETHODIMP
-IccManager::SetCardLock(const JS::Value& aInfo, nsIDOMDOMRequest** aDomRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->SetCardLock(GetOwner(), aInfo, aDomRequest);
-}
-
-NS_IMETHODIMP
-IccManager::UnlockCardLock(const JS::Value& aInfo, nsIDOMDOMRequest** aDomRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->UnlockCardLock(GetOwner(), aInfo, aDomRequest);
-}
-
-NS_IMETHODIMP
-IccManager::IccOpenChannel(const nsAString& aAid, nsIDOMDOMRequest** aRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->IccOpenChannel(GetOwner(), aAid, aRequest);
-}
-
-NS_IMETHODIMP
-IccManager::IccExchangeAPDU(int32_t aChannel, const jsval& aApdu, nsIDOMDOMRequest** aRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->IccExchangeAPDU(GetOwner(), aChannel, aApdu, aRequest);
-}
-
-NS_IMETHODIMP
-IccManager::IccCloseChannel(int32_t aChannel, nsIDOMDOMRequest** aRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->IccCloseChannel(GetOwner(), aChannel, aRequest);
-}
-
-NS_IMETHODIMP
-IccManager::ReadContacts(const nsAString& aContactType, nsIDOMDOMRequest** aRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->ReadContacts(GetOwner(), aContactType, aRequest);
-}
-
-NS_IMETHODIMP
-IccManager::UpdateContact(const nsAString& aContactType,
- nsIDOMContact* aContact,
- const nsAString& aPin2,
- nsIDOMDOMRequest** aRequest)
-{
- if (!mProvider) {
- return NS_ERROR_FAILURE;
- }
-
- return mProvider->UpdateContact(GetOwner(), aContactType, aContact, aPin2, aRequest);
-}
-
-NS_IMPL_EVENT_HANDLER(IccManager, stkcommand)
-NS_IMPL_EVENT_HANDLER(IccManager, stksessionend)
-NS_IMPL_EVENT_HANDLER(IccManager, icccardlockerror)
-
-// nsIIccListener
-
-NS_IMETHODIMP
-IccManager::NotifyStkCommand(const nsAString& aMessage)
-{
- nsRefPtr<StkCommandEvent> event = StkCommandEvent::Create(this, aMessage);
- NS_ASSERTION(event, "This should never fail!");
-
- return event->Dispatch(this, NS_LITERAL_STRING("stkcommand"));
-}
-
-NS_IMETHODIMP
-IccManager::NotifyStkSessionEnd()
-{
- return DispatchTrustedEvent(NS_LITERAL_STRING("stksessionend"));
-}
-
-NS_IMETHODIMP
-IccManager::NotifyIccCardLockError(const nsAString& aLockType, uint32_t aRetryCount)
-{
- nsCOMPtr<nsIDOMEvent> event;
- NS_NewDOMIccCardLockErrorEvent(getter_AddRefs(event), this, nullptr, nullptr);
-
- nsCOMPtr<nsIDOMIccCardLockErrorEvent> ce = do_QueryInterface(event);
- nsresult rv =
- ce->InitIccCardLockErrorEvent(NS_LITERAL_STRING("icccardlockerror"),
- false, false, aLockType, aRetryCount);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return DispatchTrustedEvent(ce);
-}
diff --git a/dom/icc/src/IccManager.h b/dom/icc/src/IccManager.h
deleted file mode 100644
index 893a01e6a..000000000
--- a/dom/icc/src/IccManager.h
+++ /dev/null
@@ -1,49 +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/. */
-
-#ifndef mozilla_dom_icc_IccManager_h
-#define mozilla_dom_icc_IccManager_h
-
-#include "nsCycleCollectionParticipant.h"
-#include "nsDOMEventTargetHelper.h"
-#include "nsIDOMIccManager.h"
-#include "nsIIccProvider.h"
-
-namespace mozilla {
-namespace dom {
-namespace icc {
-
-class IccManager : public nsDOMEventTargetHelper
- , public nsIDOMMozIccManager
-{
- /**
- * Class IccManager doesn't actually inherit nsIIccListener. Instead, it owns
- * an nsIIccListener derived instance mListener and passes it to
- * nsIIccProvider. The onreceived events are first delivered to mListener and
- * then forwarded to its owner, IccManager. See also bug 775997 comment #51.
- */
- class Listener;
-
-public:
- NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_NSIDOMMOZICCMANAGER
- NS_DECL_NSIICCLISTENER
-
- NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
-
- IccManager();
-
- void Init(nsPIDOMWindow *aWindow);
- void Shutdown();
-
-private:
- nsCOMPtr<nsIIccProvider> mProvider;
- nsRefPtr<Listener> mListener;
-};
-
-} // namespace icc
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_icc_IccManager_h
diff --git a/dom/icc/src/Makefile.in b/dom/icc/src/Makefile.in
deleted file mode 100644
index a2fed7497..000000000
--- a/dom/icc/src/Makefile.in
+++ /dev/null
@@ -1,25 +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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = $(srcdir)
-
-include $(DEPTH)/config/autoconf.mk
-
-LIBRARY_NAME = dom_icc_s
-LIBXUL_LIBRARY = 1
-FORCE_STATIC_LIB = 1
-FAIL_ON_WARNINGS := 1
-
-include $(topsrcdir)/dom/dom-config.mk
-
-LOCAL_INCLUDES = \
- -I$(topsrcdir)/content/events/src \
- $(NULL)
-
-include $(topsrcdir)/config/config.mk
-include $(topsrcdir)/ipc/chromium/chromium-config.mk
-include $(topsrcdir)/config/rules.mk
diff --git a/dom/icc/src/StkCommandEvent.cpp b/dom/icc/src/StkCommandEvent.cpp
deleted file mode 100644
index d4a0ea765..000000000
--- a/dom/icc/src/StkCommandEvent.cpp
+++ /dev/null
@@ -1,51 +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 "nsContentUtils.h"
-#include "SimToolKit.h"
-#include "StkCommandEvent.h"
-
-#include "nsJSON.h"
-#include "jsapi.h"
-#include "jsfriendapi.h"
-
-namespace mozilla {
-namespace dom {
-namespace icc {
-
-already_AddRefed<StkCommandEvent>
-StkCommandEvent::Create(mozilla::dom::EventTarget* aOwner,
- const nsAString& aMessage)
-{
- nsRefPtr<StkCommandEvent> event = new StkCommandEvent(aOwner);
- event->mCommand = aMessage;
- return event.forget();
-}
-
-NS_IMPL_ADDREF_INHERITED(StkCommandEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(StkCommandEvent, nsDOMEvent)
-
-NS_INTERFACE_MAP_BEGIN(StkCommandEvent)
- NS_INTERFACE_MAP_ENTRY(nsIDOMMozStkCommandEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-StkCommandEvent::GetCommand(JSContext* aCx, JS::Value* aCommand)
-
-{
- nsCOMPtr<nsIJSON> json(new nsJSON());
-
- if (!mCommand.IsEmpty()) {
- nsresult rv = json->DecodeToJSVal(mCommand, aCx, aCommand);
- NS_ENSURE_SUCCESS(rv, rv);
- } else {
- *aCommand = JSVAL_VOID;
- }
-
- return NS_OK;
-}
-
-}
-}
-}
diff --git a/dom/icc/src/StkCommandEvent.h b/dom/icc/src/StkCommandEvent.h
deleted file mode 100644
index 30ac05d87..000000000
--- a/dom/icc/src/StkCommandEvent.h
+++ /dev/null
@@ -1,78 +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/. */
-
-#ifndef mozilla_dom_icc_stkcommandevent_h
-#define mozilla_dom_icc_stkcommandevent_h
-
-#include "nsDOMEvent.h"
-#include "SimToolKit.h"
-#include "mozilla/dom/MozStkCommandEventBinding.h"
-
-namespace mozilla {
-namespace dom {
-namespace icc {
-
-class StkCommandEvent : public nsDOMEvent,
- public nsIDOMMozStkCommandEvent
-{
- nsString mCommand;
-
-public:
- NS_DECL_ISUPPORTS_INHERITED
- NS_FORWARD_TO_NSDOMEVENT
- NS_DECL_NSIDOMMOZSTKCOMMANDEVENT
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StkCommandEvent, nsDOMEvent)
-
- static already_AddRefed<StkCommandEvent>
- Create(EventTarget* aOwner, const nsAString& aMessage);
-
- nsresult
- Dispatch(EventTarget* aTarget, const nsAString& aEventType)
- {
- NS_ASSERTION(aTarget, "Null pointer!");
- NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
-
- nsresult rv = InitEvent(aEventType, false, false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- SetTrusted(true);
-
- nsDOMEvent* thisEvent = this;
-
- bool dummy;
- rv = aTarget->DispatchEvent(thisEvent, &dummy);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
- }
-
- virtual JSObject* WrapObject(JSContext* aCx,
- JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
- {
- return mozilla::dom::MozStkCommandEventBinding::Wrap(aCx, aScope, this);
- }
-
- JS::Value GetCommand(JSContext* aCx, mozilla::ErrorResult& aRv)
- {
- JS::Rooted<JS::Value> retVal(aCx);
- aRv = GetCommand(aCx, retVal.address());
- return retVal;
- }
-
-private:
- StkCommandEvent(mozilla::dom::EventTarget* aOwner)
- : nsDOMEvent(aOwner, nullptr, nullptr)
- {
- SetIsDOMBinding();
- }
-
- ~StkCommandEvent()
- { }
-};
-
-}
-}
-}
-
-#endif // mozilla_dom_icc_stkcommandevent_h
diff --git a/dom/icc/src/moz.build b/dom/icc/src/moz.build
deleted file mode 100644
index e5e527fd4..000000000
--- a/dom/icc/src/moz.build
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-EXPORTS.mozilla.dom.icc += [
- 'StkCommandEvent.h',
-]
-
-CPP_SOURCES += [
- 'IccManager.cpp',
- 'StkCommandEvent.cpp',
-]
-
diff --git a/dom/icc/tests/marionette/head.js b/dom/icc/tests/marionette/head.js
new file mode 100644
index 000000000..a28127f67
--- /dev/null
+++ b/dom/icc/tests/marionette/head.js
@@ -0,0 +1,459 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
+
+const PREF_KEY_RIL_DEBUGGING_ENABLED = "ril.debugging.enabled";
+
+// The pin code hard coded in emulator is "0000".
+const DEFAULT_PIN = "0000";
+// The puk code hard coded in emulator is "12345678".
+const DEFAULT_PUK = "12345678";
+
+const WHT = 0xFFFFFFFF;
+const BLK = 0x000000FF;
+const RED = 0xFF0000FF;
+const GRN = 0x00FF00FF;
+const BLU = 0x0000FFFF;
+const TSP = 0;
+
+// Basic Image, see record number 1 in EFimg.
+const BASIC_ICON = {
+ width: 8,
+ height: 8,
+ codingScheme: "basic",
+ pixels: [WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT,
+ BLK, BLK, BLK, BLK, BLK, BLK, WHT, WHT,
+ WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
+ WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
+ WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
+ WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
+ WHT, WHT, BLK, BLK, BLK, BLK, WHT, WHT,
+ WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT]
+};
+// Color Image, see record number 3 in EFimg.
+const COLOR_ICON = {
+ width: 8,
+ height: 8,
+ codingScheme: "color",
+ pixels: [BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU,
+ BLU, RED, RED, RED, RED, RED, RED, BLU,
+ BLU, RED, GRN, GRN, GRN, RED, RED, BLU,
+ BLU, RED, RED, GRN, GRN, RED, RED, BLU,
+ BLU, RED, RED, GRN, GRN, RED, RED, BLU,
+ BLU, RED, RED, GRN, GRN, GRN, RED, BLU,
+ BLU, RED, RED, RED, RED, RED, RED, BLU,
+ BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU]
+};
+// Color Image with Transparency, see record number 5 in EFimg.
+const COLOR_TRANSPARENCY_ICON = {
+ width: 8,
+ height: 8,
+ codingScheme: "color-transparency",
+ pixels: [TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP,
+ TSP, RED, RED, RED, RED, RED, RED, TSP,
+ TSP, RED, GRN, GRN, GRN, RED, RED, TSP,
+ TSP, RED, RED, GRN, GRN, RED, RED, TSP,
+ TSP, RED, RED, GRN, GRN, RED, RED, TSP,
+ TSP, RED, RED, GRN, GRN, GRN, RED, TSP,
+ TSP, RED, RED, RED, RED, RED, RED, TSP,
+ TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP]
+};
+
+/**
+ * Helper function for checking stk icon.
+ */
+function isIcons(aIcons, aExpectedIcons) {
+ is(aIcons.length, aExpectedIcons.length, "icons.length");
+ for (let i = 0; i < aIcons.length; i++) {
+ let icon = aIcons[i];
+ let expectedIcon = aExpectedIcons[i];
+
+ is(icon.width, expectedIcon.width, "icon.width");
+ is(icon.height, expectedIcon.height, "icon.height");
+ is(icon.codingScheme, expectedIcon.codingScheme, "icon.codingScheme");
+
+ is(icon.pixels.length, expectedIcon.pixels.length);
+ for (let j = 0; j < icon.pixels.length; j++) {
+ is(icon.pixels[j], expectedIcon.pixels[j], "icon.pixels[" + j + "]");
+ }
+ }
+}
+
+/**
+ * Helper function for checking stk text.
+ */
+function isStkText(aStkText, aExpectedStkText) {
+ is(aStkText.text, aExpectedStkText.text, "stkText.text");
+ if (aExpectedStkText.icons) {
+ is(aStkText.iconSelfExplanatory, aExpectedStkText.iconSelfExplanatory,
+ "stkText.iconSelfExplanatory");
+ isIcons(aStkText.icons, aExpectedStkText.icons);
+ }
+}
+
+let _pendingEmulatorCmdCount = 0;
+
+/**
+ * Send emulator command with safe guard.
+ *
+ * We should only call |finish()| after all emulator command transactions
+ * end, so here comes with the pending counter. Resolve when the emulator
+ * gives positive response, and reject otherwise.
+ *
+ * Fulfill params:
+ * result -- an array of emulator response lines.
+ * Reject params:
+ * result -- an array of emulator response lines.
+ *
+ * @param aCommand
+ * A string command to be passed to emulator through its telnet console.
+ *
+ * @return A deferred promise.
+ */
+function runEmulatorCmdSafe(aCommand) {
+ return new Promise(function(aResolve, aReject) {
+ ++_pendingEmulatorCmdCount;
+ runEmulatorCmd(aCommand, function(aResult) {
+ --_pendingEmulatorCmdCount;
+
+ ok(true, "Emulator response: " + JSON.stringify(aResult));
+ if (Array.isArray(aResult) &&
+ aResult[aResult.length - 1] === "OK") {
+ aResolve(aResult);
+ } else {
+ aReject(aResult);
+ }
+ });
+ });
+}
+
+/**
+ * Send stk proactive pdu.
+ *
+ * Fulfill params: (none)
+ * Reject params: (none)
+ *
+ * @param aPdu
+ *
+ * @return A deferred promise.
+ */
+function sendEmulatorStkPdu(aPdu) {
+ let cmd = "stk pdu " + aPdu;
+ return runEmulatorCmdSafe(cmd);
+}
+
+let workingFrame;
+let iccManager;
+
+/**
+ * Push required permissions and test if
+ * |navigator.mozIccManager| exists. Resolve if it does,
+ * reject otherwise.
+ *
+ * Fulfill params:
+ * iccManager -- an reference to navigator.mozIccManager.
+ *
+ * Reject params: (none)
+ *
+ * @param aAdditonalPermissions [optional]
+ * An array of permission strings other than "mobileconnection" to be
+ * pushed. Default: empty string.
+ *
+ * @return A deferred promise.
+ */
+function ensureIccManager(aAdditionalPermissions) {
+ return new Promise(function(aResolve, aReject) {
+ aAdditionalPermissions = aAdditionalPermissions || [];
+
+ if (aAdditionalPermissions.indexOf("mobileconnection") < 0) {
+ aAdditionalPermissions.push("mobileconnection");
+ }
+ let permissions = [];
+ for (let perm of aAdditionalPermissions) {
+ permissions.push({ "type": perm, "allow": 1, "context": document });
+ }
+
+ SpecialPowers.pushPermissions(permissions, function() {
+ ok(true, "permissions pushed: " + JSON.stringify(permissions));
+
+ // Permission changes can't change existing Navigator.prototype
+ // objects, so grab our objects from a new Navigator.
+ workingFrame = document.createElement("iframe");
+ workingFrame.addEventListener("load", function load() {
+ workingFrame.removeEventListener("load", load);
+
+ iccManager = workingFrame.contentWindow.navigator.mozIccManager;
+
+ if (iccManager) {
+ ok(true, "navigator.mozIccManager is instance of " + iccManager.constructor);
+ } else {
+ ok(true, "navigator.mozIccManager is undefined");
+ }
+
+ if (iccManager instanceof MozIccManager) {
+ aResolve(iccManager);
+ } else {
+ aReject();
+ }
+ });
+
+ document.body.appendChild(workingFrame);
+ });
+ });
+}
+
+/**
+ * Get MozIcc by IccId
+ *
+ * @param aIccId [optional]
+ * Default: The first item of |aIccManager.iccIds|.
+ *
+ * @return A MozIcc.
+ */
+function getMozIcc(aIccId) {
+ aIccId = aIccId || iccManager.iccIds[0];
+
+ if (!aIccId) {
+ ok(true, "iccManager.iccIds[0] is undefined");
+ return null;
+ }
+
+ return iccManager.getIccById(aIccId);
+}
+
+/**
+ * Get MozMobileConnection by ServiceId
+ *
+ * @param aServiceId [optional]
+ * A numeric DSDS service id. Default: 0 if not indicated.
+ *
+ * @return A MozMobileConnection.
+ */
+function getMozMobileConnectionByServiceId(aServiceId) {
+ aServiceId = aServiceId || 0;
+ return workingFrame.contentWindow.navigator.mozMobileConnections[aServiceId];
+}
+
+/**
+ * Set radio enabling state.
+ *
+ * Resolve no matter the request succeeds or fails. Never reject.
+ *
+ * Fulfill params: (none)
+ *
+ * @param aEnabled
+ * A boolean state.
+ * @param aServiceId [optional]
+ * A numeric DSDS service id.
+ *
+ * @return A deferred promise.
+ */
+function setRadioEnabled(aEnabled, aServiceId) {
+ return getMozMobileConnectionByServiceId(aServiceId).setRadioEnabled(aEnabled)
+ .then(() => {
+ ok(true, "setRadioEnabled " + aEnabled + " on " + aServiceId + " success.");
+ }, (aError) => {
+ ok(false, "setRadioEnabled " + aEnabled + " on " + aServiceId + " " +
+ aError.name);
+ });
+}
+
+/**
+ * Wait for one named event.
+ *
+ * Resolve if that named event occurs. Never reject.
+ *
+ * Fulfill params: the DOMEvent passed.
+ *
+ * @param aEventTarget
+ * An EventTarget object.
+ * @param aEventName
+ * A string event name.
+ * @param aMatchFun [optional]
+ * A matching function returns true or false to filter the event.
+ *
+ * @return A deferred promise.
+ */
+function waitForTargetEvent(aEventTarget, aEventName, aMatchFun) {
+ return new Promise(function(aResolve, aReject) {
+ aEventTarget.addEventListener(aEventName, function onevent(aEvent) {
+ if (!aMatchFun || aMatchFun(aEvent)) {
+ aEventTarget.removeEventListener(aEventName, onevent);
+ ok(true, "Event '" + aEventName + "' got.");
+ aResolve(aEvent);
+ }
+ });
+ });
+}
+
+/**
+ * Wait for one named system message.
+ *
+ * Resolve if that named message is received. Never reject.
+ *
+ * Fulfill params: the message passed.
+ *
+ * @param aEventName
+ * A string message name.
+ * @param aMatchFun [optional]
+ * A matching function returns true or false to filter the message. If no
+ * matching function passed the promise is resolved after receiving the
+ * first message.
+ *
+ * @return A deferred promise.
+ */
+function waitForSystemMessage(aMessageName, aMatchFun) {
+ let target = workingFrame.contentWindow.navigator;
+
+ return new Promise(function(aResolve, aReject) {
+ target.mozSetMessageHandler(aMessageName, function(aMessage) {
+ if (!aMatchFun || aMatchFun(aMessage)) {
+ target.mozSetMessageHandler(aMessageName, null);
+ ok(true, "System message '" + aMessageName + "' got.");
+ aResolve(aMessage);
+ }
+ });
+ });
+}
+
+/**
+ * Set radio enabling state and wait for "radiostatechange" event.
+ *
+ * Resolve if radio state changed to the expected one. Never reject.
+ *
+ * Fulfill params: (none)
+ *
+ * @param aEnabled
+ * A boolean state.
+ * @param aServiceId [optional]
+ * A numeric DSDS service id. Default: the one indicated in
+ * start*TestCommon() or 0 if not indicated.
+ *
+ * @return A deferred promise.
+ */
+function setRadioEnabledAndWait(aEnabled, aServiceId) {
+ let mobileConn = getMozMobileConnectionByServiceId(aServiceId);
+ let promises = [];
+
+ promises.push(waitForTargetEvent(mobileConn, "radiostatechange", function() {
+ // To ignore some transient states, we only resolve that deferred promise
+ // when |radioState| equals to the expected one.
+ return mobileConn.radioState === (aEnabled ? "enabled" : "disabled");
+ }));
+ promises.push(setRadioEnabled(aEnabled, aServiceId));
+
+ return Promise.all(promises);
+}
+
+/**
+ * Restart radio and wait card state changes to expected one.
+ *
+ * Resolve if card state changed to the expected one. Never reject.
+ *
+ * Fulfill params: (none)
+ *
+ * @param aCardState
+ * Expected card state.
+ *
+ * @return A deferred promise.
+ */
+function restartRadioAndWait(aCardState) {
+ return setRadioEnabledAndWait(false).then(() => {
+ let promises = [];
+
+ promises.push(waitForTargetEvent(iccManager, "iccdetected")
+ .then((aEvent) => {
+ let icc = getMozIcc(aEvent.iccId);
+ if (icc.cardState !== aCardState) {
+ return waitForTargetEvent(icc, "cardstatechange", function() {
+ return icc.cardState === aCardState;
+ });
+ }
+ }));
+ promises.push(setRadioEnabledAndWait(true));
+
+ return Promise.all(promises);
+ });
+}
+
+/**
+ * Enable/Disable PIN-lock.
+ *
+ * Fulfill params: (none)
+ * Reject params:
+ * An object contains error name and remaining retry count.
+ * @see IccCardLockError
+ *
+ * @param aIcc
+ * A MozIcc object.
+ * @param aEnabled
+ * A boolean state.
+ *
+ * @return A deferred promise.
+ */
+function setPinLockEnabled(aIcc, aEnabled) {
+ let options = {
+ lockType: "pin",
+ enabled: aEnabled,
+ pin: DEFAULT_PIN
+ };
+
+ return aIcc.setCardLock(options);
+}
+
+/**
+ * Wait for pending emulator transactions and call |finish()|.
+ */
+function cleanUp() {
+ // Use ok here so that we have at least one test run.
+ ok(true, ":: CLEANING UP ::");
+
+ waitFor(finish, function() {
+ return _pendingEmulatorCmdCount === 0;
+ });
+}
+
+/**
+ * Basic test routine helper for icc tests.
+ *
+ * This helper does nothing but clean-ups.
+ *
+ * @param aTestCaseMain
+ * A function that takes no parameter.
+ */
+function startTestBase(aTestCaseMain) {
+ // Turn on debugging pref.
+ let debugPref = SpecialPowers.getBoolPref(PREF_KEY_RIL_DEBUGGING_ENABLED);
+ SpecialPowers.setBoolPref(PREF_KEY_RIL_DEBUGGING_ENABLED, true);
+
+ Promise.resolve()
+ .then(aTestCaseMain)
+ .catch((aError) => {
+ ok(false, "promise rejects during test: " + aError);
+ })
+ .then(() => {
+ // Restore debugging pref.
+ SpecialPowers.setBoolPref(PREF_KEY_RIL_DEBUGGING_ENABLED, debugPref);
+ cleanUp();
+ });
+}
+
+/**
+ * Common test routine helper for icc tests.
+ *
+ * This function ensures global variable |iccManager| and |icc| is available
+ * during the process and performs clean-ups as well.
+ *
+ * @param aTestCaseMain
+ * A function that takes one parameter -- icc.
+ * @param aAdditonalPermissions [optional]
+ * An array of permission strings other than "mobileconnection" to be
+ * pushed. Default: empty string..
+ */
+function startTestCommon(aTestCaseMain, aAdditionalPermissions) {
+ startTestBase(function() {
+ return ensureIccManager(aAdditionalPermissions)
+ .then(aTestCaseMain);
+ });
+}
diff --git a/dom/icc/tests/marionette/manifest.ini b/dom/icc/tests/marionette/manifest.ini
index 1d9afb0b4..b500a10c4 100644
--- a/dom/icc/tests/marionette/manifest.ini
+++ b/dom/icc/tests/marionette/manifest.ini
@@ -3,11 +3,18 @@ b2g = true
browser = false
qemu = true
-[test_stk_proactive_command.js]
[test_icc_contact.js]
-[test_icc_card_lock.js]
+[test_icc_card_lock_get_retry_count.js]
+[test_icc_card_lock_change_pin.js]
+[test_icc_card_lock_enable_pin.js]
+[test_icc_card_lock_unlock_pin.js]
+[test_icc_card_lock_unlock_puk.js]
+[test_icc_card_state.js]
+[test_icc_info.js]
[test_stk_refresh.js]
+[test_stk_play_tone.js]
[test_stk_poll_off.js]
+[test_stk_poll_interval.js]
[test_stk_setup_event_list.js]
[test_stk_setup_call.js]
[test_stk_send_ss.js]
@@ -21,3 +28,10 @@ qemu = true
[test_stk_select_item.js]
[test_stk_setup_menu.js]
[test_stk_setup_idle_mode_text.js]
+[test_stk_bip_command.js]
+[test_stk_local_info.js]
+[test_stk_timer_management.js]
+[test_icc_access_invalid_object.js]
+[test_icc_detected_undetected_event.js]
+[test_icc_match_mvno.js]
+[test_icc_service_state.js]
diff --git a/dom/icc/tests/marionette/test_icc_access_invalid_object.js b/dom/icc/tests/marionette/test_icc_access_invalid_object.js
new file mode 100644
index 000000000..da7033a8e
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_access_invalid_object.js
@@ -0,0 +1,101 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function testInvalidIccObject(aIcc) {
+ // Test access iccInfo.
+ try {
+ is(aIcc.iccInfo, null, "iccInfo: expect to get null");
+ } catch(e) {
+ ok(false, "access iccInfo should not get exception");
+ }
+
+ // Test access cardState.
+ try {
+ is(aIcc.cardState, null, "cardState: expect to get null");
+ } catch(e) {
+ ok(false, "access cardState should not get exception");
+ }
+
+ // Test STK related function.
+ try {
+ aIcc.sendStkResponse({}, {});
+ ok(false, "sendStkResponse() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.sendStkMenuSelection(0, false);
+ ok(false, "sendStkMenuSelection() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.sendStkTimerExpiration({});
+ ok(false, "sendStkTimerExpiration() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.sendStkEventDownload({});
+ ok(false, "sendStkEventDownload() should get exception");
+ } catch(e) {}
+
+ // Test card lock related function.
+ try {
+ aIcc.getCardLock("pin");
+ ok(false, "getCardLock() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.unlockCardLock({});
+ ok(false, "unlockCardLock() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.setCardLock({});
+ ok(false, "setCardLock() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.getCardLockRetryCount("pin");
+ ok(false, "getCardLockRetryCount() should get exception");
+ } catch(e) {}
+
+ // Test contact related function.
+ try {
+ aIcc.readContacts("adn");
+ ok(false, "readContacts() should get exception");
+ } catch(e) {}
+ try {
+ aIcc.updateContact("adn", {});
+ ok(false, "updateContact() should get exception");
+ } catch(e) {}
+
+ // Test mvno function.
+ try {
+ aIcc.matchMvno("imsi");
+ ok(false, "matchMvno() should get exception");
+ } catch(e) {}
+
+ // Test service state function.
+ return aIcc.getServiceState("fdn").then(() => {
+ ok(false, "getServiceState() should be rejected");
+ }, () => {});
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ return Promise.resolve()
+ // Turn off radio.
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(false));
+ promises.push(waitForTargetEvent(iccManager, "iccundetected"));
+ return Promise.all(promises);
+ })
+ // Test accessing invalid icc object.
+ .then(() => testInvalidIccObject(icc))
+ // We should restore the radio status.
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(true));
+ promises.push(waitForTargetEvent(iccManager, "iccdetected"));
+ return Promise.all(promises);
+ });
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_lock.js b/dom/icc/tests/marionette/test_icc_card_lock.js
deleted file mode 100644
index 561229d55..000000000
--- a/dom/icc/tests/marionette/test_icc_card_lock.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 30000;
-
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-/* Reset pin retries by passing correct pin code. */
-function resetPinRetries(pin, callback) {
- let request = icc.setCardLock(
- {lockType: "pin",
- pin: pin,
- newPin: pin});
-
- request.onsuccess = function onsuccess() {
- callback();
- };
-
- request.onerror = function onerror() {
- is(false, "Reset pin retries got error: " + request.error.name);
- callback();
- };
-}
-
-/* Test PIN code changes fail */
-function testPinChangeFailed() {
- // The default pin is '0000' in emulator
- let request = icc.setCardLock(
- {lockType: "pin",
- pin: "1111",
- newPin: "0000"});
-
- ok(request instanceof DOMRequest,
- "request instanceof " + request.constructor);
-
- request.onerror = function onerror() {
- is(request.error.name, "IncorrectPassword");
-
- resetPinRetries("0000", runNextTest);
- };
-}
-
-/* Test PIN code changes fail notification */
-function testPinChangeFailedNotification() {
- icc.addEventListener("icccardlockerror", function onicccardlockerror(result) {
- icc.removeEventListener("icccardlockerror", onicccardlockerror);
-
- is(result.lockType, "pin");
- // The default pin retries is 3, failed once becomes to 2
- is(result.retryCount, 2);
-
- resetPinRetries("0000", runNextTest);
- });
-
- // The default pin is '0000' in emulator
- let request = icc.setCardLock(
- {lockType: "pin",
- pin: "1111",
- newPin: "0000"});
-
- ok(request instanceof DOMRequest,
- "request instanceof " + request.constructor);
-}
-
-/* Test PIN code changes success */
-function testPinChangeSuccess() {
- // The default pin is '0000' in emulator
- let request = icc.setCardLock(
- {lockType: "pin",
- pin: "0000",
- newPin: "0000"});
-
- ok(request instanceof DOMRequest,
- "request instanceof " + request.constructor);
-
- request.onerror = function onerror() {
- ok(false, "Should not fail, got error: " + request.error.name);
-
- runNextTest();
- };
-
- request.onsuccess = function onsuccess() {
- is(request.result.lockType, "pin");
- is(request.result.success, true);
-
- runNextTest();
- };
-}
-
-let tests = [
- testPinChangeFailed,
- testPinChangeFailedNotification,
- testPinChangeSuccess,
-];
-
-function runNextTest() {
- let test = tests.shift();
- if (!test) {
- cleanUp();
- return;
- }
-
- test();
-}
-
-function cleanUp() {
- SpecialPowers.removePermission("mobileconnection", document);
-
- finish();
-}
-
-runNextTest();
diff --git a/dom/icc/tests/marionette/test_icc_card_lock_change_pin.js b/dom/icc/tests/marionette/test_icc_card_lock_change_pin.js
new file mode 100644
index 000000000..07a8c5a7a
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_lock_change_pin.js
@@ -0,0 +1,45 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const LOCK_TYPE = "pin";
+
+function testChangePin(aIcc, aPin, aNewPin, aErrorName, aRetryCount) {
+ log("testChangePin for pin=" + aPin + " and newPin=" + aNewPin);
+ return aIcc.setCardLock({ lockType: LOCK_TYPE, pin: aPin, newPin: aNewPin })
+ .then((aResult) => {
+ if (aErrorName) {
+ ok(false, "changing pin should not success");
+ }
+ }, (aError) => {
+ if (!aErrorName) {
+ ok(false, "changing pin should not fail");
+ return;
+ }
+
+ // check the request error.
+ is(aError.name, aErrorName, "error.name");
+ is(aError.retryCount, aRetryCount, "error.retryCount");
+ });
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let retryCount;
+
+ return icc.getCardLockRetryCount(LOCK_TYPE)
+ // Get current PIN-lock retry count.
+ .then((aResult) => {
+ retryCount = aResult.retryCount;
+ ok(true, LOCK_TYPE + " retryCount is " + retryCount);
+ })
+ // Test PIN code changes fail.
+ // The retry count should be decreased by 1.
+ .then(() => testChangePin(icc, "1111", DEFAULT_PIN, "IncorrectPassword",
+ retryCount - 1))
+ // Test PIN code changes success. This will reset the retry count.
+ .then(() => testChangePin(icc, DEFAULT_PIN, DEFAULT_PIN));
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_lock_enable_pin.js b/dom/icc/tests/marionette/test_icc_card_lock_enable_pin.js
new file mode 100644
index 000000000..ea21821c0
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_lock_enable_pin.js
@@ -0,0 +1,59 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function setCardLockAndCheck(aIcc, aLockType, aPin, aEnabled, aErrorName,
+ aRetryCount) {
+ let options = {
+ lockType: aLockType,
+ enabled: aEnabled,
+ pin: aPin
+ };
+
+ return aIcc.setCardLock(options)
+ .then((aResult) => {
+ if (aErrorName) {
+ ok(false, "setting pin should not success");
+ return;
+ }
+
+ // Check lock state.
+ return aIcc.getCardLock(aLockType)
+ .then((aResult) => {
+ is(aResult.enabled, aEnabled, "result.enabled");
+ });
+ }, (aError) => {
+ if (!aErrorName) {
+ ok(false, "setting pin should not fail");
+ return;
+ }
+
+ // Check the request error.
+ is(aError.name, aErrorName, "error.name");
+ is(aError.retryCount, aRetryCount, "error.retryCount");
+ });
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let lockType = "pin";
+ let retryCount;
+
+ return icc.getCardLockRetryCount(lockType)
+ // Get current PIN-lock retry count.
+ .then((aResult) => {
+ retryCount = aResult.retryCount;
+ ok(true, lockType + " retryCount is " + retryCount);
+ })
+ // Test fail to enable PIN-lock by passing wrong pin.
+ // The retry count should be decreased by 1.
+ .then(() => setCardLockAndCheck(icc, lockType, "1111", true,
+ "IncorrectPassword", retryCount -1))
+ // Test enabling PIN-lock.
+ .then(() => setCardLockAndCheck(icc, lockType, DEFAULT_PIN, true))
+ // Restore pin state.
+ .then(() => setCardLockAndCheck(icc, lockType, DEFAULT_PIN, false));
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_lock_get_retry_count.js b/dom/icc/tests/marionette/test_icc_card_lock_get_retry_count.js
new file mode 100644
index 000000000..211bec0f9
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_lock_get_retry_count.js
@@ -0,0 +1,44 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function testGetCardLockRetryCount(aIcc, aLockType, aRetryCount) {
+ log("testGetCardLockRetryCount for " + aLockType);
+
+ try {
+ return aIcc.getCardLockRetryCount(aLockType)
+ .then((aResult) => {
+ if (!aRetryCount) {
+ ok(false, "getCardLockRetryCount(" + aLockType + ") should not success");
+ return;
+ }
+
+ // Check the request result.
+ is(aResult.retryCount, aRetryCount, "result.retryCount");
+ }, (aError) => {
+ if (aRetryCount) {
+ ok(false, "getCardLockRetryCount(" + aLockType + ") should not fail" +
+ aError.name);
+ }
+ });
+ } catch (e) {
+ ok(!aRetryCount, "caught an exception: " + e);
+ return Promise.resolve();
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ // Read PIN-lock retry count.
+ // The default PIN-lock retry count hard coded in emulator is 3.
+ return testGetCardLockRetryCount(icc, "pin", 3)
+ // Read PUK-lock retry count.
+ // The default PUK-lock retry count hard coded in emulator is 6.
+ .then(() => testGetCardLockRetryCount(icc, "puk", 6))
+ // Read lock retry count for an invalid entries.
+ .then(() => testGetCardLockRetryCount(icc, "invalid-lock-type"));
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_lock_unlock_pin.js b/dom/icc/tests/marionette/test_icc_card_lock_unlock_pin.js
new file mode 100644
index 000000000..83e2eb2a7
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_lock_unlock_pin.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function testUnlockPin(aIcc, aPin, aErrorName, aRetryCount) {
+ log("testUnlockPin with pin=" + aPin);
+
+ return aIcc.unlockCardLock({ lockType: "pin", pin: aPin })
+ .then((aResult) => {
+ if (aErrorName) {
+ ok(false, "unlocking pin should not success");
+ }
+ }, (aError) => {
+ if (!aErrorName) {
+ ok(false, "unlocking pin should not fail");
+ return;
+ }
+
+ // Check the request error.
+ is(aError.name, aErrorName, "error.name");
+ is(aError.retryCount, aRetryCount, "error.retryCount");
+ });
+}
+
+function testUnlockPinAndWait(aIcc, aPin, aCardState) {
+ log("testUnlockPin with pin=" + aPin + ", and wait cardState changes to '" +
+ aCardState + "'");
+
+ let promises = [];
+
+ promises.push(waitForTargetEvent(aIcc, "cardstatechange", function() {
+ return aIcc.cardState === aCardState;
+ }));
+ promises.push(testUnlockPin(aIcc, aPin));
+
+ return Promise.all(promises);
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let retryCount;
+
+ // Enable PIN-lock.
+ return setPinLockEnabled(icc, true)
+ // Reset card state to "pinRequired" by restarting radio
+ .then(() => restartRadioAndWait("pinRequired"))
+ .then(() => { icc = getMozIcc(); })
+
+ // Get current PIN-lock retry count.
+ .then(() => icc.getCardLockRetryCount("pin"))
+ .then((aResult) => {
+ retryCount = aResult.retryCount;
+ ok(true, "pin retryCount is " + retryCount);
+ })
+
+ // Test fail to unlock PIN-lock.
+ // The retry count should be decreased by 1.
+ .then(() => testUnlockPin(icc, "1111", "IncorrectPassword", retryCount - 1))
+
+ // Test success to unlock PIN-lock.
+ .then(() => testUnlockPinAndWait(icc, DEFAULT_PIN, "ready"))
+
+ // Restore pin state.
+ .then(() => setPinLockEnabled(icc, false));
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_lock_unlock_puk.js b/dom/icc/tests/marionette/test_icc_card_lock_unlock_puk.js
new file mode 100644
index 000000000..71b9b1c44
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_lock_unlock_puk.js
@@ -0,0 +1,97 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function passingWrongPinAndWait(aIcc) {
+ return aIcc.getCardLockRetryCount("pin").then((aResult) => {
+ let promises = [];
+ let retryCount = aResult.retryCount;
+
+ ok(true, "pin retryCount is " + retryCount);
+
+ promises.push(waitForTargetEvent(aIcc, "cardstatechange", function() {
+ return aIcc.cardState === "pukRequired";
+ }));
+
+ for (let i = 0; i < retryCount; i++) {
+ promises.push(aIcc.unlockCardLock({ lockType: "pin", pin: "1111" })
+ .then(() => {
+ ok(false, "unlocking pin should not success");
+ }, function reject(aRetryCount, aError) {
+ // check the request error.
+ is(aError.name, "IncorrectPassword", "error.name");
+ is(aError.retryCount, aRetryCount, "error.retryCount");
+ }.bind(null, retryCount - i - 1)));
+ }
+
+ return Promise.all(promises);
+ });
+}
+
+function testUnlockPuk(aIcc, aPuk, aNewPin, aErrorName, aRetryCount) {
+ log("testUnlockPuk with puk=" + aPuk + " and newPin=" + aNewPin);
+
+ return aIcc.unlockCardLock({ lockType: "puk", puk: aPuk, newPin: aNewPin })
+ .then((aResult) => {
+ if (aErrorName) {
+ ok(false, "unlocking puk should not success");
+ }
+ }, (aError) => {
+ if (!aErrorName) {
+ ok(false, "unlocking puk should not fail");
+ return;
+ }
+
+ // Check the request error.
+ is(aError.name, aErrorName, "error.name");
+ is(aError.retryCount, aRetryCount, "error.retryCount");
+ });
+}
+
+function testUnlockPukAndWait(aIcc, aPuk, aNewPin, aCardState) {
+ log("testUnlockPuk with puk=" + aPuk + "/newPin=" + aNewPin +
+ ", and wait card state changes to '" + aCardState + "'");
+
+ let promises = [];
+
+ promises.push(waitForTargetEvent(aIcc, "cardstatechange", function() {
+ return aIcc.cardState === aCardState;
+ }));
+ promises.push(testUnlockPuk(aIcc, aPuk, aNewPin));
+
+ return Promise.all(promises);
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let retryCount;
+
+ // Enable pin lock.
+ return setPinLockEnabled(icc, true)
+ // Reset card state to "pinRequired" by restarting radio
+ .then(() => restartRadioAndWait("pinRequired"))
+ .then(() => { icc = getMozIcc() })
+ // Switch cardState to "pukRequired" by entering wrong pin code.
+ .then(() => passingWrongPinAndWait(icc))
+
+ // Get current PUK-lock retry count.
+ .then(() => icc.getCardLockRetryCount("puk"))
+ .then((aResult) => {
+ retryCount = aResult.retryCount;
+ ok(true, "puk retryCount is " + retryCount);
+ })
+
+ // Test unlock PUK code fail.
+ // The retry count should be decreased by 1.
+ .then(() => testUnlockPuk(icc, "11111111", DEFAULT_PIN, "IncorrectPassword",
+ retryCount - 1))
+
+ // Test unlock PUK code success.
+ .then(() => testUnlockPukAndWait(icc, DEFAULT_PUK, DEFAULT_PIN, "ready"))
+
+ // Restore pin state.
+ .then(() => setPinLockEnabled(icc, false));
+});
diff --git a/dom/icc/tests/marionette/test_icc_card_state.js b/dom/icc/tests/marionette/test_icc_card_state.js
new file mode 100644
index 000000000..5c8a179c4
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_card_state.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_HEAD_JS = "head.js";
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ // Basic test.
+ is(icc.cardState, "ready", "card state is " + icc.cardState);
+
+ // Test cardstatechange event by switching radio off.
+ return Promise.resolve()
+ // Turn off radio and expect to get card state changing to null.
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(false));
+ promises.push(waitForTargetEvent(icc, "cardstatechange", function() {
+ return icc.cardState === null;
+ }));
+ return Promise.all(promises);
+ })
+ // Restore radio status and expect to get iccdetected event.
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(true));
+ promises.push(waitForTargetEvent(iccManager, "iccdetected"));
+ return Promise.all(promises);
+ });
+});
diff --git a/dom/icc/tests/marionette/test_icc_contact.js b/dom/icc/tests/marionette/test_icc_contact.js
index e242d49ac..7f2f2fdc2 100644
--- a/dom/icc/tests/marionette/test_icc_contact.js
+++ b/dom/icc/tests/marionette/test_icc_contact.js
@@ -1,116 +1,81 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 30000;
-
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testReadContacts(type) {
- let request = icc.readContacts(type);
- request.onsuccess = function onsuccess() {
- let contacts = request.result;
-
- is(Array.isArray(contacts), true);
-
- is(contacts[0].name, "Mozilla");
- is(contacts[0].tel[0].value, "15555218201");
-
- is(contacts[1].name, "Saßê黃");
- is(contacts[1].tel[0].value, "15555218202");
-
- is(contacts[2].name, "Fire 火");
- is(contacts[2].tel[0].value, "15555218203");
-
- is(contacts[3].name, "Huang 黃");
- is(contacts[3].tel[0].value, "15555218204");
-
- runNextTest();
- };
-
- request.onerror = function onerror() {
- ok(false, "Cannot get " + type + " contacts");
- runNextTest();
- };
-};
-
-function testAddContact(type, pin2) {
- let contact = new mozContact();
-
- contact.init({
- name: "add",
- tel: [{value: "0912345678"}]
- });
-
- let updateRequest = icc.updateContact(type, contact, pin2);
-
- updateRequest.onsuccess = function onsuccess() {
- // Get ICC contact for checking new contact
-
- let getRequest = icc.readContacts(type);
-
- getRequest.onsuccess = function onsuccess() {
- let contacts = getRequest.result;
-
- // There are 4 SIM contacts which are harded in emulator
- is(contacts.length, 5);
-
- is(contacts[4].name, "add");
- is(contacts[4].tel[0].value, "0912345678");
-
- runNextTest();
- };
-
- getRequest.onerror = function onerror() {
- ok(false, "Cannot get " + type + " contacts: " + getRequest.error.name);
- runNextTest();
- };
- };
-
- updateRequest.onerror = function onerror() {
- ok(false, "Cannot add " + type + " contact: " + updateRequest.error.name);
- runNextTest();
- };
-};
-
-function testReadAdnContacts() {
- testReadContacts("adn");
-}
-
-function testAddAdnContact() {
- testAddContact("adn");
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function testReadContacts(aIcc, aType) {
+ log("testReadContacts: type=" + aType);
+ let iccId = aIcc.iccInfo.iccid;
+ return aIcc.readContacts(aType)
+ .then((aResult) => {
+ is(Array.isArray(aResult), true);
+
+ is(aResult[0].name[0], "Mozilla");
+ is(aResult[0].tel[0].value, "15555218201");
+ is(aResult[0].id, iccId + "1");
+
+ is(aResult[1].name[0], "Saßê黃");
+ is(aResult[1].tel[0].value, "15555218202");
+ is(aResult[1].id, iccId + "2");
+
+ is(aResult[2].name[0], "Fire 火");
+ is(aResult[2].tel[0].value, "15555218203");
+ is(aResult[2].id, iccId + "3");
+
+ is(aResult[3].name[0], "Huang 黃");
+ is(aResult[3].tel[0].value, "15555218204");
+ is(aResult[3].id, iccId + "4");
+ }, (aError) => {
+ ok(false, "Cannot get " + aType + " contacts");
+ });
}
-function testReadFdnContacts() {
- testReadContacts("fdn");
-}
-
-function testAddFdnContact() {
- testAddContact("fdn", "0000");
-}
-
-let tests = [
- testReadAdnContacts,
- testAddAdnContact,
- testReadFdnContacts,
- testAddFdnContact
-];
-
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
-
- test();
-}
+function testAddContact(aIcc, aType, aPin2) {
+ log("testAddContact: type=" + aType + ", pin2=" + aPin2);
+ let contact = new mozContact({
+ name: ["add"],
+ tel: [{value: "0912345678"}],
+ email:[]
+ });
-function cleanUp() {
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
+ return aIcc.updateContact(aType, contact, aPin2)
+ .then((aResult) => {
+ // Get ICC contact for checking new contact
+ return aIcc.readContacts(aType)
+ .then((aResult) => {
+ // There are 4 SIM contacts which are harded in emulator
+ is(aResult.length, 5);
+
+ is(aResult[4].name[0], "add");
+ is(aResult[4].tel[0].value, "0912345678");
+ }, (aError) => {
+ ok(false, "Cannot get " + aType + " contacts: " + aError.name);
+ })
+ }, (aError) => {
+ if (aType === "fdn" && aPin2 === undefined) {
+ ok(aError.name === "SimPin2",
+ "expected error when pin2 is not provided");
+ } else {
+ ok(false, "Cannot add " + aType + " contact: " + aError.name);
+ }
+ });
}
-runNextTest();
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ // Test read adn contacts
+ return testReadContacts(icc, "adn")
+ // Test add adn contacts
+ .then(() => testAddContact(icc, "adn"))
+ // Test read fdn contact
+ .then(() => testReadContacts(icc, "fdn"))
+ // Test add fdn contacts
+ .then(() => testAddContact(icc, "fdn", "0000"))
+ // Test add fdn contacts without passing pin2
+ .then(() => testAddContact(icc, "fdn"))
+ // Test read sdn contacts
+ .then(() => testReadContacts(icc, "sdn"));
+});
diff --git a/dom/icc/tests/marionette/test_icc_detected_undetected_event.js b/dom/icc/tests/marionette/test_icc_detected_undetected_event.js
new file mode 100644
index 000000000..920728e58
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_detected_undetected_event.js
@@ -0,0 +1,51 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_HEAD_JS = "head.js";
+
+// Start tests
+startTestCommon(function() {
+ let origNumIccs = iccManager.iccIds.length;
+ let icc = getMozIcc();
+ let iccId = icc.iccInfo.iccid;
+ let mobileConnection = getMozMobileConnectionByServiceId();
+
+ return Promise.resolve()
+ // Test iccundetected event.
+ .then(() => {
+ let promises = [];
+
+ promises.push(setRadioEnabled(false));
+ promises.push(waitForTargetEvent(iccManager, "iccundetected").then((aEvt) => {
+ is(aEvt.iccId, iccId, "icc " + aEvt.iccId + " becomes undetected");
+ is(iccManager.iccIds.length, origNumIccs - 1,
+ "iccIds.length becomes to " + iccManager.iccIds.length);
+ is(iccManager.getIccById(aEvt.iccId), null,
+ "should not get a valid icc object here");
+
+ // The mozMobileConnection.iccId should be in sync.
+ is(mobileConnection.iccId, null, "check mozMobileConnection.iccId");
+ }));
+
+ return Promise.all(promises);
+ })
+ // Test iccdetected event.
+ .then(() => {
+ let promises = [];
+
+ promises.push(setRadioEnabled(true));
+ promises.push(waitForTargetEvent(iccManager, "iccdetected").then((aEvt) => {
+ is(aEvt.iccId, iccId, "icc " + aEvt.iccId + " is detected");
+ is(iccManager.iccIds.length, origNumIccs,
+ "iccIds.length becomes to " + iccManager.iccIds.length);
+ ok(iccManager.getIccById(aEvt.iccId) instanceof MozIcc,
+ "should get a valid icc object here");
+
+ // The mozMobileConnection.iccId should be in sync.
+ is(mobileConnection.iccId, iccId, "check mozMobileConnection.iccId");
+ }));
+
+ return Promise.all(promises);
+ });
+});
diff --git a/dom/icc/tests/marionette/test_icc_info.js b/dom/icc/tests/marionette/test_icc_info.js
new file mode 100644
index 000000000..4e1f8400c
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_info.js
@@ -0,0 +1,64 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_HEAD_JS = "head.js";
+
+/* Basic test */
+function basicTest(aIcc) {
+ let iccInfo = aIcc.iccInfo;
+
+ // The emulator's hard coded iccid value.
+ // See it here {B2G_HOME}/external/qemu/telephony/sim_card.c#L299.
+ is(iccInfo.iccid, 89014103211118510720);
+
+ if (iccInfo instanceof MozGsmIccInfo) {
+ log("Test Gsm IccInfo");
+ is(iccInfo.iccType, "sim");
+ is(iccInfo.spn, "Android");
+ // The emulator's hard coded mcc and mnc codes.
+ // See it here {B2G_HOME}/external/qemu/telephony/android_modem.c#L2465.
+ is(iccInfo.mcc, 310);
+ is(iccInfo.mnc, 260);
+ // Phone number is hardcoded in MSISDN
+ // See {B2G_HOME}/external/qemu/telephony/sim_card.c, in asimcard_io().
+ is(iccInfo.msisdn, "15555215554");
+ } else {
+ log("Test Cdma IccInfo");
+ is(iccInfo.iccType, "ruim");
+ // MDN is hardcoded as "8587777777".
+ // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
+ // in requestCdmaSubscription().
+ is(iccInfo.mdn, "8587777777");
+ // PRL version is hardcoded as 1.
+ // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
+ // in requestCdmaSubscription().
+ is(iccInfo.prlVersion, 1);
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ return Promise.resolve()
+ // Basic test
+ .then(() => basicTest(icc))
+ // Test iccInfo when card becomes undetected
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(false));
+ promises.push(waitForTargetEvent(icc, "iccinfochange", function() {
+ // Expect iccInfo changes to null
+ return icc.iccInfo === null;
+ }));
+ return Promise.all(promises);
+ })
+ // Restore radio status and expect to get iccdetected event.
+ .then(() => {
+ let promises = [];
+ promises.push(setRadioEnabled(true));
+ promises.push(waitForTargetEvent(iccManager, "iccdetected"));
+ return Promise.all(promises);
+ });
+});
diff --git a/dom/icc/tests/marionette/test_icc_match_mvno.js b/dom/icc/tests/marionette/test_icc_match_mvno.js
new file mode 100644
index 000000000..24f5f28b6
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_match_mvno.js
@@ -0,0 +1,57 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ // mvno type, mvno data, request success, expected result
+ // Emulator's hard coded IMSI: 310260000000000
+ ["imsi", "3102600", true, true ],
+ // x and X means skip the comparison.
+ ["imsi", "31026xx0", true, true ],
+ ["imsi", "310260x0x", true, true ],
+ ["imsi", "310260X00", true, true ],
+ ["imsi", "310260XX1", true, false ],
+ ["imsi", "31026012", true, false ],
+ ["imsi", "310260000000000", true, true ],
+ ["imsi", "310260000000000123", true, false ],
+ ["imsi", "", false, "InvalidParameter"],
+ // Emulator's hard coded SPN: Android
+ ["spn", "Android", true, true ],
+ ["spn", "", false, "InvalidParameter"],
+ ["spn", "OneTwoThree", true, false ],
+ // Emulator's hard coded GID1: 5a4d
+ ["gid", "", false, "InvalidParameter"],
+ ["gid", "A1", true, false ],
+ ["gid", "5A", true, true ],
+ ["gid", "5a", true, true ],
+ ["gid", "5a4d", true, true ],
+ ["gid", "5A4D", true, true ],
+ ["gid", "5a4d6c", true, false ]
+];
+
+function testMatchMvno(aIcc, aMvnoType, aMvnoData, aSuccess, aExpectedResult) {
+ log("matchMvno: " + aMvnoType + ", " + aMvnoData);
+ return aIcc.matchMvno(aMvnoType, aMvnoData)
+ .then((aResult) => {
+ log("onsuccess: " + aResult);
+ ok(aSuccess, "onsuccess while error expected");
+ is(aResult, aExpectedResult);
+ }, (aError) => {
+ log("onerror: " + aError.name);
+ ok(!aSuccess, "onerror while success expected");
+ is(aError.name, aExpectedResult);
+ });
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => testMatchMvno.apply(null, [icc].concat(data)));
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_icc_service_state.js b/dom/icc/tests/marionette/test_icc_service_state.js
new file mode 100644
index 000000000..ee89bc9bd
--- /dev/null
+++ b/dom/icc/tests/marionette/test_icc_service_state.js
@@ -0,0 +1,28 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+function testUnsupportedService() {
+ try {
+ icc.getServiceState("unsupported-service");
+ ok(false, "should get exception");
+ } catch (aException) {
+ ok(true, "got exception: " + aException);
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+
+ // Check fdn service state
+ return icc.getServiceState("fdn")
+ .then((aResult) => {
+ is(aResult, true, "check fdn service state");
+ })
+
+ // Test unsupported service
+ .then(() => testUnsupportedService());
+});
diff --git a/dom/icc/tests/marionette/test_stk_bip_command.js b/dom/icc/tests/marionette/test_stk_bip_command.js
new file mode 100644
index 000000000..6431936e8
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_bip_command.js
@@ -0,0 +1,137 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ // Open channel.
+ {command: "D02E" + // Length
+ "8103014001" + // Command details
+ "82028182" + // Device identities
+ "05074F70656E204944" + // Alpha identifier
+ "9E020007" + // Icon identifier
+ "86099111223344556677F8" + // Address
+ "350702030403041F02" + // Bear description
+ "39020578", // Buffer size
+ expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
+ commandQualifier: 0x01,
+ text: "Open ID",
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
+ {command: "D023" + // Length
+ "8103014001" + // Command details
+ "82028182" + // Device identities
+ "0500" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "350702030403041F02" + // Bear description
+ "39020578", // Buffer size
+ expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
+ commandQualifier: 0x01,
+ text: ""}},
+ {command: "D02C" + // Length
+ "8103014001" + // Command details
+ "82028182" + // Device identities
+ "05094F70656E2049442031" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "350702030403041F02" + // Bear description
+ "39020578", // Buffer size
+ expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
+ commandQualifier: 0x01,
+ text: "Open ID 1"}},
+ // Close channel.
+ {command: "D00D" + // Length
+ "8103014100" + // Command details
+ "82028182" + // Device identities
+ "9E020007", // Icon identifier
+ expect: {typeOfCommand: MozIccManager.STK_CMD_CLOSE_CHANNEL,
+ commandQualifier: 0x00,
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
+ {command: "D015" + // Length
+ "8103014100" + // Command details
+ "82028121" + // Device identities
+ "850A436C6F73652049442031", // Alpha identifier
+ expect: {typeOfCommand: MozIccManager.STK_CMD_CLOSE_CHANNEL,
+ commandQualifier: 0x00,
+ text: "Close ID 1"}},
+ // Receive data.
+ {command: "D00C" + // Length
+ "8103014200" + // Command details
+ "82028121" + // Device identities
+ "B701C8", // Channel data length
+ expect: {typeOfCommand: MozIccManager.STK_CMD_RECEIVE_DATA,
+ commandQualifier: 0x00}},
+ {command: "D01C" + // Length
+ "8103014200" + // Command details
+ "82028121" + // Device identities
+ "850E5265636569766520446174612031" + // Alpha identifier
+ "B701C8", // Channel data length
+ expect: {typeOfCommand: MozIccManager.STK_CMD_RECEIVE_DATA,
+ commandQualifier: 0x00,
+ text: "Receive Data 1"}},
+ // Send data.
+ {command: "D017" + // Length
+ "8103014301" + // Command details
+ "82028121" + // Device identities
+ "9E020007" + // Icon identifier
+ "B6080001020304050607", // Channel data
+ expect: {typeOfCommand: MozIccManager.STK_CMD_SEND_DATA,
+ commandQualifier: 0x01,
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
+ {command: "D020" + // Length
+ "8103014301" + // Command details
+ "82028121" + // Device identities
+ "850B53656E6420446174612031" + // Alpha identifier
+ "B6080001020304050607", // Channel data
+ expect: {typeOfCommand: MozIccManager.STK_CMD_SEND_DATA,
+ commandQualifier: 0x01,
+ text: "Send Data 1"}},
+];
+
+function testBipCommand(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, aExpect.typeOfCommand, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
+ }
+
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("bip_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testBipCommand(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testBipCommand(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_display_text.js b/dom/icc/tests/marionette/test_stk_display_text.js
index 27aa7bef4..a65b300aa 100644
--- a/dom/icc/tests/marionette/test_stk_display_text.js
+++ b/dom/icc/tests/marionette/test_stk_display_text.js
@@ -1,118 +1,246 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testDisplayText(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_DISPLAY_TEXT, expect.name);
- is(command.options.text, expect.text, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (expect.userClear) {
- is(command.options.userClear, expect.userClear, expect.name);
- }
- if (expect.isHighPriority) {
- is(command.options.isHighPriority, expect.isHighPriority, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d01a8103012180820281028d0f04546f6f6c6b697420546573742031",
- func: testDisplayText,
- expect: {name: "display_text_cmd_1",
- commandQualifier: 0x80,
+const TEST_DATA = [
+ {command: "D01A" + // Length
+ "8103012101" + // Command details
+ "82028102" + // Device identities
+ "8D0F04546F6F6C6B697420546573742031", // Text string
+ expect: {commandQualifier: 0x01,
text: "Toolkit Test 1",
- userClear: true}},
- {command: "d01a8103012181820281028d0f04546f6f6c6b697420546573742032",
- func: testDisplayText,
- expect: {name: "display_text_cmd_2",
- commandQualifier: 0x81,
+ responseNeeded: false}},
+ {command: "D01C" + // Length
+ "8103012181" + // Command details
+ "82028102" + // Device identities
+ "8D0F04546F6F6C6B697420546573742032" + // Text string
+ "2B00", // Immediate response
+ expect: {commandQualifier: 0x81,
text: "Toolkit Test 2",
- isHighPriority: true,
- userClear: true}},
- {command: "d0198103012180820281028d0e00d4f79bbd4ed341d4f29c0e9a01",
- func: testDisplayText,
- expect: {name: "display_text_cmd_3",
- commandQualifier: 0x80,
- text: "Toolkit Test 3",
- userClear: true}},
- {command: "d01a8103012100820281028d0f04546f6f6c6b697420546573742034",
- func: testDisplayText,
- expect: {name: "display_text_cmd_4",
- commandQualifier: 0x00,
- text: "Toolkit Test 4"}},
- {command: "d081ad8103012180820281028d81a1045468697320636f6d6d616e6420696e7374727563747320746865204d4520746f20646973706c617920612074657874206d6573736167652e20497420616c6c6f7773207468652053494d20746f20646566696e6520746865207072696f72697479206f662074686174206d6573736167652c20616e6420746865207465787420737472696e6720666f726d61742e2054776f207479706573206f66207072696f",
- func: testDisplayText,
- expect: {name: "display_text_cmd_5",
- commandQualifier: 0x80,
- text: "This command instructs the ME to display a text message. It allows the SIM to define the priority of that message, and the text string format. Two types of prio",
- userClear: true}},
- {command: "d01a8103012180820281028d0f043c474f2d4241434b57415244533e",
- func: testDisplayText,
- expect: {name: "display_text_cmd_6",
- commandQualifier: 0x80,
+ responseNeeded: true}},
+ {command: "D081AD" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D81A1045468697320636F6D6D616E6420696E73747275" + // Text string
+ "63747320746865204D4520746F20646973706C61792061" +
+ "2074657874206D6573736167652E20497420616C6C6F77" +
+ "73207468652053494D20746F20646566696E6520746865" +
+ "207072696F72697479206F662074686174206D65737361" +
+ "67652C20616E6420746865207465787420737472696E67" +
+ "20666F726D61742E2054776F207479706573206F662070" +
+ "72696F",
+ expect: {commandQualifier: 0x80,
+ text: "This command instructs the ME to display a text message. " +
+ "It allows the SIM to define the priority of that message," +
+ " and the text string format. Two types of prio",
+ responseNeeded: false}},
+ {command: "D01A" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D0F043C474F2D4241434B57415244533E", // Text string
+ expect: {commandQualifier: 0x80,
text: "<GO-BACKWARDS>",
- userClear: true}},
- {command: "d0248103012180820281028d1908041704140420041004120421042204120423041904220415",
- func: testDisplayText,
- expect: {name: "display_text_cmd_7",
- commandQualifier: 0x80,
+ responseNeeded: false}},
+ {command: "D024" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D19080417041404200410041204210422041204230419" + // Text string
+ "04220415",
+ expect: {commandQualifier: 0x80,
text: "ЗДРАВСТВУЙТЕ",
- userClear: true}},
- {command: "d0108103012180820281028d05084f60597d",
- func: testDisplayText,
- expect: {name: "display_text_cmd_8",
- commandQualifier: 0x80,
+ responseNeeded: false}},
+ {command: "D010" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D05084F60597D", // Text string
+ expect: {commandQualifier: 0x80,
text: "你好",
- userClear: true}},
- {command: "d0128103012180820281028d07080038003030eb",
- func: testDisplayText,
- expect: {name: "display_text_cmd_9",
- commandQualifier: 0x80,
- text: "80ル",
- userClear: true}},
+ responseNeeded: false}},
+ {command: "D028" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "0D1D00D3309BFC06C95C301AA8E80259C3EC34B9AC07C9" + // Text string
+ "602F58ED159BB940",
+ expect: {commandQualifier: 0x80,
+ text: "Saldo 2.04 E. Validez 20/05/13. ",
+ responseNeeded: false}},
+ {command: "D019" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D0A043130205365636F6E64" + // Text string
+ "8402010A", // Duration
+ expect: {commandQualifier: 0x80,
+ text: "10 Second",
+ responseNeeded: false,
+ duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
+ timeInterval: 0x0A}}},
+ {command: "D01A" + // Length
+ "8103012180" + // Command details
+ "82028102" + // Device identities
+ "8D0B0442617369632049636F6E" + // Text string
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x80,
+ text: "Basic Icon",
+ responseNeeded: false,
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON]}},
+ {command: "D026" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1B" + // Text string
+ "00" + // 7BIT
+ "D4F79BBD4ED341D4F29C0E3A4A9F55A80E8687C158A09B304905",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x00, 7BIT",
+ responseNeeded: false}},
+ {command: "D029" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1E" + // Text string
+ "04" + // 8BIT
+ "546F6F6C6B697420546573742047524F55503A307830302C2038424954",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x00, 8BIT",
+ responseNeeded: false}},
+ {command: "D046" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D3B" + // Text string
+ "08" + // UCS2
+ "0054006F006F006C006B0069007400200054006500730074002000470052004F" +
+ "00550050003A0030007800300030002C00200055004300530032",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x00, UCS2",
+ responseNeeded: false}},
+ {command: "D026" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1B" + // Text string
+ "12" + // 7BIT + Class 2
+ "D4F79BBD4ED341D4F29C0E3A4A9F55A80E868FC158A09B304905",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x10, 7BIT",
+ responseNeeded: false}},
+ {command: "D029" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1E" + // Text string
+ "16" + // 8BIT + Class 2
+ "546F6F6C6B697420546573742047524F55503A307831302C2038424954",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x10, 8BIT",
+ responseNeeded: false}},
+ {command: "D046" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D3B" + // Text string
+ "1A" + // UCS2 + Class 2
+ "0054006F006F006C006B0069007400200054006500730074002000470052004F" +
+ "00550050003A0030007800310030002C00200055004300530032",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0x10, UCS2",
+ responseNeeded: false}},
+ {command: "D026" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1B" + // Text string
+ "F2" + // 7BIT + Class 2
+ "D4F79BBD4ED341D4F29C0E3A4A9F55A80E8637C258A09B304905",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0xF0, 7BIT",
+ responseNeeded: false}},
+ {command: "D029" + // Length
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D1E" + // Text string
+ "F6" + // 8BIT + Class 2
+ "546F6F6C6B697420546573742047524F55503A307846302C2038424954",
+ expect: {commandQualifier: 0x00,
+ text: "Toolkit Test GROUP:0xF0, 8BIT",
+ responseNeeded: false}},
+ // Bug 1088573: this test case is to ensure that we provide |length| argument
+ // in |integer| format to GsmPDUHelper.readSeptetsToString().
+ {command: "D081FC" + // Length (2-byte length encoded: 252)
+ "8103012100" + // Command details
+ "82028102" + // Device identities
+ "8D" + // Text string
+ "81F0" + // 2-byte length encoded: 240
+ "00" + // 7BIT
+ "C332A85D9ECFC3E732685E068DDF6DF87B5E0691CB20D96D061A87E5E131BD2C" +
+ "2FCF416537A8FD269741E3771B2E2FCFE76517685806B5CBF379F85C0695E774" +
+ "50D86C4E8FD165D0BC2E07C1D9F579BA5C97CF41E5B13CEC9E83CA7490BB0C22" +
+ "BFD374103C3C0795E9F232882E7FBBE3F5B20B24BBCD40E5391DC42E83DCEFB6" +
+ "585E06B5C3F874BBDE0691CBA071581E1ED3CBF2F21C14369BD3637458CC2EBB" +
+ "40C3329D5E0699DFEE313DFD76BBC3EC34BD0C0A83CAF432280C87CBDF757BB9" +
+ "0C8287E5207619346D1E73A0783D0D9A9FCA733A885C96BFEBEC32280C9A6689" +
+ "CE621654768382D529551A64268B2E",
+ expect: {commandQualifier: 0x00,
+ text: "Ce message se compose de 273 caracteres en mode " +
+ "compresse. Ce message est affiche sur plusieurs " +
+ "ecrans et ne doit pas etre tronque. 273 est le " +
+ "nombre maximum de caracteres affichable. Cette " +
+ "fonctionnalite a ete approuvee par le SMG9 qui s'est " +
+ "deroule a SYDNEY en AUSTRALIE.",
+ responseNeeded: false}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testDisplayText(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_DISPLAY_TEXT,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ is(aCommand.options.userClear, !!(aExpect.commandQualifier & 0x80),
+ "options.userClear");
+ is(aCommand.options.isHighPriority, !!(aExpect.commandQualifier & 0x01),
+ "options.isHighPriority");
+ is(aCommand.options.text, aExpect.text, "options.text");
+ is(aCommand.options.responseNeeded, aExpect.responseNeeded,
+ "options.responseNeeded");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // duration is optional.
+ if ("duration" in aExpect) {
+ let duration = aCommand.options.duration;
+ is(duration.timeUnit, aExpect.duration.timeUnit,
+ "options.duration.timeUnit");
+ is(duration.timeInterval, aExpect.duration.timeInterval,
+ "options.duration.timeInterval");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("display_text_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testDisplayText(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testDisplayText(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_get_inkey.js b/dom/icc/tests/marionette/test_stk_get_inkey.js
index 9368956eb..881622106 100644
--- a/dom/icc/tests/marionette/test_stk_get_inkey.js
+++ b/dom/icc/tests/marionette/test_stk_get_inkey.js
@@ -1,138 +1,161 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testGetInKey(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_GET_INKEY, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.text, expect.text, expect.name);
- if (command.options.isAlphabet) {
- is(command.options.isAlphabet, expect.isAlphabet, expect.name);
- }
- if (command.options.isUCS2) {
- is(command.options.isUCS2, expect.isUCS2, expect.name);
- }
- if (command.options.isYesNoRequested) {
- is(command.options.isYesNoRequested, expect.isYesNoRequested, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d0158103012200820281828d0a04456e74657220222b22",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_1",
- commandQualifier: 0x00,
- text: "Enter \"+\""}},
- {command: "d0148103012200820281828d09004537bd2c07896022",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_2",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D014" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D09004537BD2C07896022", // Text string
+ expect: {commandQualifier: 0x00,
text: "Enter \"0\""}},
- {command: "d01a8103012200820281828d0f043c474f2d4241434b57415244533e",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_3",
- commandQualifier: 0x00,
- text: "<GO-BACKWARDS>"}},
- {command: "d0138103012200820281828d08043c41424f52543e",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_4",
- commandQualifier: 0x00,
- text: "<ABORT>"}},
- {command: "d0158103012201820281828d0a04456e74657220227122",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_5",
- commandQualifier: 0x01,
- text: "Enter \"q\"",
- isAlphabet: true}},
- {command: "d081ad8103012201820281828d81a104456e746572202278222e205468697320636f6d6d616e6420696e7374727563747320746865204d4520746f20646973706c617920746578742c20616e6420746f2065787065637420746865207573657220746f20656e74657220612073696e676c65206368617261637465722e20416e7920726573706f6e736520656e7465726564206279207468652075736572207368616c6c206265207061737365642074",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_6",
- commandQualifier: 0x01,
- text: "Enter \"x\". This command instructs the ME to display text, and to expect the user to enter a single character. Any response entered by the user shall be passed t",
- isAlphabet: true}},
- {command: "d0168103012200820281828d0b043c54494d452d4f55543e",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_7",
- commandQualifier: 0x00,
+ {command: "D00B" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D00", // Text string
+ expect: {commandQualifier: 0x00,
+ text: null}},
+ {command: "D00C" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D0100", // Text string
+ expect: {commandQualifier: 0x00,
+ text: ""}},
+ {command: "D081AD" + // Length
+ "8103012201" + // Command details
+ "82028182" + // Device identities
+ "8D81A104456E746572202278222E205468697320636F6D" + // Text string
+ "6D616E6420696E7374727563747320746865204D452074" +
+ "6F20646973706C617920746578742C20616E6420746F20" +
+ "65787065637420746865207573657220746F20656E7465" +
+ "7220612073696E676C65206368617261637465722E2041" +
+ "6E7920726573706F6E736520656E746572656420627920" +
+ "7468652075736572207368616C6C206265207061737365" +
+ "642074",
+ expect: {commandQualifier: 0x01,
+ text: "Enter \"x\". This command instructs the ME to display " +
+ "text, and to expect the user to enter a single character. " +
+ "Any response entered by the user shall be passed t"}},
+ {command: "D016" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D0B043C54494D452D4F55543E", // Text string
+ expect: {commandQualifier: 0x00,
text: "<TIME-OUT>"}},
- {command: "d0248103012200820281828d1908041704140420041004120421042204120423041904220415",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_8",
- commandQualifier: 0x00,
- text: "ЗДРАВСТВУЙТЕ"}},
- {command: "d081998103012200820281828d818d080417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_9",
- commandQualifier: 0x00,
- text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ"}},
- {command: "d0118103012203820281828d0604456e746572",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_10",
- commandQualifier: 0x03,
- text: "Enter",
- isAlphabet: true,
- isUCS2: true}},
- {command: "d0158103012204820281828d0a04456e74657220594553",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_11",
- commandQualifier: 0x04,
- text: "Enter YES",
- isYesNoRequested: true}},
- {command: "d0148103012204820281828d0904456e746572204e4f",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_12",
- commandQualifier: 0x04,
- text: "Enter NO",
- isYesNoRequested: true}},
- {command: "d0198103012200820281828d0a043c4e4f2d49434f4e3e1e020001",
- func: testGetInKey,
- expect: {name: "get_inkey_cmd_13",
- commandQualifier: 0x00,
+ {command: "D08199" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D818D0804170414042004100412042104220412042304" + // Text string
+ "1904220415041704140420041004120421042204120423" +
+ "0419042204150417041404200410041204210422041204" +
+ "2304190422041504170414042004100412042104220412" +
+ "0423041904220415041704140420041004120421042204" +
+ "1204230419042204150417041404200410041204210422" +
+ "041204230419",
+ expect: {commandQualifier: 0x00,
+ text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДР" +
+ "АВСТВУЙТЕЗДРАВСТВУЙ"}},
+ {command: "D011" + // Length
+ "8103012203" + // Command details
+ "82028182" + // Device identities
+ "8D0604456E746572", // Text string
+ expect: {commandQualifier: 0x03,
+ text: "Enter"}},
+ {command: "D015" + // Length
+ "8103012204" + // Command details
+ "82028182" + // Device identities
+ "8D0A04456E74657220594553", // Text string
+ expect: {commandQualifier: 0x04,
+ text: "Enter YES"}},
+ {command: "D019" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D0A043C4E4F2D49434F4E3E" + // Text string
+ "1E020002", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ // The record number 02 in EFimg is not defined, so no icon will be
+ // shown, but the text string should still be displayed.
text: "<NO-ICON>"}},
+ {command: "D016" + // Length
+ "8103012280" + // Command details
+ "82028182" + // Device identities
+ "8D07043C49434F4E3E" + // Text string
+ "1E020101", // Icon identifier
+ expect: {commandQualifier: 0x80,
+ text: "<ICON>",
+ iconSelfExplanatory: false,
+ icons : [BASIC_ICON]}},
+ {command: "D019" + // Length
+ "8103012200" + // Command details
+ "82028182" + // Device identities
+ "8D0A04456E74657220222B22" + // Text string
+ "8402010A", // Duration
+ expect: {commandQualifier: 0x00,
+ text: "Enter \"+\"",
+ duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
+ timeInterval: 0x0A}}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testGetInKey(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_GET_INKEY, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ is(aCommand.options.isAlphabet, !!(aExpect.commandQualifier & 0x01),
+ "options.isAlphabet");
+ is(aCommand.options.isUCS2, !!(aExpect.commandQualifier & 0x02),
+ "options.isUCS2");
+ is(aCommand.options.isYesNoRequested, !!(aExpect.commandQualifier & 0x04),
+ "options.isYesNoRequested");
+ is(aCommand.options.isHelpAvailable, !!(aExpect.commandQualifier & 0x80),
+ "options.isHelpAvailable");
+ is(aCommand.options.text, aExpect.text, "options.text");
+ is(aCommand.options.minLength, 1, "options.minLength");
+ is(aCommand.options.maxLength, 1, "options.maxLength");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // duration is optional.
+ if ("duration" in aExpect) {
+ let duration = aCommand.options.duration;
+ is(duration.timeUnit, aExpect.duration.timeUnit,
+ "options.duration.timeUnit");
+ is(duration.timeInterval, aExpect.duration.timeInterval,
+ "options.duration.timeInterval");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("get_inkey_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testGetInKey(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testGetInKey(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_get_input.js b/dom/icc/tests/marionette/test_stk_get_input.js
index 06c2be0ad..e0e23e22d 100644
--- a/dom/icc/tests/marionette/test_stk_get_input.js
+++ b/dom/icc/tests/marionette/test_stk_get_input.js
@@ -1,212 +1,202 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testGetInput(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_GET_INPUT, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.text, expect.text, expect.name);
- is(command.options.minLength, expect.minLength, expect.name);
- is(command.options.maxLength, expect.maxLength, expect.name);
- if (command.options.defaultText) {
- is(command.options.defaultText, expect.defaultText, expect.name);
- }
- if (command.options.isAlphabet) {
- is(command.options.isAlphabet, expect.isAlphabet, expect.name);
- }
- if (command.options.isUCS2) {
- is(command.options.isUCS2, expect.isUCS2, expect.name);
- }
- if (command.options.isPacked) {
- is(command.options.isPacked, expect.isPacked, expect.name);
- }
- if (command.options.hideInput) {
- is(command.options.hideInput, expect.hideInput, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d01b8103012300820281828d0c04456e74657220313233343591020505",
- func: testGetInput,
- expect: {name: "get_input_cmd_1",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D01B" + // Length
+ "8103012300" + // Command details
+ "82028182" + // Device identities
+ "8D0C04456E746572203132333435" + // Text string
+ "91020505", // Response length
+ expect: {commandQualifier: 0x00,
text: "Enter 12345",
minLength: 5,
maxLength: 5}},
- {command: "d01a8103012308820281828d0b004537bd2c07d96eaad10a91020505",
- func: testGetInput,
- expect: {name: "get_input_cmd_2",
- commandQualifier: 0x08,
+ {command: "D01A" + // Length
+ "8103012308" + // Command details
+ "82028182" + // Device identities
+ "8D0B004537BD2C07D96EAAD10A" + // Text string
+ "91020505", // Response length
+ expect: {commandQualifier: 0x08,
text: "Enter 67*#+",
minLength: 5,
- maxLength: 5,
- isPacked: true}},
- {command: "d01b8103012301820281828d0c04456e74657220416243644591020505",
- func: testGetInput,
- expect: {name: "get_input_cmd_3",
- commandQualifier: 0x01,
+ maxLength: 5}},
+ {command: "D01B" + // Length
+ "8103012301" + // Command details
+ "82028182" + // Device identities
+ "8D0C04456E746572204162436445" + // Text string
+ "91020505", // Response length
+ expect: {commandQualifier: 0x01,
text: "Enter AbCdE",
minLength: 5,
- maxLength: 5,
- isAlphabet: true}},
- {command: "d0278103012304820281828d180450617373776f726420313c53454e443e3233343536373891020408",
- func: testGetInput,
- expect: {name: "get_input_cmd_4",
- commandQualifier: 0x04,
+ maxLength: 5}},
+ {command: "D027" + // Length
+ "8103012304" + // Command details
+ "82028182" + // Device identities
+ "8D180450617373776F726420313C53454E443E323334" + // Text string
+ "35363738" +
+ "91020408", // Response length
+ expect: {commandQualifier: 0x04,
text: "Password 1<SEND>2345678",
minLength: 4,
- maxLength: 8,
- hideInput: true}},
- {command: "d0248103012300820281828d1504456e74657220312e2e392c302e2e392c3028312991020114",
- func: testGetInput,
- expect: {name: "get_input_cmd_5",
- commandQualifier: 0x00,
- text: "Enter 1..9,0..9,0(1)",
- minLength: 1,
- maxLength: 20}},
- {command: "d01e8103012300820281828d0f043c474f2d4241434b57415244533e91020008",
- func: testGetInput,
- expect: {name: "get_input_cmd_6",
- commandQualifier: 0x00,
- text: "<GO-BACKWARDS>",
- minLength: 0,
maxLength: 8}},
- {command: "d0178103012300820281828d08043c41424f52543e91020008",
- func: testGetInput,
- expect: {name: "get_input_cmd_7",
- commandQualifier: 0x00,
- text: "<ABORT>",
+ {command: "D01E" + // Length
+ "8103012300" + // Command details
+ "82028182" + // Device identities
+ "8D0F043C474F2D4241434B57415244533E" + // Text string
+ "91020008", // Response length
+ expect: {commandQualifier: 0x00,
+ text: "<GO-BACKWARDS>",
minLength: 0,
maxLength: 8}},
- {command: "d081b18103012300820281828d81a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a303030303030303030302323239102a0a0",
- func: testGetInput,
- expect: {name: "get_input_cmd_8",
- commandQualifier: 0x00,
- text: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###",
+ {command: "D081B1" + // Length
+ "8103012300" + // Command details
+ "82028182" + // Device identities
+ "8D81A1042A2A2A313131313131313131312323232A2A2A" + // Text string
+ "323232323232323232322323232A2A2A33333333333333" +
+ "3333332323232A2A2A343434343434343434342323232A" +
+ "2A2A353535353535353535352323232A2A2A3636363636" +
+ "36363636362323232A2A2A373737373737373737372323" +
+ "232A2A2A383838383838383838382323232A2A2A393939" +
+ "393939393939392323232A2A2A30303030303030303030" +
+ "232323" +
+ "9102A0A0", // Response length
+ expect: {commandQualifier: 0x00,
+ text: "***1111111111###***2222222222###***3333333333###***444444" +
+ "4444###***5555555555###***6666666666###***7777777777###**" +
+ "*8888888888###***9999999999###***0000000000###",
minLength: 160,
maxLength: 160}},
- {command: "d0168103012300820281828d07043c53454e443e91020001",
- func: testGetInput,
- expect: {name: "get_input_cmd_9",
- commandQualifier: 0x00,
- text: "<SEND>",
- minLength: 0,
- maxLength: 1}},
- {command: "d01a8103012300820281828d0b043c54494d452d4f55543e9102000a",
- func: testGetInput,
- expect: {name: "get_input_cmd_10",
- commandQualifier: 0x00,
- text: "<TIME-OUT>",
- minLength: 0,
- maxLength: 10}},
- {command: "d0288103012301820281828d190804170414042004100412042104220412042304190422041591020505",
- func: testGetInput,
- expect: {name: "get_input_cmd_11",
- commandQualifier: 0x01,
- text: "ЗДРАВСТВУЙТЕ",
- minLength: 5,
- maxLength: 5,
- isAlphabet: true}},
- {command: "d0819d8103012301820281828d818d08041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041991020505",
- func: testGetInput,
- expect: {name: "get_input_cmd_12",
- commandQualifier: 0x01,
- text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ",
+ {command: "D0819D" + // Length
+ "8103012301" + // Command details
+ "82028182" + // Device identities
+ "8D818D0804170414042004100412042104220412042304" + // Text string
+ "1904220415041704140420041004120421042204120423" +
+ "0419042204150417041404200410041204210422041204" +
+ "2304190422041504170414042004100412042104220412" +
+ "0423041904220415041704140420041004120421042204" +
+ "1204230419042204150417041404200410041204210422" +
+ "041204230419" +
+ "91020505", // Response length
+ expect: {commandQualifier: 0x01,
+ text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУ" +
+ "ЙТЕЗДРАВСТВУЙ",
minLength: 5,
- maxLength: 5,
- isAlphabet: true}},
- {command: "d01b8103012303820281828d0c04456e7465722048656c6c6f91020c0c",
- func: testGetInput,
- expect: {name: "get_input_cmd_13",
- commandQualifier: 0x03,
- text: "Enter Hello",
- minLength: 12,
- maxLength: 12,
- isAlphabet: true,
- isUCS2: true}},
- {command: "d01b8103012303820281828d0c04456e7465722048656c6c6f910205ff",
- func: testGetInput,
- expect: {name: "get_input_cmd_14",
- commandQualifier: 0x03,
+ maxLength: 5}},
+ {command: "D01B" + // Length
+ "8103012303" + // Command details
+ "82028182" + // Device identities
+ "8D0C04456E7465722048656C6C6F" + // Text string
+ "910205FF", // Response length
+ expect: {commandQualifier: 0x03,
text: "Enter Hello",
minLength: 5,
- maxLength: 0xFF,
- isAlphabet: true,
- isUCS2: true}},
- {command: "d0238103012300820281828d0c04456e746572203132333435910205051706043132333435",
- func: testGetInput,
- expect: {name: "get_input_cmd_15",
- commandQualifier: 0x00,
- text: "Enter 12345",
- minLength: 5,
- maxLength: 5,
- defaultText: "12345"}},
- {command: "d081ba8103012300820281828d0704456e7465723a9102a0a01781a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a30303030303030303030232323",
- func: testGetInput,
- expect: {name: "get_input_cmd_16",
- commandQualifier: 0x00,
+ maxLength: 0xFF}},
+ {command: "D081BA" + // Length
+ "8103012300" + // Command details
+ "82028182" + // Device identities
+ "8D0704456E7465723A" + // Text string
+ "9102A0A0" + // Response length
+ "1781A1042A2A2A313131313131313131312323232A2A2A" + // Default text
+ "323232323232323232322323232A2A2A33333333333333" +
+ "3333332323232A2A2A343434343434343434342323232A" +
+ "2A2A353535353535353535352323232A2A2A3636363636" +
+ "36363636362323232A2A2A373737373737373737372323" +
+ "232A2A2A383838383838383838382323232A2A2A393939" +
+ "393939393939392323232A2A2A30303030303030303030" +
+ "232323",
+ expect: {commandQualifier: 0x00,
text: "Enter:",
minLength: 160,
maxLength: 160,
- defaultText: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###"}},
- {command: "d01d8103012300820281828d0a043c4e4f2d49434f4e3e9102000a1e020001",
- func: testGetInput,
- expect: {name: "get_input_cmd_17",
- commandQualifier: 0x00,
+ defaultText: "***1111111111###***2222222222###***3333333333###**" +
+ "*4444444444###***5555555555###***6666666666###***7" +
+ "777777777###***8888888888###***9999999999###***000" +
+ "0000000###"}},
+ {command: "D01D" + // Length
+ "8103012300" + // Command details
+ "82028182" + // Device identities
+ "8D0A043C4E4F2D49434F4E3E" + // Text string
+ "9102000A" + // Response length
+ "1E020002", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ // The record number 02 in EFimg is not defined, so no icon will be
+ // shown, but the text string should still be displayed.
text: "<NO-ICON>",
minLength: 0,
maxLength: 10}},
- {command: "d0208103012300820281828d0d043c42415349432d49434f4e3e9102000a1e020101",
- func: testGetInput,
- expect: {name: "get_input_cmd_18",
- commandQualifier: 0x00,
+ {command: "D020" + // Length
+ "8103012380" + // Command details
+ "82028182" + // Device identities
+ "8D0D043C42415349432D49434F4E3E" + // Text string
+ "9102000A" + // Response length
+ "1E020101", // Icon identifier
+ expect: {commandQualifier: 0x80,
text: "<BASIC-ICON>",
minLength: 0,
- maxLength: 10}},
+ maxLength: 10,
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON]}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testGetInput(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_GET_INPUT, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ is(aCommand.options.isAlphabet, !!(aExpect.commandQualifier & 0x01),
+ "options.isAlphabet");
+ is(aCommand.options.isUCS2, !!(aExpect.commandQualifier & 0x02),
+ "options.isUCS2");
+ is(aCommand.options.hideInput, !!(aExpect.commandQualifier & 0x04),
+ "options.hideInput");
+ is(aCommand.options.isPacked, !!(aExpect.commandQualifier & 0x08),
+ "options.isPacked");
+ is(aCommand.options.isHelpAvailable, !!(aExpect.commandQualifier & 0x80),
+ "options.isHelpAvailable");
+ is(aCommand.options.text, aExpect.text, "options.text");
+ is(aCommand.options.minLength, aExpect.minLength, "options.minLength");
+ is(aCommand.options.maxLength, aExpect.maxLength, "options.maxLength");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // defaultText is optional.
+ if ("defaultText" in aExpect) {
+ is(aCommand.options.defaultText, aExpect.defaultText, "options.defaultText");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("get_input_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testGetInput(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testGetInput(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_launch_browser.js b/dom/icc/tests/marionette/test_stk_launch_browser.js
index 5d20f0dfa..c47277a1a 100644
--- a/dom/icc/tests/marionette/test_stk_launch_browser.js
+++ b/dom/icc/tests/marionette/test_stk_launch_browser.js
@@ -1,289 +1,151 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testLaunchBrowser(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_LAUNCH_BROWSER, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.url, expect.url, expect.name);
- if (command.options.confirmMessage) {
- is(command.options.confirmMessage, expect.text, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d0188103011500820281823100050b44656661756c742055524c",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_1",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL"}},
- {command: "d01f8103011500820281823112687474703a2f2f7878782e7979792e7a7a7a0500",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_2",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D018" + // Length
+ "8103011500" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "050B44656661756C742055524C", // Alpha identifier
+ expect: {commandQualifier: 0x00,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED,
+ confirmMessage: { text: "Default URL" }}},
+ {command: "D01F" + // Length
+ "8103011500" + // Command details
+ "82028182" + // Device identities
+ "3112687474703A2F2F7878782E7979792E7A7A7A" + // URL
+ "0500", // Alpha identifier
+ expect: {commandQualifier: 0x00,
url: "http://xxx.yyy.zzz",
- text: ""}},
- {command: "d00e8103011500820281823001003100",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_3",
- commandQualifier: 0x00,
- url: "",
- text: ""}},
- {command: "d02081030115008202818231003201030d10046162632e6465662e6768692e6a6b6c",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_4",
- commandQualifier: 0x00,
- url: "",
- text: ""}},
- {command: "d0188103011502820281823100050b44656661756c742055524c",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_5",
- commandQualifier: 0x02,
- url: "",
- text: "Default URL"}},
- {command: "d0188103011503820281823100050b44656661756c742055524c",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_6",
- commandQualifier: 0x03,
- url: "",
- text: "Default URL"}},
- {command: "d00b8103011500820281823100",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_7",
- commandQualifier: 0x00,
- url: "",
- text: ""}},
- {command: "d0268103011502820281823100051980041704140420041004120421042204120423041904220415",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_8",
- commandQualifier: 0x02,
- url: "",
- text: "ЗДРАВСТВУЙТЕ"}},
- {command: "d021810301150282028182310005104e6f742073656c66206578706c616e2e1e020101",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_9",
- commandQualifier: 0x02,
- url: "",
- text: "Not self explan."}},
- {command: "d01d8103011502820281823100050c53656c66206578706c616e2e1e020001",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_10",
- commandQualifier: 0x02,
- url: "",
- text: "Self explan."}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_11",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2032",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_12",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d01b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_13",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2032",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_14",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d02b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_15",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2032",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_16",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d04b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_17",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_18",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_19",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d08b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_20",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_21",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_22",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d10b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_23",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_24",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_25",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d20b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_26",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_27",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_28",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d40b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_29",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_30",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_31",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d80b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_32",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_33",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2033",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_34",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 3"}},
- {command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d00b4",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_35",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 1"}},
- {command: "d01a8103011500820281823100050d44656661756c742055524c2032",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_36",
- commandQualifier: 0x00,
- url: "",
- text: "Default URL 2"}},
- {command: "d01281030115028202818231000505804f60597d",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_37",
- commandQualifier: 0x02,
- url: "",
- text: "你好"}},
- {command: "d010810301150282028182310005038030eb",
- func: testLaunchBrowser,
- expect: {name: "launch_browser_cmd_38",
- commandQualifier: 0x02,
- url: "",
- text: "ル"}}
+ mode: MozIccManager.STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED,
+ confirmMessage: { text: "" }}},
+ {command: "D023" + // Length
+ "8103011500" + // Command details
+ "82028182" + // Device identities
+ "300100" + // Browser identity
+ "3100" + // URL
+ "320103" + // Bear
+ "0D10046162632E6465662E6768692E6A6B6C", // Text string
+ expect: {commandQualifier: 0x00,
+ // Browser identity, Bear and Text string are useless.
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED}},
+ {command: "D018" + // Length
+ "8103011502" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "050B44656661756C742055524C", // Alpha identifier
+ expect: {commandQualifier: 0x02,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_USING_EXISTING_BROWSER,
+ confirmMessage: { text: "Default URL" }}},
+ {command: "D018" + // Length
+ "8103011503" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "050B44656661756C742055524C", // Alpha identifier
+ expect: {commandQualifier: 0x03,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_USING_NEW_BROWSER,
+ confirmMessage: { text: "Default URL"}}},
+ {command: "D026" + // Length
+ "8103011502" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "051980041704140420041004120421042204120423" + // Alpha identifier
+ "041904220415",
+ expect: {commandQualifier: 0x02,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_USING_EXISTING_BROWSER,
+ confirmMessage: { text: "ЗДРАВСТВУЙТЕ" }}},
+ {command: "D021" + // Length
+ "8103011502" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "05104E6F742073656C66206578706C616E2E" + // Alpha identifier
+ "1E020101", // Icon identifier
+ expect: {commandQualifier: 0x02,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_USING_EXISTING_BROWSER,
+ confirmMessage: { text: "Not self explan.",
+ iconSelfExplanatory: false,
+ icons : [BASIC_ICON] }
+ }},
+ {command: "D012" + // Length
+ "8103011502" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "0505804F60597D", // Alpha identifier
+ expect: {commandQualifier: 0x02,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_USING_EXISTING_BROWSER,
+ confirmMessage: { text: "你好" }}},
+ {command: "D00F" + // Length
+ "8103011500" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "1E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED,
+ confirmMessage: { iconSelfExplanatory: true,
+ icons: [BASIC_ICON] }}},
+ {command: "D00F" + // Length
+ "8103011500" + // Command details
+ "82028182" + // Device identities
+ "3100" + // URL
+ "1E020003", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ url: "",
+ mode: MozIccManager.STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED,
+ confirmMessage: { iconSelfExplanatory: true,
+ icons: [COLOR_ICON] }}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testLaunchBrowser(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_LAUNCH_BROWSER,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ is(aCommand.options.url, aExpect.url, "options.url");
+ is(aCommand.options.mode, aExpect.mode, "options.mode");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // confirmMessage is optional
+ if ("confirmMessage" in aExpect) {
+ isStkText(aCommand.options.confirmMessage, aExpect.confirmMessage,
+ "options.confirmMessage");
}
}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("launch_browser_cmd: " + data.command);
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testLaunchBrowser(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testLaunchBrowser(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
+ return Promise.all(promises);
+ });
}
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_local_info.js b/dom/icc/tests/marionette/test_stk_local_info.js
new file mode 100644
index 000000000..8c2a064b6
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_local_info.js
@@ -0,0 +1,69 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ // Location
+ {command: "D009" + // Length
+ "8103012600" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: MozIccManager.STK_LOCAL_INFO_LOCATION_INFO,
+ localInfoType: MozIccManager.STK_LOCAL_INFO_LOCATION_INFO}},
+ // Imei
+ {command: "D009" + // Length
+ "8103012601" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: MozIccManager.STK_LOCAL_INFO_IMEI,
+ localInfoType: MozIccManager.STK_LOCAL_INFO_IMEI}},
+ // Data
+ {command: "D009" + // Length
+ "8103012603" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: MozIccManager.STK_LOCAL_INFO_DATE_TIME_ZONE,
+ localInfoType: MozIccManager.STK_LOCAL_INFO_DATE_TIME_ZONE}},
+ // Language
+ {command: "D009" + // Length
+ "8103012604" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: MozIccManager.STK_LOCAL_INFO_LANGUAGE,
+ localInfoType: MozIccManager.STK_LOCAL_INFO_LANGUAGE}},
+];
+
+function testLocalInfo(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_PROVIDE_LOCAL_INFO,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+ is(aCommand.options.localInfoType, aExpect.localInfoType,
+ "options.localInfoType");
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("local_info_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testLocalInfo(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testLocalInfo(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_play_tone.js b/dom/icc/tests/marionette/test_stk_play_tone.js
new file mode 100644
index 000000000..e156c4c80
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_play_tone.js
@@ -0,0 +1,120 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ {command: "D009" + // Length
+ "8103012000" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: 0x00}},
+ {command: "D014" + // Length
+ "8103012001" + // Command details
+ "82028182" + // Device identities
+ "8509506C617920546F6E65", // Alpha identifier
+ expect: {commandQualifier: 0x01,
+ text: "Play Tone"}},
+ {command: "D00B" + // Length
+ "8103012001" + // Command details
+ "82028182" + // Device identities
+ "8500", // Alpha identifier
+ expect: {commandQualifier: 0x01,
+ text: ""}},
+ {command: "D00C" + // Length
+ "8103012000" + // Command details
+ "82028182" + // Device identities
+ "8E0101", // Tone
+ expect: {commandQualifier: 0x00,
+ tone: 0x01}},
+ {command: "D00D" + // Length
+ "8103012000" + // Command details
+ "82028182" + // Device identities
+ "84020205", // Duration
+ expect: {commandQualifier: 0x00,
+ duration: {timeUnit: MozIccManager.STK_TIME_UNIT_TENTH_SECOND,
+ timeInterval: 0x05}}},
+ {command: "D00D" + // Length
+ "8103012000" + // Command details
+ "82028182" + // Device identities
+ "1E020101", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON]}},
+ {command: "D01F" + // Length
+ "8103012001" + // Command details
+ "82028182" + // Device identities
+ "8509506C617920546F6E65" + // Alpha identifier
+ "8E0101" + // Tone
+ "84020202" + // Duration
+ "1E020003", // Icon identifier
+ expect: {commandQualifier: 0x01,
+ text: "Play Tone",
+ duration: {timeUnit: MozIccManager.STK_TIME_UNIT_TENTH_SECOND,
+ timeInterval: 0x02},
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON]}},
+];
+
+function testPlayTone(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_PLAY_TONE, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+
+ is(aCommand.options.isVibrate, !!(aExpect.commandQualifier & 0x01),
+ "options.isVibrate");
+
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
+ }
+
+ // tone is optional.
+ if ("tone" in aExpect) {
+ is(aCommand.options.tone, aExpect.tone, "options.tone");
+ }
+
+ // duration is optional.
+ if ("duration" in aExpect) {
+ let duration = aCommand.options.duration;
+ is(duration.timeUnit, aExpect.duration.timeUnit,
+ "options.duration.timeUnit");
+ is(duration.timeInterval, aExpect.duration.timeInterval,
+ "options.duration.timeInterval");
+ }
+
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("play_tone_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testPlayTone(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testPlayTone(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_poll_interval.js b/dom/icc/tests/marionette/test_stk_poll_interval.js
new file mode 100644
index 000000000..09251b1da
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_poll_interval.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ {command: "D00D" + // Length
+ "8103010300" + // Command details
+ "82028182" + // Device identities
+ "8402001A", // Duration
+ expect: {commandQualifier: 0x00,
+ timeUnit: MozIccManager.STK_TIME_UNIT_MINUTE,
+ timeInterval: 0x1A}},
+ {command: "D00D" + // Length
+ "8103010300" + // Command details
+ "82028182" + // Device identities
+ "8402010A", // Duration
+ expect: {commandQualifier: 0x00,
+ timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
+ timeInterval: 0x0A}},
+ {command: "D00D" + // Length
+ "8103010300" + // Command details
+ "82028182" + // Device identities
+ "84020205", // Duration
+ expect: {commandQualifier: 0x00,
+ timeUnit: MozIccManager.STK_TIME_UNIT_TENTH_SECOND,
+ timeInterval: 0x05}},
+];
+
+function testPollOff(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_POLL_INTERVAL,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+ is(aCommand.options.timeUnit, aExpect.timeUnit,
+ "options.timeUnit");
+ is(aCommand.options.timeInterval, aExpect.timeInterval,
+ "options.timeInterval");
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("poll_interval_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testPollOff(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testPollOff(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_poll_off.js b/dom/icc/tests/marionette/test_stk_poll_off.js
index ca4b93bd2..83fab4b7a 100644
--- a/dom/icc/tests/marionette/test_stk_poll_off.js
+++ b/dom/icc/tests/marionette/test_stk_poll_off.js
@@ -1,61 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testPollOff(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_POLL_OFF, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
-
- runNextTest();
-}
-
-let tests = [
- {command: "d009810301040082028182",
- func: testPollOff,
- expect: {name: "pull_off_cmd_1",
- commandQualifier: 0x00}}
+const TEST_DATA = [
+ {command: "D009" + // Length
+ "8103010400" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: 0x00}}
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
-
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
- }
+function testPollOff(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_POLL_OFF, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("poll_off_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testPollOff(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testPollOff(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
-}
-
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_proactive_command.js b/dom/icc/tests/marionette/test_stk_proactive_command.js
deleted file mode 100644
index 08a0662c8..000000000
--- a/dom/icc/tests/marionette/test_stk_proactive_command.js
+++ /dev/null
@@ -1,244 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 30000;
-
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testDisplayTextGsm7BitEncoding(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_DISPLAY_TEXT);
- is(cmd.options.userClear, true);
- is(cmd.options.text, "Saldo 2.04 E. Validez 20/05/13. ");
-
- runNextTest();
-}
-
-function testLocalInfoLocation(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_PROVIDE_LOCAL_INFO);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_LOCAL_INFO_LOCATION_INFO);
- is(cmd.options.localInfoType, icc.STK_LOCAL_INFO_LOCATION_INFO);
-
- runNextTest();
-}
-
-function testLocalInfoImei(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_PROVIDE_LOCAL_INFO);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_LOCAL_INFO_IMEI);
- is(cmd.options.localInfoType, icc.STK_LOCAL_INFO_IMEI);
-
- runNextTest();
-}
-
-function testLocalInfoDate(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_PROVIDE_LOCAL_INFO);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_LOCAL_INFO_DATE_TIME_ZONE);
- is(cmd.options.localInfoType, icc.STK_LOCAL_INFO_DATE_TIME_ZONE);
-
- runNextTest();
-}
-
-function testLocalInfoLanguage(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_PROVIDE_LOCAL_INFO);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_LOCAL_INFO_LANGUAGE);
- is(cmd.options.localInfoType, icc.STK_LOCAL_INFO_LANGUAGE);
-
- runNextTest();
-}
-
-function isFirstMenuItemNull(cmd) {
- return (cmd.options.items.length == 1 && !(cmd.options.items[0]));
-}
-
-function testInitialSetupMenu(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_SET_UP_MENU);
- is(isFirstMenuItemNull(cmd), false);
-
- runNextTest();
-}
-function testRemoveSetupMenu(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_SET_UP_MENU);
- is(isFirstMenuItemNull(cmd), true);
-
- runNextTest();
-}
-
-function testPollingOff(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_POLL_OFF);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, 0x00);
- is(cmd.options, null);
-
- runNextTest();
-}
-
-function testRefresh(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_REFRESH);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, 0x01);
- is(cmd.options, null);
-
- runNextTest();
-}
-
-function testTimerManagementStart(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_TIMER_START);
- is(cmd.options.timerAction, icc.STK_TIMER_START);
- is(cmd.options.timerId, 0x01);
- is(cmd.options.timerValue, (0x01 * 60 * 60) + (0x02 * 60) + 0x03);
-
- runNextTest();
-}
-
-function testTimerManagementDeactivate(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_TIMER_DEACTIVATE);
- is(cmd.options.timerAction, icc.STK_TIMER_DEACTIVATE);
- is(cmd.options.timerId, 0x04);
-
- runNextTest();
-}
-
-function testTimerManagementGetCurrentValue(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, icc.STK_TIMER_GET_CURRENT_VALUE);
- is(cmd.options.timerAction, icc.STK_TIMER_GET_CURRENT_VALUE);
- is(cmd.options.timerId, 0x08);
-
- runNextTest();
-}
-
-function testGetInKeyVariableTimeout(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_GET_INKEY);
- is(cmd.options.duration.timeUnit, 0x01);
- is(cmd.options.duration.timeInterval, 0x0A);
-
- runNextTest();
-}
-
-function testSetupCall(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_SET_UP_CALL);
- is(cmd.commandNumber, 0x01);
- is(cmd.commandQualifier, 0x04);
- is(cmd.options.address, "012340123456,1,2");
- is(cmd.options.confirmMessage, "Disconnect");
- is(cmd.options.callMessage, "Message");
-
- runNextTest();
-}
-
-function testDisplayTextVariableTimeOut(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_DISPLAY_TEXT);
- is(cmd.commandNumber, 0x01);
- is(cmd.options.duration.timeUnit, icc.STK_TIME_UNIT_SECOND);
- is(cmd.options.duration.timeInterval, 0x0A);
-
- runNextTest();
-}
-
-function testSetUpCallVariableTimeOut(cmd) {
- log("STK CMD " + JSON.stringify(cmd));
- is(cmd.typeOfCommand, icc.STK_CMD_SET_UP_CALL);
- is(cmd.commandNumber, 0x01);
- is(cmd.options.duration.timeUnit, icc.STK_TIME_UNIT_SECOND);
- is(cmd.options.duration.timeInterval, 0x0A);
-
- runNextTest();
-}
-
-let tests = [
- {command: "d0288103012180820281020d1d00d3309bfc06c95c301aa8e80259c3ec34b9ac07c9602f58ed159bb940",
- func: testDisplayTextGsm7BitEncoding},
- {command: "d009810301260082028182",
- func: testLocalInfoLocation},
- {command: "d009810301260182028182",
- func: testLocalInfoImei},
- {command: "d009810301260382028182",
- func: testLocalInfoDate},
- {command: "d009810301260482028182",
- func: testLocalInfoLanguage},
- {command: "D00D81030125008202818285008F00",
- func: testRemoveSetupMenu},
- {command:"D03B810301250082028182850C546F6F6C6B6974204D656E758F07014974656D20318F07024974656D20328F07034974656D20338F07044974656D2034",
- func: testInitialSetupMenu},
- {command: "d009810301040082028182",
- func: testPollingOff},
- {command: "d0108103010101820281829205013f002fe2",
- func: testRefresh},
- {command: "d011810301270082028182a40101a503102030",
- func: testTimerManagementStart},
- {command: "d00c810301270182028182a40104",
- func: testTimerManagementDeactivate},
- {command: "d00c810301270282028182a40108",
- func: testTimerManagementGetCurrentValue},
- {command: "d029810301100482028182050a446973636f6e6e6563748609811032042143651c2c05074d657373616765",
- func: testSetupCall},
- {command: "D0198103012200820281828D0A04456E74657220222B228402010A",
- func: testGetInKeyVariableTimeout},
- {command: "d0198103012180820281028D0A043130205365636F6E648402010A",
- func: testDisplayTextVariableTimeOut},
- {command: "d02281030110008202818385084E6F7420627573798609911032042143651C2C8402010A",
- func: testSetUpCallVariableTimeOut},
-];
-
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(cmd, func) {
- ++pendingEmulatorCmdCount;
-
- runEmulatorCmd(cmd, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command);
- }
-}
-
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
-
- let cmd = "stk pdu " + test.command;
- sendStkPduToEmulator(cmd, test.func)
-}
-
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
diff --git a/dom/icc/tests/marionette/test_stk_refresh.js b/dom/icc/tests/marionette/test_stk_refresh.js
index c76e1459e..ed4ad4214 100644
--- a/dom/icc/tests/marionette/test_stk_refresh.js
+++ b/dom/icc/tests/marionette/test_stk_refresh.js
@@ -1,65 +1,51 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 30000;
-
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testRefresh(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_REFRESH, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
-
- runNextTest();
-}
-
-let tests = [
- {command: "d0108103010101820281829205013f002fe2",
- func: testRefresh,
- expect: {name: "refresh_cmd_1",
- commandQualifier: 0x01}},
- {command: "d009810301010482028182",
- func: testRefresh,
- expect: {name: "refresh_cmd_2",
- commandQualifier: 0x04}}
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ {command: "D010" + // Length
+ "8103010101" + // Command details
+ "82028182" + // Device identities
+ "9205013F002FE2", // File list
+ expect: {commandQualifier: 0x01}},
+ {command: "D009" + // Length
+ "8103010104" + // Command details
+ "82028182", // Device identities
+ expect: {commandQualifier: 0x04}}
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
-
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
- }
-}
-
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
+function testRefresh(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_REFRESH, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("refresh_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testRefresh(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testRefresh(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
}
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_select_item.js b/dom/icc/tests/marionette/test_stk_select_item.js
index 69497aa68..c3236a54b 100644
--- a/dom/icc/tests/marionette/test_stk_select_item.js
+++ b/dom/icc/tests/marionette/test_stk_select_item.js
@@ -1,350 +1,347 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSelectItem(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SELECT_ITEM, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.title, expect.title, expect.name);
- for (let index in command.options.items) {
- is(command.options.items[index].identifier, expect.items[index].identifier, expect.name);
- is(command.options.items[index].text, expect.items[index].text, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d03d810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
- func: testSelectItem,
- expect: {name: "select_item_cmd_1",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D03D" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "8F07044974656D2034", // Item
+ expect: {commandQualifier: 0x00,
title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
- {command: "d081fc810301240082028182850a4c617267654d656e75318f05505a65726f8f044f4f6e658f044e54776f8f064d54687265658f054c466f75728f054b466976658f044a5369788f0649536576656e8f064845696768748f05474e696e658f0646416c7068618f0645427261766f8f0844436861726c69658f064344656c74618f05424563686f8f0941466f782d74726f748f0640426c61636b8f063f42726f776e8f043e5265648f073d4f72616e67658f073c59656c6c6f778f063b477265656e8f053a426c75658f073956696f6c65748f0538477265798f063757686974658f06366d696c6c698f06356d6963726f8f05346e616e6f8f05337069636f",
- func: testSelectItem,
- expect: {name: "select_item_cmd_2",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"},
+ {identifier: 4, text: "Item 4"}]}},
+ {command: "D081FC" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850A4C617267654D656E7531" + // Alpha identifier
+ "8F05505A65726F" + // Item
+ "8F044F4F6E65" + // Item
+ "8F044E54776F" + // Item
+ "8F064D5468726565" + // Item
+ "8F054C466F7572" + // Item
+ "8F054B46697665" + // Item
+ "8F044A536978" + // Item
+ "8F0649536576656E" + // Item
+ "8F06484569676874" + // Item
+ "8F05474E696E65" + // Item
+ "8F0646416C706861" + // Item
+ "8F0645427261766F" + // Item
+ "8F0844436861726C6965" + // Item
+ "8F064344656C7461" + // Item
+ "8F05424563686F" + // Item
+ "8F0941466F782D74726F74" + // Item
+ "8F0640426C61636B" + // Item
+ "8F063F42726F776E" + // Item
+ "8F043E526564" + // Item
+ "8F073D4F72616E6765" + // Item
+ "8F073C59656C6C6F77" + // Item
+ "8F063B477265656E" + // Item
+ "8F053A426C7565" + // Item
+ "8F073956696F6C6574" + // Item
+ "8F053847726579" + // Item
+ "8F06375768697465" + // Item
+ "8F06366D696C6C69" + // Item
+ "8F06356D6963726F" + // Item
+ "8F05346E616E6F" + // Item
+ "8F05337069636F", // Item
+ expect: {commandQualifier: 0x00,
title: "LargeMenu1",
- items: [{identifier: 80, text: "Zero"}, {identifier: 79, text: "One"}, {identifier: 78, text: "Two"}, {identifier: 77, text: "Three"}, {identifier: 76, text: "Four"}, {identifier: 75, text: "Five"}, {identifier: 74, text: "Six"}, {identifier: 73, text: "Seven"}, {identifier: 72, text: "Eight"}, {identifier: 71, text: "Nine"}, {identifier: 70, text: "Alpha"}, {identifier: 69, text: "Bravo"}, {identifier: 68, text: "Charlie"}, {identifier: 67, text: "Delta"}, {identifier: 66, text: "Echo"}, {identifier: 65, text: "Fox-trot"}, {identifier: 64, text: "Black"}, {identifier: 63, text: "Brown"}, {identifier: 62, text: "Red"}, {identifier: 61, text: "Orange"}, {identifier: 60, text: "Yellow"}, {identifier: 59, text: "Green"}, {identifier: 58, text: "Blue"}, {identifier: 57, text: "Violet"}, {identifier: 56, text: "Grey"}, {identifier: 55, text: "White"}, {identifier: 54, text: "milli"}, {identifier: 53, text: "micro"}, {identifier: 52, text: "nano"}, {identifier: 51, text: "pico"}]}},
- {command: "d081fb810301240082028182850a4c617267654d656e75328f1eff43616c6c20466f7277617264696e6720556e636f6e646974696f6e616c8f1dfe43616c6c20466f7277617264696e67204f6e205573657220427573798f1cfd43616c6c20466f7277617264696e67204f6e204e6f205265706c798f26fc43616c6c20466f7277617264696e67204f6e2055736572204e6f7420526561636861626c658f1efb42617272696e67204f6620416c6c204f7574676f696e672043616c6c738f2cfa42617272696e67204f6620416c6c204f7574676f696e6720496e7465726e6174696f6e616c2043616c6c738f11f9434c492050726573656e746174696f6e",
- func: testSelectItem,
- expect: {name: "select_item_cmd_3",
- commandQualifier: 0x00,
+ items: [{identifier: 80, text: "Zero"},
+ {identifier: 79, text: "One"},
+ {identifier: 78, text: "Two"},
+ {identifier: 77, text: "Three"},
+ {identifier: 76, text: "Four"},
+ {identifier: 75, text: "Five"},
+ {identifier: 74, text: "Six"},
+ {identifier: 73, text: "Seven"},
+ {identifier: 72, text: "Eight"},
+ {identifier: 71, text: "Nine"},
+ {identifier: 70, text: "Alpha"},
+ {identifier: 69, text: "Bravo"},
+ {identifier: 68, text: "Charlie"},
+ {identifier: 67, text: "Delta"},
+ {identifier: 66, text: "Echo"},
+ {identifier: 65, text: "Fox-trot"},
+ {identifier: 64, text: "Black"},
+ {identifier: 63, text: "Brown"},
+ {identifier: 62, text: "Red"},
+ {identifier: 61, text: "Orange"},
+ {identifier: 60, text: "Yellow"},
+ {identifier: 59, text: "Green"},
+ {identifier: 58, text: "Blue"},
+ {identifier: 57, text: "Violet"},
+ {identifier: 56, text: "Grey"},
+ {identifier: 55, text: "White"},
+ {identifier: 54, text: "milli"},
+ {identifier: 53, text: "micro"},
+ {identifier: 52, text: "nano"},
+ {identifier: 51, text: "pico"}]}},
+ {command: "D081FB" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850A4C617267654D656E7532" + // Alpha identifier
+ "8F1EFF43616C6C20466F7277617264696E6720556E636F6E6469" + // Item
+ "74696F6E616C" +
+ "8F1DFE43616C6C20466F7277617264696E67204F6E2055736572" + // Item
+ "2042757379" +
+ "8F1CFD43616C6C20466F7277617264696E67204F6E204E6F2052" + // Item
+ "65706C79" +
+ "8F26FC43616C6C20466F7277617264696E67204F6E2055736572" + // Item
+ "204E6F7420526561636861626C65" +
+ "8F1EFB42617272696E67204F6620416C6C204F7574676F696E67" + // Item
+ "2043616C6C73" +
+ "8F2CFA42617272696E67204F6620416C6C204F7574676F696E67" + // Item
+ "20496E7465726E6174696F6E616C2043616C6C73" +
+ "8F11F9434C492050726573656E746174696F6E", // Item
+ expect: {commandQualifier: 0x00,
title: "LargeMenu2",
- items: [{identifier: 255, text: "Call Forwarding Unconditional"}, {identifier: 254, text: "Call Forwarding On User Busy"}, {identifier: 253, text: "Call Forwarding On No Reply"}, {identifier: 252, text: "Call Forwarding On User Not Reachable"}, {identifier: 251, text: "Barring Of All Outgoing Calls"}, {identifier: 250, text: "Barring Of All Outgoing International Calls"}, {identifier: 249, text: "CLI Presentation"}]}},
- {command: "d022810301240082028182850b53656c656374204974656d8f04114f6e658f041254776f",
- func: testSelectItem,
- expect: {name: "select_item_cmd_4",
- commandQualifier: 0x00,
- title: "Select Item",
- items: [{identifier: 17, text: "One"}, {identifier: 18, text: "Two"}]}},
- {command: "d081fd8103012400820281828581ed5468652053494d207368616c6c20737570706c79206120736574206f66206974656d732066726f6d207768696368207468652075736572206d61792063686f6f7365206f6e652e2045616368206974656d20636f6d70726973657320612073686f7274206964656e74696669657220287573656420746f20696e646963617465207468652073656c656374696f6e2920616e642061207465787420737472696e672e204f7074696f6e616c6c79207468652053494d206d617920696e636c75646520616e20616c706861206964656e7469666965722e2054686520616c706861206964656e74696669657220698f020159",
- func: testSelectItem,
- expect: {name: "select_item_cmd_5",
- commandQualifier: 0x00,
- title: "The SIM shall supply a set of items from which the user may choose one. Each item comprises a short identifier (used to indicate the selection) and a text string. Optionally the SIM may include an alpha identifier. The alpha identifier i",
+ items: [{identifier: 255, text: "Call Forwarding Unconditional"},
+ {identifier: 254, text: "Call Forwarding On User Busy"},
+ {identifier: 253, text: "Call Forwarding On No Reply"},
+ {identifier: 252, text: "Call Forwarding On User Not Reachable"},
+ {identifier: 251, text: "Barring Of All Outgoing Calls"},
+ {identifier: 250, text: "Barring Of All Outgoing International Calls"},
+ {identifier: 249, text: "CLI Presentation"}]}},
+ {command: "D081FD" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "8581ED5468652053494D207368616C6C20737570" + // Alpha identifier
+ "706C79206120736574206F66206974656D732066" +
+ "726F6D207768696368207468652075736572206D" +
+ "61792063686F6F7365206F6E652E204561636820" +
+ "6974656D20636F6D70726973657320612073686F" +
+ "7274206964656E74696669657220287573656420" +
+ "746F20696E646963617465207468652073656C65" +
+ "6374696F6E2920616E6420612074657874207374" +
+ "72696E672E204F7074696F6E616C6C7920746865" +
+ "2053494D206D617920696E636C75646520616E20" +
+ "616C706861206964656E7469666965722E205468" +
+ "6520616C706861206964656E7469666965722069" +
+ "8F020159", // Item
+ expect: {commandQualifier: 0x00,
+ title: "The SIM shall supply a set of items from which the user " +
+ "may choose one. Each item comprises a short identifier " +
+ "(used to indicate the selection) and a text string. " +
+ "Optionally the SIM may include an alpha identifier. " +
+ "The alpha identifier i",
items: [{identifier: 1, text: "Y"}]}},
- {command: "d081f3810301240082028182850a304c617267654d656e758f1dff312043616c6c20466f727761726420556e636f6e646974696f6e616c8f1cfe322043616c6c20466f7277617264204f6e205573657220427573798f1bfd332043616c6c20466f7277617264204f6e204e6f205265706c798f25fc342043616c6c20466f7277617264204f6e2055736572204e6f7420526561636861626c658f20fb352042617272696e67204f6620416c6c204f7574676f696e672043616c6c738f24fa362042617272696e67204f6620416c6c204f7574676f696e6720496e742043616c6c738f13f93720434c492050726573656e746174696f6e",
- func: testSelectItem,
- expect: {name: "select_item_cmd_6",
- commandQualifier: 0x00,
- title: "0LargeMenu",
- items: [{identifier: 255, text: "1 Call Forward Unconditional"}, {identifier: 254, text: "2 Call Forward On User Busy"}, {identifier: 253, text: "3 Call Forward On No Reply"}, {identifier: 252, text: "4 Call Forward On User Not Reachable"}, {identifier: 251, text: "5 Barring Of All Outgoing Calls"}, {identifier: 250, text: "6 Barring Of All Outgoing Int Calls"}, {identifier: 249, text: "7 CLI Presentation"}]}},
- {command: "d039810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20331803131026",
- func: testSelectItem,
- expect: {name: "select_item_cmd_7",
- commandQualifier: 0x00,
- title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d037810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033900102",
- func: testSelectItem,
- expect: {name: "select_item_cmd_8",
- commandQualifier: 0x00,
- title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301248082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_9",
- commandQualifier: 0x80,
+ {command: "D039" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "1803131026", // Items next action indicator
+ expect: {commandQualifier: 0x00,
title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d03e810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20339e0201019f0401050505",
- func: testSelectItem,
- expect: {name: "select_item_cmd_10",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"}],
+ nextActionList: [MozIccManager.STK_CMD_SEND_SMS,
+ MozIccManager.STK_CMD_SET_UP_CALL,
+ MozIccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
+ {command: "D03E" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "9E020101" + // Icon identifier
+ "9F0401030303", // Item icon identifier list
+ expect: {commandQualifier: 0x00,
title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d03e810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20339e0200019f0400050505",
- func: testSelectItem,
- expect: {name: "select_item_cmd_11",
- commandQualifier: 0x00,
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON],
+ items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: false, icons: [COLOR_ICON]},
+ {identifier: 2, text: "Item 2", iconSelfExplanatory: false, icons: [COLOR_ICON]},
+ {identifier: 3, text: "Item 3", iconSelfExplanatory: false, icons: [COLOR_ICON]}]}},
+ {command: "D028" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F0101" + // Item
+ "8F0102" + // Item
+ "8F0103" + // Item
+ "9F0400050505", // Item icon identifier list
+ expect: {commandQualifier: 0x00,
title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301240382028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_12",
- commandQualifier: 0x03,
+ items: [{identifier: 1, text: "", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
+ {identifier: 2, text: "", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
+ {identifier: 3, text: "", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]}]}},
+ {command: "D034" + // Length
+ "8103012483" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033", // Item
+ expect: {commandQualifier: 0x83,
title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301240182028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_13",
- commandQualifier: 0x01,
- title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d02b810301240482028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d2032",
- func: testSelectItem,
- expect: {name: "select_item_cmd_14",
- commandQualifier: 0x04,
- title: "Toolkit Select",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d030810301240082028182850a3c54494d452d4f55543e8f07014974656d20318f07024974656d20328f07034974656d2033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_15",
- commandQualifier: 0x00,
- title: "<TIME-OUT>",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_16",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
- func: testSelectItem,
- expect: {name: "select_item_cmd_17",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001001b4d108000601b4000601b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_18",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
- func: testSelectItem,
- expect: {name: "select_item_cmd_19",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001002b4d108000602b4000602b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_20",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
- func: testSelectItem,
- expect: {name: "select_item_cmd_21",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001004b4d108000604b4000604b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_22",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_23",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_24",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001008b4d108000608b4000608b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_25",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_26",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_27",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001010b4d108000610b4000610b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_28",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"}]}},
+ {command: "D03D" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "8510546F6F6C6B69742053656C6563742031" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "D004001000B4" + // Text attribute
+ "D108000600B4000600B4", // Item text attribute list
+ expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_29",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_30",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001020b4d108000620b4000620b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_31",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_32",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_33",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001040b4d108000640b4000640b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_34",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_35",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_36",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001080b4d108000680b4000680b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_37",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_38",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
- func: testSelectItem,
- expect: {name: "select_item_cmd_39",
- commandQualifier: 0x00,
- title: "Toolkit Select 3",
- items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
- {command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001000b4d108000600b4000600b4",
- func: testSelectItem,
- expect: {name: "select_item_cmd_40",
- commandQualifier: 0x00,
- title: "Toolkit Select 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
- func: testSelectItem,
- expect: {name: "select_item_cmd_41",
- commandQualifier: 0x00,
- title: "Toolkit Select 2",
- items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
- {command: "d07e8103012400820281828519800417041404200410041204210422041204230419042204158f1c018004170414042004100412042104220412042304190422041500318f1c028004170414042004100412042104220412042304190422041500328f1c03800417041404200410041204210422041204230419042204150033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_42",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"}]}},
+ {command: "D069" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "8F1C01800417041404200410041204210422041204230419042204150031" + // Item
+ "8F1102810D089794A09092A1A292A399A29532" + // Item
+ "8F1203820D041087849080829192829389928533", // Item
+ expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
- items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
- {command: "d053810301240082028182850f810c089794a09092a1a292a399a2958f1101810d089794a09092a1a292a399a295318f1102810d089794a09092a1a292a399a295328f1103810d089794a09092a1a292a399a29533",
- func: testSelectItem,
- expect: {name: "select_item_cmd_43",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ",
- items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
- {command: "d0578103012400820281828510820c04108784908082919282938992858f1201820d0410878490808291928293899285318f1202820d0410878490808291928293899285328f1203820d041087849080829192829389928533",
- func: testSelectItem,
- expect: {name: "select_item_cmd_44",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ",
- items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
- {command: "d03e810301240082028182850b805de551777bb1900962e98f080180987976ee4e008f080280987976ee4e8c8f080380987976ee4e098f080480987976ee56db",
- func: testSelectItem,
- expect: {name: "select_item_cmd_45",
- commandQualifier: 0x00,
- title: "工具箱选择",
- items: [{identifier: 1, text: "项目一"}, {identifier: 2, text: "项目二"}, {identifier: 3, text: "项目三"}, {identifier: 4, text: "项目四"}]}},
- {command: "d0388103012400820281828509800038003030eb00308f0a01800038003030eb00318f0a02800038003030eb00328f0a03800038003030eb0033",
- func: testSelectItem,
- expect: {name: "select_item_cmd_46",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"},
+ {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"},
+ {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
+ {command: "D038" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "8509800038003030EB0030" + // Alpha identifier
+ "8F0A01800038003030EB0031" + // Item
+ "8F0A02800038003030EB0032" + // Item
+ "8F0A03800038003030EB0033", // Item
+ expect: {commandQualifier: 0x00,
title: "80ル0",
- items: [{identifier: 1, text: "80ル1"}, {identifier: 2, text: "80ル2"}, {identifier: 3, text: "80ル3"}]}},
- {command: "d03081030124008202818285078104613831eb308f08018104613831eb318f08028104613831eb328f08038104613831eb33",
- func: testSelectItem,
- expect: {name: "select_item_cmd_47",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "80ル1"},
+ {identifier: 2, text: "80ル2"},
+ {identifier: 3, text: "80ル3"}]}},
+ {command: "D030" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "85078104613831EB30" + // Alpha identifier
+ "8F08018104613831EB31" + // Item
+ "8F08028104613831EB32" + // Item
+ "8F08038104613831EB33", // Item
+ expect: {commandQualifier: 0x00,
title: "81ル0",
- items: [{identifier: 1, text: "81ル1"}, {identifier: 2, text: "81ル2"}, {identifier: 3, text: "81ル3"}]}},
- {command: "d0348103012400820281828508820430a03832cb308f0901820430a03832cb318f0902820430a03832cb328f0903820430a03832cb33",
- func: testSelectItem,
- expect: {name: "select_item_cmd_48",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "81ル1"},
+ {identifier: 2, text: "81ル2"},
+ {identifier: 3, text: "81ル3"}]}},
+ {command: "D034" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "8508820430A03832CB30" + // Alpha identifier
+ "8F0901820430A03832CB31" + // Item
+ "8F0902820430A03832CB32" + // Item
+ "8F0903820430A03832CB33", // Item
+ expect: {commandQualifier: 0x00,
title: "82ル0",
- items: [{identifier: 1, text: "82ル1"}, {identifier: 2, text: "82ル2"}, {identifier: 3, text: "82ル3"}]}}
+ items: [{identifier: 1, text: "82ル1"},
+ {identifier: 2, text: "82ル2"},
+ {identifier: 3, text: "82ル3"}]}},
+ {command: "D03C" + // Length
+ "8103012400" + // Command details
+ "82028182" + // Device identities
+ "850E546F6F6C6B69742053656C656374" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "1803000081" + // Items next action indicator
+ "100102", // Item identifier
+ expect: {commandQualifier: 0x00,
+ title: "Toolkit Select",
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"}],
+ nextActionList: [MozIccManager.STK_NEXT_ACTION_NULL,
+ MozIccManager.STK_NEXT_ACTION_NULL,
+ MozIccManager.STK_NEXT_ACTION_END_PROACTIVE_SESSION],
+ defaultItem: 1}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSelectItem(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SELECT_ITEM, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ is(aCommand.options.presentationType, aCommand.commandQualifier & 0x03,
+ "presentationType");
+ is(aCommand.options.isHelpAvailable, !!(aCommand.commandQualifier & 0x80),
+ "isHelpAvailable");
+ is(aCommand.options.title, aExpect.title, "options.title");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
- }
-}
+ for (let index in aExpect.items) {
+ let item = aCommand.options.items[index];
+ let itemExpect = aExpect.items[index];
+ is(item.identifier, itemExpect.identifier,
+ "options.items[" + index + "].identifier");
+ is(item.text, itemExpect.text,
+ "options.items[" + index + "].text");
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ if (itemExpect.icons) {
+ isIcons(item.icons, itemExpect.icons);
+ is(item.iconSelfExplanatory, itemExpect.iconSelfExplanatory,
+ "options.items[" + index + "].iconSelfExplanatory");
+ }
}
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
-}
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
+ }
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
+ // nextActionList is optional.
+ if ("nextActionList" in aExpect) {
+ for (let index in aExpect.nextActionList) {
+ is(aCommand.options.nextActionList[index], aExpect.nextActionList[index],
+ "options.nextActionList[" + index + "]");
+ }
}
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
+ // defaultItem is optional.
+ if ("defaultItem" in aExpect) {
+ is(aCommand.options.defaultItem, aExpect.defaultItem, "options.defaultItem");
+ }
}
-runNextTest();
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("select_item_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSelectItem(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSelectItem(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_send_dtmf.js b/dom/icc/tests/marionette/test_stk_send_dtmf.js
index 70436fb29..2cec55142 100644
--- a/dom/icc/tests/marionette/test_stk_send_dtmf.js
+++ b/dom/icc/tests/marionette/test_stk_send_dtmf.js
@@ -1,230 +1,113 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSendDTMF(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SEND_DTMF, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (command.options.text) {
- is(command.options.text, expect.text, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d01b810301140082028183850953656e642044544d46ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_1",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D01B" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "850953656E642044544D46" + // Alpha identifier
+ "AC052143658709", // DTMF string
+ expect: {commandQualifier: 0x00,
text: "Send DTMF"}},
- {command: "d0138103011400820281838500ac06c1cccccccc2c",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_2",
- commandQualifier: 0x00,
+ {command: "D010" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "AC052143658709", // DTMF string
+ expect: {commandQualifier: 0x00}},
+ {command: "D013" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "8500" + // Alpha identifier
+ "AC06C1CCCCCCCC2C", // DTMF string
+ expect: {commandQualifier: 0x00,
text: ""}},
- {command: "d01d810301140082028183850a42617369632049636f6eac02c1f29e020001",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_3",
- commandQualifier: 0x00,
- text: "Basic Icon"}},
- {command: "d01b810301140082028183850953656e642044544d46ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_4",
- commandQualifier: 0x00,
- text: "Send DTMF"}},
- {command: "d01c810301140082028183850953656e642044544d46ac02c1f29e020101",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_5",
- commandQualifier: 0x00,
- text: "Send DTMF"}},
- {command: "d028810301140082028183851980041704140420041004120421042204120423041904220415ac02c1f2",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_6",
- commandQualifier: 0x00,
+ {command: "D01D" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "850A42617369632049636F6E" + // Alpha identifier
+ "AC02C1F2" + // DTMF string
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Basic Icon",
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON]}},
+ {command: "D011" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "AC02C1F2" + // DTMF string
+ "9E020005", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ iconSelfExplanatory: true,
+ icons: [COLOR_TRANSPARENCY_ICON]}},
+ {command: "D028" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "AC02C1F2", // DTMF string
+ expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_7",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_8",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b01b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_9",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_10",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d00400b002b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_11",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_12",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b04b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_13",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_14",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_15",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b08b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_16",
- commandQualifier: 0x00,
+ {command: "D023" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "850B53656E642044544D462031" + // Alpha identifier
+ "AC052143658709" + // DTMF string
+ "D004000B00B4", // Text attribute
+ expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_17",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_18",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b10b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_19",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_20",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_21",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b20b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_22",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_23",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_24",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b40b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_25",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_26",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_27",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b80b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_28",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_29",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_30",
- commandQualifier: 0x00,
- text: "Send DTMF 3"}},
- {command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b00b4",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_31",
- commandQualifier: 0x00,
- text: "Send DTMF 1"}},
- {command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_32",
- commandQualifier: 0x00,
- text: "Send DTMF 2"}},
- {command: "d0148103011400820281838505804f60597dac02c1f2",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_33",
- commandQualifier: 0x00,
+ {command: "D014" + // Length
+ "8103011400" + // Command details
+ "82028183" + // Device identities
+ "8505804F60597D" + // Alpha identifier
+ "AC02C1F2", // DTMF string
+ expect: {commandQualifier: 0x00,
text: "你好"}},
- {command: "d01281030114008202818385038030ebac02c1f2",
- func: testSendDTMF,
- expect: {name: "send_dtmf_cmd_34",
- commandQualifier: 0x00,
- text: "ル"}}
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
-
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+function testSendDTMF(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_DTMF, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("send_dtmf_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSendDTMF(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSendDTMF(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_send_sms.js b/dom/icc/tests/marionette/test_stk_send_sms.js
index 21c5af5a1..25f069b3d 100644
--- a/dom/icc/tests/marionette/test_stk_send_sms.js
+++ b/dom/icc/tests/marionette/test_stk_send_sms.js
@@ -1,280 +1,207 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSendSMS(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SEND_SMS, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (command.options.text) {
- is(command.options.text, expect.title, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d037810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_1",
- commandQualifier: 0x00,
- title: "Send SM"}},
- {command: "d032810301130182028183850753656e6420534d86099111223344556677f88b130100099110325476f840f40753656e6420534d",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_2",
- commandQualifier: 0x01,
- title: "Send SM"}},
- {command: "d03d810301130082028183850d53686f7274204d65737361676586099111223344556677f88b180100099110325476f840f00d53f45b4e0735cbf379f85c06",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_3",
- commandQualifier: 0x00,
- title: "Short Message"}},
- {command: "d081fd810301130182028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052501144657374696e6174696f6e114164647265737386099111223344556677f88b81ac0100099110325476f840f4a054776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e7370",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_4",
- commandQualifier: 0x01,
- title: "The address data object holds the RP_Destination_Address"}},
- {command: "d081e9810301130082028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052502044657374696e6174696f6e204164647265737386099111223344556677f88b81980100099110325476f840f0a0d4fb1b44cfc3cb7350585e0691cbe6b4bb4cd6815aa020688e7ecbe9a076793e0f9fcb20fa1b242e83e665371d447f83e8e832c85da6dfdff23528ed0685dda06973da9a5685cd2415d42ecfe7e17399057acb41613768da9cb686cf6633e82482dae5f93c7c2eb3407774595e06d1d165507d5e9683c8617a18340ebb41e232081e9ecfcb64105d1e76cfe1",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_5",
- commandQualifier: 0x00,
- title: "The address data object holds the RP Destination Address"}},
- {command: "d081fd8103011300820281838581e654776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e73706172656e746c793b202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954208b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_6",
- commandQualifier: 0x00,
- title: "Two types are defined: - A short message to be sent to the network in an SMS-SUBMIT message, or an SMS-COMMAND message, where the user data can be passed transparently; - A short message to be sent to the network in an SMS-SUBMIT "}},
- {command: "d030810301130082028183850086099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_7",
- commandQualifier: 0x00,
- title: ""}},
- {command: "d05581030113008202818385198004170414042004100412042104220412042304190422041586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_8",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ"}},
- {command: "d04b810301130082028183850f810c089794a09092a1a292a399a29586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_9",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ"}},
- {command: "d04c8103011300820281838510820c041087849080829192829389928586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_9",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ"}},
- {command: "d03b81030113008202818385074e4f2049434f4e86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167659e020001",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_10",
- commandQualifier: 0x00,
- title: "NO ICON"}},
- {command: "d03b810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167651e020101",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_11",
- commandQualifier: 0x00,
- title: "Send SM"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_12",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_13",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001001b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_14",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_15",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001002b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_16",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_17",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001004b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_18",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_19",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_20",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001008b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_21",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_22",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_23",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001010b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_24",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_25",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_26",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001020b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_27",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_28",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_29",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001040b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_30",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_31",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_32",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001080b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_33",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_34",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_35",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001000b4",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_36",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_37",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d8103011300820281838505804e2d4e0086099111223344556677f88b100100099110325476f84008044e2d4e00",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_38",
- commandQualifier: 0x00,
- title: "中一"}},
- {command: "d02d810301130082028183850581029cad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_39",
- commandQualifier: 0x00,
- title: "中一"}},
- {command: "d02e810301130082028183850682024e00ad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_40",
- commandQualifier: 0x00,
- title: "中一"}},
- {command: "d0358103011300820281838509800038003030eb003086099111223344556677f88b140100099110325476f84008080038003030eb0031",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_41",
- commandQualifier: 0x00,
- title: "80ル0"}},
- {command: "d03381030113008202818385078104613831eb3186099111223344556677f88b140100099110325476f84008080038003030eb0032",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_42",
- commandQualifier: 0x00,
- title: "81ル1"}},
- {command: "d0348103011300820281838508820430a03832cb3286099111223344556677f88b140100099110325476f84008080038003030eb0033",
- func: testSendSMS,
- expect: {name: "send_sms_cmd_43",
- commandQualifier: 0x00,
- title: "82ル2"}}
+const TEST_DATA = [
+ {command: "D02E" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F40C54657374204D657373616765", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00}},
+ {command: "D03D" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "850D53686F7274204D657373616765" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F00D53F45B4E0735CBF379F85C06", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00,
+ text: "Short Message"}},
+ {command: "D081FD" + // Length
+ "8103011301" + // Command details
+ "82028183" + // Device identities
+ "853854686520616464726573732064617461206F62" + // Alpha identifier
+ "6A65637420686F6C64732074686520525011446573" +
+ "74696E6174696F6E1141646472657373" +
+ "86099111223344556677F8" + // Address
+ "8B81AC0100099110325476F840F4A054776F20747970" + // 3GPP-SMS TPDU
+ "65732061726520646566696E65643A202D2041207368" +
+ "6F7274206D65737361676520746F2062652073656E74" +
+ "20746F20746865206E6574776F726B20696E20616E20" +
+ "534D532D5355424D4954206D6573736167652C206F72" +
+ "20616E20534D532D434F4D4D414E44206D6573736167" +
+ "652C2077686572652074686520757365722064617461" +
+ "2063616E20626520706173736564207472616E7370",
+ expect: {commandQualifier: 0x01,
+ text: "The address data object holds the RP_Destination_Address"}},
+ {command: "D081C3" + // Length
+ "8103011301" + // Command details
+ "82028183" + // Device identities
+ "86099111223344556677F8" + // Address
+ "8B81AC0100099110325476F840F4A054776F20747970" + // 3GPP-SMS TPDU
+ "65732061726520646566696E65643A202D2041207368" +
+ "6F7274206D65737361676520746F2062652073656E74" +
+ "20746F20746865206E6574776F726B20696E20616E20" +
+ "534D532D5355424D4954206D6573736167652C206F72" +
+ "20616E20534D532D434F4D4D414E44206D6573736167" +
+ "652C2077686572652074686520757365722064617461" +
+ "2063616E20626520706173736564207472616E7370",
+ expect: {commandQualifier: 0x01}},
+ {command: "D081FD" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "8581E654776F207479706573206172652064656669" + // Alpha identifier
+ "6E65643A202D20412073686F7274206D6573736167" +
+ "6520746F2062652073656E7420746F20746865206E" +
+ "6574776F726B20696E20616E20534D532D5355424D" +
+ "4954206D6573736167652C206F7220616E20534D53" +
+ "2D434F4D4D414E44206D6573736167652C20776865" +
+ "726520746865207573657220646174612063616E20" +
+ "626520706173736564207472616E73706172656E74" +
+ "6C793B202D20412073686F7274206D657373616765" +
+ "20746F2062652073656E7420746F20746865206E65" +
+ "74776F726B20696E20616E20534D532D5355424D49" +
+ "5420" +
+ "8B09010002911040F00120", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00,
+ text: "Two types are defined: - A short message to be sent to " +
+ "the network in an SMS-SUBMIT message, or an SMS-COMMAND " +
+ "message, where the user data can be passed transparently; " +
+ "- A short message to be sent to the network in an " +
+ "SMS-SUBMIT "}},
+ {command: "D030" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "8500" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F40C54657374204D657373616765", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00,
+ text: ""}},
+ {command: "D055" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B240100099110325476F8400818041704140420041004120421042204120423041904220415", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00,
+ text: "ЗДРАВСТВУЙТЕ"}},
+ {command: "D04B" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "850F810C089794A09092A1A292A399A295" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B240100099110325476F8400818041704140420041004120421042204120423041904220415", // 3GPP-SMS TPDU
+ expect: {commandQualifier: 0x00,
+ text: "ЗДРАВСТВУЙТЕ"}},
+ {command: "D03B" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "85074E4F2049434F4E" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F40C54657374204D657373616765" + // 3GPP-SMS TPDU
+ "9E020002", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ // The record number 02 in EFimg is not defined, so no icon will be
+ // shown, but the text string should still be displayed.
+ text: "NO ICON"}},
+ {command: "D032" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F40C54657374204D657373616765" + // 3GPP-SMS TPDU
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON]}},
+ {command: "D03B" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "850753656E6420534D" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B180100099110325476F840F40C54657374204D657373616765" + // 3GPP-SMS TPDU
+ "1E020101", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Send SM",
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON]}},
+ {command: "D02C" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "851054657874204174747269627574652031" + // Alpha identifier
+ "8B09010002911040F00120" + // 3GPP-SMS TPDU
+ "D004001000B4", // Text attribute
+ expect: {commandQualifier: 0x00,
+ text: "Text Attribute 1"}},
+ {command: "D035" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "8509800038003030EB0030" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B140100099110325476F84008080038003030EB0031",
+ expect: {commandQualifier: 0x00, // 3GPP-SMS TPDU
+ text: "80ル0"}},
+ {command: "D033" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "85078104613831EB31" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B140100099110325476F84008080038003030EB0032",
+ expect: {commandQualifier: 0x00, // 3GPP-SMS TPDU
+ text: "81ル1"}},
+ {command: "D034" + // Length
+ "8103011300" + // Command details
+ "82028183" + // Device identities
+ "8508820430A03832CB32" + // Alpha identifier
+ "86099111223344556677F8" + // Address
+ "8B140100099110325476F84008080038003030EB0033",
+ expect: {commandQualifier: 0x00, // 3GPP-SMS TPDU
+ text: "82ル2"}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSendSMS(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SMS, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("send_sms_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSendSMS(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSendSMS(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_send_ss.js b/dom/icc/tests/marionette/test_stk_send_ss.js
index 6e914690e..30c50cbbf 100644
--- a/dom/icc/tests/marionette/test_stk_send_ss.js
+++ b/dom/icc/tests/marionette/test_stk_send_ss.js
@@ -1,240 +1,135 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSendSS(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SEND_SS, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (command.options.text) {
- is(command.options.text, expect.title, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d029810301110082028183850c43616c6c20466f7277617264891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_1",
- commandQualifier: 0x00,
- title: "Call Forward"}},
- {command: "d02d810301110082028183850c43616c6c20466f7277617264891491aa120a21436587092143658709214365a711fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_2",
- commandQualifier: 0x00,
- title: "Call Forward"}},
- {command: "d081fd8103011100820281838581eb4576656e20696620746865204669786564204469616c6c696e67204e756d626572207365727669636520697320656e61626c65642c2074686520737570706c656d656e74617279207365727669636520636f6e74726f6c20737472696e6720696e636c7564656420696e207468652053454e442053532070726f61637469766520636f6d6d616e64207368616c6c206e6f7420626520636865636b656420616761696e73742074686f7365206f66207468652046444e206c6973742e2055706f6e20726563656976696e67207468697320636f6d6d616e642c20746865204d45207368616c6c20646563698904ffba13fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_3",
- commandQualifier: 0x00,
- title: "Even if the Fixed Dialling Number service is enabled, the supplementary service control string included in the SEND SS proactive command shall not be checked against those of the FDN list. Upon receiving this command, the ME shall deci"}},
- {command: "d01d8103011100820281838500891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_4",
- commandQualifier: 0x00,
- title: ""}},
- {command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020001",
- func: testSendSS,
- expect: {name: "send_ss_cmd_5",
- commandQualifier: 0x00,
- title: "Basic Icon"}},
- {command: "d02c810301110082028183850b436f6c6f75722049636f6e891091aa120a214365870921436587a901fb9e020002",
- func: testSendSS,
- expect: {name: "send_ss_cmd_6",
- commandQualifier: 0x00,
- title: "Colour Icon"}},
- {command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020101",
- func: testSendSS,
- expect: {name: "send_ss_cmd_7",
- commandQualifier: 0x00,
- title: "Basic Icon"}},
- {command: "d036810301110082028183851980041704140420041004120421042204120423041904220415891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_8",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_9",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_10",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001001b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_11",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_12",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001002b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_13",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_14",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001004b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_15",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_16",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_17",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001008b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_18",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_19",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_20",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001010b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_21",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_22",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_23",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001020b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_24",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_25",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_26",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001040b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_27",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_28",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_29",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001080b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_30",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_31",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_32",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001000b4",
- func: testSendSS,
- expect: {name: "send_ss_cmd_33",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_34",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0228103011100820281838505804f60597d891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_35",
- commandQualifier: 0x00,
- title: "你好"}},
- {command: "d02081030111008202818385038030eb891091aa120a214365870921436587a901fb",
- func: testSendSS,
- expect: {name: "send_ss_cmd_36",
- commandQualifier: 0x00,
- title: "ル"}}
+const TEST_DATA = [
+ {command: "D029" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "850C43616C6C20466F7277617264" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB", // SS string
+ expect: {commandQualifier: 0x00,
+ text: "Call Forward"}},
+ {command: "D01B" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "891091AA120A214365870921436587A901FB", // SS string
+ expect: {commandQualifier: 0x00}},
+ {command: "D081FD" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "8581EB4576656E2069662074686520466978656420" + // Alpha identifier
+ "4469616C6C696E67204E756D626572207365727669" +
+ "636520697320656E61626C65642C20746865207375" +
+ "70706C656D656E7461727920736572766963652063" +
+ "6F6E74726F6C20737472696E6720696E636C756465" +
+ "6420696E207468652053454E442053532070726F61" +
+ "637469766520636F6D6D616E64207368616C6C206E" +
+ "6F7420626520636865636B656420616761696E7374" +
+ "2074686F7365206F66207468652046444E206C6973" +
+ "742E2055706F6E20726563656976696E6720746869" +
+ "7320636F6D6D616E642C20746865204D4520736861" +
+ "6C6C2064656369" +
+ "8904FFBA13FB", // SS string
+ expect: {commandQualifier: 0x00,
+ text: "Even if the Fixed Dialling Number service is enabled, " +
+ "the supplementary service control string included in the " +
+ "SEND SS proactive command shall not be checked against " +
+ "those of the FDN list. Upon receiving this command, the " +
+ "ME shall deci"}},
+ {command: "D01D" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "8500" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB", // SS string
+ expect: {commandQualifier: 0x00,
+ text: ""}},
+ {command: "D02B" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "850A42617369632049636F6E" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB" + // SS string
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Basic Icon",
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON]}},
+ {command: "D01F" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "891091AA120A214365870921436587A901FB" + // SS string
+ "9E020103", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ iconSelfExplanatory: false,
+ icons: [COLOR_ICON]}},
+ {command: "D036" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB", // SS string
+ expect: {commandQualifier: 0x00,
+ text: "ЗДРАВСТВУЙТЕ"}},
+ {command: "D033" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "851054657874204174747269627574652031" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB" + // SS string
+ "D004001000B4", // Text attribute
+ expect: {commandQualifier: 0x00,
+ text: "Text Attribute 1"}},
+ {command: "D022" + // Length
+ "8103011100" + // Command details
+ "82028183" + // Device identities
+ "8505804F60597D" + // Alpha identifier
+ "891091AA120A214365870921436587A901FB", // SS string
+ expect: {commandQualifier: 0x00,
+ text: "你好"}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSendSS(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SS, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("send_ss_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSendSS(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSendSS(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_send_ussd.js b/dom/icc/tests/marionette/test_stk_send_ussd.js
index 45ecc4c2a..a6934f137 100644
--- a/dom/icc/tests/marionette/test_stk_send_ussd.js
+++ b/dom/icc/tests/marionette/test_stk_send_ussd.js
@@ -1,245 +1,173 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSendUSSD(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SEND_USSD, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (command.options.text) {
- is(command.options.text, expect.title, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d050810301120082028183850a372d62697420555353448a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_1",
- commandQualifier: 0x00,
- title: "7-bit USSD"}},
- {command: "d058810301120082028183850a382d62697420555353448a41444142434445464748494a4b4c4d4e4f505152535455565758595a2d6162636465666768696a6b6c6d6e6f707172737475767778797a2d31323334353637383930",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_2",
- commandQualifier: 0x00,
- title: "8-bit USSD"}},
- {command: "d02f81030112008202818385095543533220555353448a1948041704140420041004120421042204120423041904220415",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_3",
- commandQualifier: 0x00,
- title: "UCS2 USSD"}},
- {command: "d081fd8103011200820281838581b66f6e636520612052454c4541534520434f4d504c455445206d65737361676520636f6e7461696e696e672074686520555353442052657475726e20526573756c74206d657373616765206e6f7420636f6e7461696e696e6720616e206572726f7220686173206265656e2072656365697665642066726f6d20746865206e6574776f726b2c20746865204d45207368616c6c20696e666f726d207468652053494d20746861742074686520636f6d6d616e64206861738a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_4",
- commandQualifier: 0x00,
- title: "once a RELEASE COMPLETE message containing the USSD Return Result message not containing an error has been received from the network, the ME shall inform the SIM that the command has"}},
- {command: "d04681030112008202818385008a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_5",
- commandQualifier: 0x00,
- title: ""}},
- {command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020001",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_6",
- commandQualifier: 0x00,
- title: "Basic Icon"}},
- {command: "d054810301120082028183850a436f6c6f722049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020002",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_7",
- commandQualifier: 0x00,
- title: "Color Icon"}},
- {command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_8",
- commandQualifier: 0x00,
- title: "Basic Icon"}},
- {command: "d05f8103011200820281838519800417041404200410041204210422041204230419042204158a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_9",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_10",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_11",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_12",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_13",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_14",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_15",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_16",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_17",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_18",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_19",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_20",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_21",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001010b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_22",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_23",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_24",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001020b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_25",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_26",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_27",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001040b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_28",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_29",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_30",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001080b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_31",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_32",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_33",
- commandQualifier: 0x00,
- title: "Text Attribute 3"}},
- {command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_34",
- commandQualifier: 0x00,
- title: "Text Attribute 1"}},
- {command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_35",
- commandQualifier: 0x00,
- title: "Text Attribute 2"}},
- {command: "d04b8103011200820281838505804f60597d8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_36",
- commandQualifier: 0x00,
- title: "你好"}},
- {command: "d04981030112008202818385038030eb8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
- func: testSendUSSD,
- expect: {name: "send_ussd_cmd_37",
- commandQualifier: 0x00,
- title: "ル"}}
+const TEST_DATA = [
+ {command: "D050" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "850A372D6269742055535344" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00,
+ text: "7-bit USSD"}},
+ {command: "D044" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00}},
+ {command: "D058" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "850A382D6269742055535344" + // Alpha identifier
+ "8A41444142434445464748494A4B4C4D4E4F5051525354" + // USSD string
+ "55565758595A2D6162636465666768696A6B6C6D6E6F70" +
+ "7172737475767778797A2D31323334353637383930",
+ expect: {commandQualifier: 0x00,
+ text: "8-bit USSD"}},
+ {command: "D02F" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8509554353322055535344" + // Alpha identifier
+ "8A1948041704140420041004120421042204120423041904220415", // USSD string
+ expect: {commandQualifier: 0x00,
+ text: "UCS2 USSD"}},
+ {command: "D081FD" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8581B66F6E636520612052454C4541534520434F4D" + // Alpha identifier
+ "504C455445206D65737361676520636F6E7461696E" +
+ "696E672074686520555353442052657475726E2052" +
+ "6573756C74206D657373616765206E6F7420636F6E" +
+ "7461696E696E6720616E206572726F722068617320" +
+ "6265656E2072656365697665642066726F6D207468" +
+ "65206E6574776F726B2C20746865204D4520736861" +
+ "6C6C20696E666F726D207468652053494D20746861" +
+ "742074686520636F6D6D616E6420686173" +
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00,
+ text: "once a RELEASE COMPLETE message containing the USSD " +
+ "Return Result message not containing an error has been " +
+ "received from the network, the ME shall inform the SIM " +
+ "that the command has"}},
+ {command: "D046" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8500" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00,
+ text: ""}},
+ {command: "D054" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "850A42617369632049636F6E" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560" +
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Basic Icon",
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON]}},
+ {command: "D048" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560" +
+ "9E020103", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ iconSelfExplanatory: false,
+ icons: [COLOR_ICON]}},
+ {command: "D05F" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00,
+ text: "ЗДРАВСТВУЙТЕ"}},
+ {command: "D05C" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "851054657874204174747269627574652031" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560" +
+ "D004001000B4", // Text attribute
+ expect: {commandQualifier: 0x00,
+ text: "Text Attribute 1"}},
+ {command: "D04A" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560" +
+ "D004001000B4", // Text attribute
+ expect: {commandQualifier: 0x00}},
+ {command: "D04B" + // Length
+ "8103011200" + // Command details
+ "82028183" + // Device identities
+ "8505804F60597D" + // Alpha identifier
+ "8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
+ "B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
+ "3B3EAF6FC564335ACD76C3E560",
+ expect: {commandQualifier: 0x00,
+ text: "你好"}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSendUSSD(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_USSD, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // text is optional.
+ if ("text" in aExpect) {
+ is(aCommand.options.text, aExpect.text, "options.text");
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
-
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("send_ussd_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSendUSSD(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSendUSSD(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_setup_call.js b/dom/icc/tests/marionette/test_stk_setup_call.js
index 5b90aedff..f43a5426c 100644
--- a/dom/icc/tests/marionette/test_stk_setup_call.js
+++ b/dom/icc/tests/marionette/test_stk_setup_call.js
@@ -1,284 +1,236 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSetupCall(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SET_UP_CALL, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- if (command.options.confirmMessage) {
- is(command.options.confirmMessage, expect.text, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d01e81030110008202818385084e6f7420627573798609911032042143651c2c",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_1",
- commandQualifier: 0x00,
- text: "Not busy"}},
- {command: "d01d81030110028202818385074f6e20686f6c648609911032042143651c2c",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_2",
- commandQualifier: 0x02,
- text: "On hold"}},
- {command: "d020810301100482028183850a446973636f6e6e6563748609911032042143651c2c",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_3",
- commandQualifier: 0x04,
- text: "Disconnect"}},
- {command: "d02b81030110008202818385114361706162696c69747920636f6e6669678609911032042143651c2c870201a0",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_4",
- commandQualifier: 0x00,
- text: "Capability config"}},
- {command: "d01c81030110018202818386119110325476981032547698103254769810",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_5",
- commandQualifier: 0x01}},
- {command: "d081fd8103011001820281838581ed54687265652074797065732061726520646566696e65643a202d2073657420757020612063616c6c2c20627574206f6e6c79206966206e6f742063757272656e746c792062757379206f6e20616e6f746865722063616c6c3b202d2073657420757020612063616c6c2c2070757474696e6720616c6c206f746865722063616c6c732028696620616e7929206f6e20686f6c643b202d2073657420757020612063616c6c2c20646973636f6e6e656374696e6720616c6c206f746865722063616c6c732028696620616e79292066697273742e20466f722065616368206f662074686573652074797065732c2086029110",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_6",
- commandQualifier: 0x01,
- text: "Three types are defined: - set up a call, but only if not currently busy on another call; - set up a call, putting all other calls (if any) on hold; - set up a call, disconnecting all other calls (if any) first. For each of these types, "}},
- {command: "d02b810301100082028183850c43616c6c65642070617274798609911032042143651c2c880780509595959595",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_7",
- commandQualifier: 0x00,
- text: "Called party"}},
- {command: "d02281030110018202818385084475726174696f6e8609911032042143651c2c8402010a",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_8",
- commandQualifier: 0x01,
- text: "Duration"}},
- {command: "d028810301100082028183850c434f4e4649524d4154494f4e8609911032042143651c2c850443414c4c",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_9",
- commandQualifier: 0x00,
- text: "CONFIRMATION"}},
- {command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e312e318609911032042143651c2c9e020101",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_10",
- commandQualifier: 0x00,
- text: "Set up call Icon 3.1.1"}},
- {command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e322e318609911032042143651c2c9e020001",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_11",
- commandQualifier: 0x00,
- text: "Set up call Icon 3.2.1"}},
- {command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e332e318609911032042143651c2c9e020102",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_12",
- commandQualifier: 0x00,
- text: "Set up call Icon 3.3.1"}},
- {command: "d04c81030110008202818385165365742075702063616c6c2049636f6e20332e342e318609911032042143651c2c9e02000185165365742075702063616c6c2049636f6e20332e342e329e020001",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_13",
- commandQualifier: 0x00,
- text: "Set up call Icon 3.4.1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_14",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_15",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e01b4d004000601b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_16",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_17",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e02b4d004000602b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_18",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_19",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e04b4d004000604b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_20",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_21",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_22",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e08b4d004000608b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_23",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_24",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_25",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e10b4d004000610b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_26",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_27",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_28",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e20b4d004000620b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_29",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_30",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_31",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e40b4d004000640b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_32",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_33",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_34",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e80b4d004000680b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_35",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_36",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_37",
- commandQualifier: 0x00,
- text: "CONFIRMATION 3"}},
- {command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e00b4d0040006004b",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_38",
- commandQualifier: 0x00,
- text: "CONFIRMATION 1"}},
- {command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_39",
- commandQualifier: 0x00,
- text: "CONFIRMATION 2"}},
- {command: "d02d810301100082028183851980041704140420041004120421042204120423041904220415860791103204214365",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_40",
- commandQualifier: 0x00,
- text: "ЗДРАВСТВУЙТЕ"}},
- {command: "d04c810301100082028183851b800417041404200410041204210422041204230419042204150031860791103204214365851b800417041404200410041204210422041204230419042204150032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_41",
- commandQualifier: 0x00,
- text: "ЗДРАВСТВУЙТЕ1"}},
- {command: "d0198103011000820281838505804e0d5fd9860791103204214365",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_42",
- commandQualifier: 0x00,
- text: "不忙"}},
- {command: "d022810301100082028183850580786e5b9a860791103204214365850780625375358bdd",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_43",
- commandQualifier: 0x00,
- text: "确定"}},
- {command: "d01781030110008202818385038030eb860791103204214365",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_44",
- commandQualifier: 0x00,
- text: "ル"}},
- {command: "d02081030110008202818385058030eb003186079110320421436585058030eb0032",
- func: testSetupCall,
- expect: {name: "setup_call_cmd_45",
- commandQualifier: 0x00,
- text: "ル1"}},
+const TEST_DATA = [
+ {command: "D01E" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "85084E6F742062757379" + // Alpha identifier
+ "8609911032042143651C2C", // Address
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "Not busy" },
+ address: "+012340123456,1,2"}},
+ {command: "D01D" + // Length
+ "8103011002" + // Command details
+ "82028183" + // Device identities
+ "85074F6E20686F6C64" + // Alpha identifier
+ "8609911032042143651C2C", // Address
+ expect: {commandQualifier: 0x02,
+ confirmMessage: { text: "On hold" },
+ address: "+012340123456,1,2"}},
+ {command: "D020" + // Length
+ "8103011004" + // Command details
+ "82028183" + // Device identities
+ "850A446973636F6E6E656374" + // Alpha identifier
+ "8609911032042143651C2C", // Address
+ expect: {commandQualifier: 0x04,
+ confirmMessage: { text: "Disconnect" },
+ address: "+012340123456,1,2"}},
+ {command: "D02B" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "85114361706162696C69747920636F6E666967" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "870201A0", // Capability configuration parameters
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "Capability config" },
+ address: "+012340123456,1,2"}},
+ {command: "D01C" + // Length
+ "8103011001" + // Command details
+ "82028183" + // Device identities
+ "86119110325476981032547698103254769810", // Address
+ expect: {commandQualifier: 0x01,
+ address: "+01234567890123456789012345678901"}},
+ {command: "D081FD" + // Length
+ "8103011001" + // Command details
+ "82028183" + // Device identities
+ "8581ED546872656520747970657320617265206465" + // Alpha identifier
+ "66696E65643A202D2073657420757020612063616C" +
+ "6C2C20627574206F6E6C79206966206E6F74206375" +
+ "7272656E746C792062757379206F6E20616E6F7468" +
+ "65722063616C6C3B202D2073657420757020612063" +
+ "616C6C2C2070757474696E6720616C6C206F746865" +
+ "722063616C6C732028696620616E7929206F6E2068" +
+ "6F6C643B202D2073657420757020612063616C6C2C" +
+ "20646973636F6E6E656374696E6720616C6C206F74" +
+ "6865722063616C6C732028696620616E7929206669" +
+ "7273742E20466F722065616368206F662074686573" +
+ "652074797065732C20" +
+ "86029110", // Address
+ expect: {commandQualifier: 0x01,
+ confirmMessage: {
+ text: "Three types are defined: - set up a call, but only if " +
+ "not currently busy on another call; - set up a call, " +
+ "putting all other calls (if any) on hold; - set up a " +
+ "call, disconnecting all other calls (if any) first. For " +
+ "each of these types, "
+ },
+ address: "+01"}},
+ {command: "D022" + // Length
+ "8103011001" + // Command details
+ "82028183" + // Device identities
+ "85084475726174696F6E" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "8402010A", // Duration
+ expect: {commandQualifier: 0x01,
+ confirmMessage: { text: "Duration" },
+ address: "+012340123456,1,2",
+ duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
+ timeInterval: 0x0A}}},
+ {command: "D028" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "850C434F4E4649524D4154494F4E" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "850443414C4C", // Alpha identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "CONFIRMATION" },
+ callMessage: { text: "CALL" },
+ address: "+012340123456,1,2"}},
+ {command: "D030" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "85165365742075702063616C6C2049636F6E20332E312E31" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "9E020101", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "Set up call Icon 3.1.1",
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON] },
+ address: "+012340123456,1,2"}},
+ {command: "D04C" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "85165365742075702063616C6C2049636F6E20332E342E31" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "9E020001" + // Icon identifier
+ "85165365742075702063616C6C2049636F6E20332E342E32" + // Alpha identifier
+ "9E020003", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "Set up call Icon 3.4.1",
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON] },
+ callMessage: { text: "Set up call Icon 3.4.2" ,
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON] },
+ address: "+012340123456,1,2"}},
+ {command: "D038" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "850E434F4E4649524D4154494F4E2031" + // Alpha identifier
+ "8609911032042143651C2C" + // Address
+ "850643414C4C2031" + // Alpha identifier
+ "D004000E00B4" + // Text attribute
+ "D004000600B4", // Text attribute
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "CONFIRMATION 1" },
+ callMessage: { text: "CALL 1" },
+ address: "+012340123456,1,2"}},
+ {command: "D04C" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "851B800417041404200410041204210422041204230419042204150031" + // Alpha identifier
+ "860791103204214365" + // Address
+ "851B800417041404200410041204210422041204230419042204150032", // Alpha identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "ЗДРАВСТВУЙТЕ1" },
+ callMessage: { text: "ЗДРАВСТВУЙТЕ2" },
+ address: "+012340123456"}},
+ {command: "D019" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "8505804E0D5FD9" + // Alpha identifier
+ "860791103204214365", // Address
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "不忙" },
+ address: "+012340123456"}},
+ {command: "D022" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "850580786E5B9A" + // Alpha identifier
+ "860791103204214365" + // Address
+ "850780625375358BDD", // Alpha identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "确定" },
+ callMessage: { text: "打电话" },
+ address: "+012340123456"}},
+ {command: "D016" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "8500" + // Alpha identifier
+ "860791103204214365" + // Address
+ "8500", // Alpha identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { text: "" },
+ callMessage: { text: "" },
+ address: "+012340123456"}},
+ {command: "D01C" + // Length
+ "8103011000" + // Command details
+ "82028183" + // Device identities
+ "8609911032042143651C2C" + // Address
+ "9E020001" + // Icon identifier
+ "9E020103", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ confirmMessage: { iconSelfExplanatory: true,
+ icons: [BASIC_ICON] },
+ callMessage: { iconSelfExplanatory: false,
+ icons: [COLOR_ICON] },
+ address: "+012340123456,1,2"}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSetupCall(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_CALL,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+ is(aCommand.options.address, aExpect.address, "options.address");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // confirmMessage is optional.
+ if ("confirmMessage" in aExpect) {
+ isStkText(aCommand.options.confirmMessage, aExpect.confirmMessage);
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // callMessage is optional.
+ if ("callMessage" in aExpect) {
+ isStkText(aCommand.options.callMessage, aExpect.callMessage);
}
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
+ // duration is optional.
+ if ("duration" in aExpect) {
+ let duration = aCommand.options.duration;
+ is(duration.timeUnit, aExpect.duration.timeUnit, "duration.timeUnit");
+ is(duration.timeInterval, aExpect.duration.timeInterval,
+ "duration.timeInterval");
+ }
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("setup_call_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSetupCall(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSetupCall(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_setup_event_list.js b/dom/icc/tests/marionette/test_stk_setup_event_list.js
index 76cdaed80..f3b6e83cb 100644
--- a/dom/icc/tests/marionette/test_stk_setup_event_list.js
+++ b/dom/icc/tests/marionette/test_stk_setup_event_list.js
@@ -1,90 +1,84 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSetupEventList(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SET_UP_EVENT_LIST, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- for (let index in command.options.eventList) {
- is(command.options.eventList[index], expect.eventList[index], expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d00c810301050082028182990104",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_1",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D00C" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "990104", // Event list
+ expect: {commandQualifier: 0x00,
eventList: [4]}},
- {command: "d00d81030105008202818299020507",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_2",
- commandQualifier: 0x00,
+ {command: "D00D" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "99020507", // Event list
+ expect: {commandQualifier: 0x00,
eventList: [5, 7]}},
- {command: "d00c810301050082028182990107",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_3",
- commandQualifier: 0x00,
+ {command: "D00C" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "990107", // Event list
+ expect: {commandQualifier: 0x00,
eventList: [7]}},
- {command: "d00c810301050082028182990107",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_4",
- commandQualifier: 0x00,
+ {command: "D00C" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "990107", // Event list
+ expect: {commandQualifier: 0x00,
eventList: [7]}},
- {command: "d00b8103010500820281829900",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_5",
- commandQualifier: 0x00,
+ {command: "D00B" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "9900", // Event list
+ expect: {commandQualifier: 0x00,
eventList: null}},
- {command: "d00c810301050082028182990107",
- func: testSetupEventList,
- expect: {name: "setup_event_list_cmd_6",
- commandQualifier: 0x00,
+ {command: "D00C" + // Length
+ "8103010500" + // Command details
+ "82028182" + // Device identities
+ "990107", // Event list
+ expect: {commandQualifier: 0x00,
eventList: [7]}}
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSetupEventList(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_EVENT_LIST,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
-
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ for (let index in aExpect.eventList) {
+ is(aCommand.options.eventList[index], aExpect.eventList[index],
+ "options.eventList[" + index + "]");
}
}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("setup_event_list_cmd: " + data.command);
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSetupEventList(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSetupEventList(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
+ return Promise.all(promises);
+ });
}
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js b/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js
index eb90f404a..51a4940e9 100644
--- a/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js
+++ b/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js
@@ -1,233 +1,115 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSetupIdleModeText(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SET_UP_IDLE_MODE_TEXT, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.text, expect.text, expect.name);
-
- runNextTest();
-}
-
-let tests = [
- {command: "d01a8103012800820281828d0f0449646c65204d6f64652054657874",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_1",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D01A" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D0F0449646C65204D6F64652054657874", // Text string
+ expect: {commandQualifier: 0x00,
text: "Idle Mode Text"}},
- {command: "d0188103012800820281828d0d04546f6f6c6b69742054657374",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_2",
- commandQualifier: 0x00,
- text: "Toolkit Test"}},
- {command: "d081fd8103012800820281828d81f100547419344d3641737498cd06cdeb70383b0f0a83e8653c1d34a7cbd3ee330b7447a7c768d01c1d66b341e232889c9ec3d9e17c990c12e741747419d42c82c27350d80d4a93d96550fb4d2e83e8653c1d943683e8e832a85904a5e7a0b0985d06d1df20f21b94a6bba8e832082e2fcfcb6e7a989e7ebb41737a9e5d06a5e72076d94c0785e7a0b01b946ec3d9e576d94d0fd3d36f37885c1ea7e7e9b71b447f83e8e832a85904b5c3eeba393ca6d7e565b90b444597416932bb0c6abfc96510bd8ca783e6e8309b0d129741e4f41cce0ee7cb6450da0d0a83da61b7bb2c07d1d1613aa8ec9ed7e5e539888e0ed341ee32",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_3",
- commandQualifier: 0x00,
- text: "The SIM shall supply a text string, which shall be displayed by the ME as an idle mode text if the ME is able to do it.The presentation style is left as an implementation decision to the ME manufacturer. The idle mode text shall be displayed in a manner that ensures that ne"}},
- {command: "d0198103012800820281828d0a0449646c6520746578749e020001",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_4",
- commandQualifier: 0x00,
- text: "Idle text"}},
- {command: "d0198103012800820281828d0a0449646c6520746578749e020101",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_5",
- commandQualifier: 0x00,
- text: "Idle text"}},
- {command: "d0198103012800820281828d0a0449646c6520746578749e020002",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_6",
- commandQualifier: 0x00,
- text: "Idle text"}},
- {command: "d0248103012800820281828d1908041704140420041004120421042204120423041904220415",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_7",
- commandQualifier: 0x00,
+ {command: "D081FD" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D81F100547419344D3641737498CD06CDEB70383B0F0A" + // Text string
+ "83E8653C1D34A7CBD3EE330B7447A7C768D01C1D66B341" +
+ "E232889C9EC3D9E17C990C12E741747419D42C82C27350" +
+ "D80D4A93D96550FB4D2E83E8653C1D943683E8E832A859" +
+ "04A5E7A0B0985D06D1DF20F21B94A6BBA8E832082E2FCF" +
+ "CB6E7A989E7EBB41737A9E5D06A5E72076D94C0785E7A0" +
+ "B01B946EC3D9E576D94D0FD3D36F37885C1EA7E7E9B71B" +
+ "447F83E8E832A85904B5C3EEBA393CA6D7E565B90B4445" +
+ "97416932BB0C6ABFC96510BD8CA783E6E8309B0D129741" +
+ "E4F41CCE0EE7CB6450DA0D0A83DA61B7BB2C07D1D1613A" +
+ "A8EC9ED7E5E539888E0ED341EE32",
+ expect: {commandQualifier: 0x00,
+ text: "The SIM shall supply a text string, which shall be " +
+ "displayed by the ME as an idle mode text if the ME is " +
+ "able to do it.The presentation style is left as an " +
+ "implementation decision to the ME manufacturer. The idle " +
+ "mode text shall be displayed in a manner that ensures " +
+ "that ne"}},
+ {command: "D019" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D0A0449646C652074657874" + // Text string
+ "9E020101", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Idle text",
+ iconSelfExplanatory: false,
+ icons: [BASIC_ICON]}},
+ {command: "D019" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D0A0449646C652074657874" + // Text string
+ "9E020007", // Icon identifier
+ expect: {commandQualifier: 0x00,
+ text: "Idle text",
+ iconSelfExplanatory: true,
+ icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
+ {command: "D024" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D1908041704140420041004120421042204120423041904220415", // Text string
+ expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_8",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_9",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001001b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_10",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_11",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001002b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_12",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_13",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001004b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_14",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_15",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_16",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001008b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_17",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_18",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_19",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001010b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_20",
- commandQualifier: 0x00,
+ {command: "D022" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D110449646C65204D6F646520546578742031" + // Text string
+ "D004001000B4", // Text attribute
+ expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_21",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_22",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001020b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_23",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_24",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_25",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001040b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_26",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_27",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_28",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001080b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_29",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_30",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_31",
- commandQualifier: 0x00,
- text: "Idle Mode Text 3"}},
- {command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001000b4",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_32",
- commandQualifier: 0x00,
- text: "Idle Mode Text 1"}},
- {command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_33",
- commandQualifier: 0x00,
- text: "Idle Mode Text 2"}},
- {command: "d0108103012800820281828d05084f60597d",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_34",
- commandQualifier: 0x00,
+ {command: "D010" + // Length
+ "8103012800" + // Command details
+ "82028182" + // Device identities
+ "8D05084F60597D", // Text string
+ expect: {commandQualifier: 0x00,
text: "你好"}},
- {command: "d0148103012800820281828d09080038003030eb0030",
- func: testSetupIdleModeText,
- expect: {name: "setup_idle_mode_text_cmd_35",
- commandQualifier: 0x00,
- text: "80ル0"}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
-
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+function testSetupIdleModeText(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_IDLE_MODE_TEXT,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+ is(aCommand.options.text, aExpect.text, "options.text");
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("setup_idle_mode_text_cmd: " + data.command);
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSetupIdleModeText(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSetupIdleModeText(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
+ return Promise.all(promises);
+ });
}
-
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
-
-runNextTest();
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_setup_menu.js b/dom/icc/tests/marionette/test_stk_setup_menu.js
index ab59a96b0..cb5dd9b6a 100644
--- a/dom/icc/tests/marionette/test_stk_setup_menu.js
+++ b/dom/icc/tests/marionette/test_stk_setup_menu.js
@@ -1,248 +1,312 @@
/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-MARIONETTE_TIMEOUT = 30000;
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
-SpecialPowers.addPermission("mobileconnection", true, document);
-
-let icc = navigator.mozIccManager;
-ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
-
-function testSetupMenu(command, expect) {
- log("STK CMD " + JSON.stringify(command));
- is(command.typeOfCommand, icc.STK_CMD_SET_UP_MENU, expect.name);
- is(command.commandQualifier, expect.commandQualifier, expect.name);
- is(command.options.title, expect.title, expect.name);
- for (let index in command.options.items) {
- is(command.options.items[index].identifier, expect.items[index].identifier, expect.name);
- is(command.options.items[index].text, expect.items[index].text, expect.name);
- }
-
- runNextTest();
-}
-
-let tests = [
- {command: "d03b810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_1",
- commandQualifier: 0x00,
- title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
- {command: "d023810301250082028182850c546f6f6c6b6974204d656e758f04114f6e658f041254776f",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_2",
- commandQualifier: 0x00,
- title: "Toolkit Menu",
- items: [{identifier: 17, text: "One"}, {identifier: 18, text: "Two"}]}},
- {command: "d081fc810301250082028182850a4c617267654d656e75318f05505a65726f8f044f4f6e658f044e54776f8f064d54687265658f054c466f75728f054b466976658f044a5369788f0649536576656e8f064845696768748f05474e696e658f0646416c7068618f0645427261766f8f0844436861726c69658f064344656c74618f05424563686f8f0941466f782d74726f748f0640426c61636b8f063f42726f776e8f043e5265648f073d4f72616e67658f073c59656c6c6f778f063b477265656e8f053a426c75658f073956696f6c65748f0538477265798f063757686974658f06366d696c6c698f06356d6963726f8f05346e616e6f8f05337069636f",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_3",
- commandQualifier: 0x00,
+const TEST_DATA = [
+ {command: "D081FC" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850A4C617267654D656E7531" + // Alpha identifier
+ "8F05505A65726F" + // Item
+ "8F044F4F6E65" + // Item
+ "8F044E54776F" + // Item
+ "8F064D5468726565" + // Item
+ "8F054C466F7572" + // Item
+ "8F054B46697665" + // Item
+ "8F044A536978" + // Item
+ "8F0649536576656E" + // Item
+ "8F06484569676874" + // Item
+ "8F05474E696E65" + // Item
+ "8F0646416C706861" + // Item
+ "8F0645427261766F" + // Item
+ "8F0844436861726C6965" + // Item
+ "8F064344656C7461" + // Item
+ "8F05424563686F" + // Item
+ "8F0941466F782D74726F74" + // Item
+ "8F0640426C61636B" + // Item
+ "8F063F42726F776E" + // Item
+ "8F043E526564" + // Item
+ "8F073D4F72616E6765" + // Item
+ "8F073C59656C6C6F77" + // Item
+ "8F063B477265656E" + // Item
+ "8F053A426C7565" + // Item
+ "8F073956696F6C6574" + // Item
+ "8F053847726579" + // Item
+ "8F06375768697465" + // Item
+ "8F06366D696C6C69" + // Item
+ "8F06356D6963726F" + // Item
+ "8F05346E616E6F" + // Item
+ "8F05337069636F", // Item
+ expect: {commandQualifier: 0x00,
title: "LargeMenu1",
- items: [{identifier: 80, text: "Zero"}, {identifier: 79, text: "One"}, {identifier: 78, text: "Two"}, {identifier: 77, text: "Three"}, {identifier: 76, text: "Four"}, {identifier: 75, text: "Five"}, {identifier: 74, text: "Six"}, {identifier: 73, text: "Seven"}, {identifier: 72, text: "Eight"}, {identifier: 71, text: "Nine"}, {identifier: 70, text: "Alpha"}, {identifier: 69, text: "Bravo"}, {identifier: 68, text: "Charlie"}, {identifier: 67, text: "Delta"}, {identifier: 66, text: "Echo"}, {identifier: 65, text: "Fox-trot"}, {identifier: 64, text: "Black"}, {identifier: 63, text: "Brown"}, {identifier: 62, text: "Red"}, {identifier: 61, text: "Orange"}, {identifier: 60, text: "Yellow"}, {identifier: 59, text: "Green"}, {identifier: 58, text: "Blue"}, {identifier: 57, text: "Violet"}, {identifier: 56, text: "Grey"}, {identifier: 55, text: "White"}, {identifier: 54, text: "milli"}, {identifier: 53, text: "micro"}, {identifier: 52, text: "nano"}, {identifier: 51, text: "pico"}]}},
- {command: "d081f3810301250082028182850a4c617267654d656e75328f1dff312043616c6c20466f727761726420556e636f6e646974696f6e616c8f1cfe322043616c6c20466f7277617264204f6e205573657220427573798f1bfd332043616c6c20466f7277617264204f6e204e6f205265706c798f25fc342043616c6c20466f7277617264204f6e2055736572204e6f7420526561636861626c658f20fb352042617272696e67204f6620416c6c204f7574676f696e672043616c6c738f24fa362042617272696e67204f6620416c6c204f7574676f696e6720496e742043616c6c738f13f93720434c492050726573656e746174696f6e",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_4",
- commandQualifier: 0x00,
+ items: [{identifier: 80, text: "Zero"},
+ {identifier: 79, text: "One"},
+ {identifier: 78, text: "Two"},
+ {identifier: 77, text: "Three"},
+ {identifier: 76, text: "Four"},
+ {identifier: 75, text: "Five"},
+ {identifier: 74, text: "Six"},
+ {identifier: 73, text: "Seven"},
+ {identifier: 72, text: "Eight"},
+ {identifier: 71, text: "Nine"},
+ {identifier: 70, text: "Alpha"},
+ {identifier: 69, text: "Bravo"},
+ {identifier: 68, text: "Charlie"},
+ {identifier: 67, text: "Delta"},
+ {identifier: 66, text: "Echo"},
+ {identifier: 65, text: "Fox-trot"},
+ {identifier: 64, text: "Black"},
+ {identifier: 63, text: "Brown"},
+ {identifier: 62, text: "Red"},
+ {identifier: 61, text: "Orange"},
+ {identifier: 60, text: "Yellow"},
+ {identifier: 59, text: "Green"},
+ {identifier: 58, text: "Blue"},
+ {identifier: 57, text: "Violet"},
+ {identifier: 56, text: "Grey"},
+ {identifier: 55, text: "White"},
+ {identifier: 54, text: "milli"},
+ {identifier: 53, text: "micro"},
+ {identifier: 52, text: "nano"},
+ {identifier: 51, text: "pico"}]}},
+ {command: "D081F3" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850A4C617267654D656E7532" + // Alpha identifier
+ "8F1DFF312043616C6C20466F727761726420556E636F6E646974" + // Item
+ "696F6E616C" +
+ "8F1CFE322043616C6C20466F7277617264204F6E205573657220" + // Item
+ "42757379" +
+ "8F1BFD332043616C6C20466F7277617264204F6E204E6F205265" + // Item
+ "706C79" +
+ "8F25FC342043616C6C20466F7277617264204F6E205573657220" + // Item
+ "4E6F7420526561636861626C65" +
+ "8F20FB352042617272696E67204F6620416C6C204F7574676F69" + // Item
+ "6E672043616C6C73" +
+ "8F24FA362042617272696E67204F6620416C6C204F7574676F69" + // Item
+ "6E6720496E742043616C6C73" +
+ "8F13F93720434C492050726573656E746174696F6E", // Item
+ expect: {commandQualifier: 0x00,
title: "LargeMenu2",
- items: [{identifier: 255, text: "1 Call Forward Unconditional"}, {identifier: 254, text: "2 Call Forward On User Busy"}, {identifier: 253, text: "3 Call Forward On No Reply"}, {identifier: 252, text: "4 Call Forward On User Not Reachable"}, {identifier: 251, text: "5 Barring Of All Outgoing Calls"}, {identifier: 250, text: "6 Barring Of All Outgoing Int Calls"}, {identifier: 249, text: "7 CLI Presentation"}]}},
- {command: "d081fc8103012500820281828581ec5468652053494d207368616c6c20737570706c79206120736574206f66206d656e75206974656d732c207768696368207368616c6c20626520696e7465677261746564207769746820746865206d656e752073797374656d20286f72206f74686572204d4d4920666163696c6974792920696e206f7264657220746f206769766520746865207573657220746865206f70706f7274756e69747920746f2063686f6f7365206f6e65206f66207468657365206d656e75206974656d7320617420686973206f776e2064697363726574696f6e2e2045616368206974656d20636f6d70726973657320612073688f020159",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_5",
- commandQualifier: 0x00,
- title: "The SIM shall supply a set of menu items, which shall be integrated with the menu system (or other MMI facility) in order to give the user the opportunity to choose one of these menu items at his own discretion. Each item comprises a sh",
+ items: [{identifier: 255, text: "1 Call Forward Unconditional"},
+ {identifier: 254, text: "2 Call Forward On User Busy"},
+ {identifier: 253, text: "3 Call Forward On No Reply"},
+ {identifier: 252, text: "4 Call Forward On User Not Reachable"},
+ {identifier: 251, text: "5 Barring Of All Outgoing Calls"},
+ {identifier: 250, text: "6 Barring Of All Outgoing Int Calls"},
+ {identifier: 249, text: "7 CLI Presentation"}]}},
+ {command: "D081FC" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "8581EC5468652053494D207368616C6C20737570" + // Alpha identifier
+ "706C79206120736574206F66206D656E75206974" +
+ "656D732C207768696368207368616C6C20626520" +
+ "696E746567726174656420776974682074686520" +
+ "6D656E752073797374656D20286F72206F746865" +
+ "72204D4D4920666163696C6974792920696E206F" +
+ "7264657220746F20676976652074686520757365" +
+ "7220746865206F70706F7274756E69747920746F" +
+ "2063686F6F7365206F6E65206F66207468657365" +
+ "206D656E75206974656D7320617420686973206F" +
+ "776E2064697363726574696F6E2E204561636820" +
+ "6974656D20636F6D7072697365732061207368" +
+ "8F020159", // Item
+ expect: {commandQualifier: 0x00,
+ title: "The SIM shall supply a set of menu items, which shall " +
+ "be integrated with the menu system (or other MMI " +
+ "facility) in order to give the user the opportunity to " +
+ "choose one of these menu items at his own discretion. " +
+ "Each item comprises a sh",
items: [{identifier: 1, text: "Y"}]}},
- {command: "d03b810301258082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_6",
- commandQualifier: 0x80,
- title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
- {command: "d041810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034180413101526",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_7",
- commandQualifier: 0x00,
+ {command: "D03B" + // Length
+ "8103012580" + // Command details
+ "82028182" + // Device identities
+ "850C546F6F6C6B6974204D656E75" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "8F07044974656D2034", // Item
+ expect: {commandQualifier: 0x80,
title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
- {command: "d03c810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20339e0201019f0401050505",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_8",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"},
+ {identifier: 4, text: "Item 4"}]}},
+ {command: "D041" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850C546F6F6C6B6974204D656E75" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "8F07044974656D2034" + // Item
+ "180413101526", // Items next action indicator
+ expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d03c810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20339e0200019f0400050505",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_9",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"},
+ {identifier: 4, text: "Item 4"}],
+ nextActionList: [MozIccManager.STK_CMD_SEND_SMS,
+ MozIccManager.STK_CMD_SET_UP_CALL,
+ MozIccManager.STK_CMD_LAUNCH_BROWSER,
+ MozIccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
+ {command: "D03C" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850C546F6F6C6B6974204D656E75" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "9E020001" + // Icon identifier
+ "9F0400050505", // Item icon identifier list
+ expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d029810301250182028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d2032",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_10",
- commandQualifier: 0x01,
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON],
+ items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
+ {identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
+ {identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]}]}},
+ {command: "D036" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850C546F6F6C6B6974204D656E75" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "9E020001", // Icon identifier
+ expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e00b4d10c000600b4000600b4000600b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_11",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_12",
- commandQualifier: 0x00,
- title: "Toolkit Menu 2",
- items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e01b4d10c000601b4000601b4000601b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_13",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_14",
- commandQualifier: 0x00,
- title: "Toolkit Menu 2",
- items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e02b4d10c000602b4000602b4000602b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_15",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_16",
- commandQualifier: 0x00,
- title: "Toolkit Menu 2",
- items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e04b4d10c000604b4000604b4000604b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_17",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036d004000e00b4d10c000600b4000600b4000600b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_18",
- commandQualifier: 0x00,
- title: "Toolkit Menu 2",
- items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
- {command: "d034810301250082028182850e546f6f6c6b6974204d656e7520338f07074974656d20378f07084974656d20388f07094974656d2039",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_19",
- commandQualifier: 0x00,
- title: "Toolkit Menu 3",
- items: [{identifier: 7, text: "Item 7"}, {identifier: 8, text: "Item 8"}, {identifier: 9, text: "Item 9"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e08b4d10c000608b4000608b4000608b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_20",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e10b4d10c000610b4000610b4000610b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_21",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e20b4d10c000620b4000620b4000620b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_22",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e40b4d10c000640b4000640b4000640b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_23",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e80b4d10c000680b4000680b4000680b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_24",
- commandQualifier: 0x00,
- title: "Toolkit Menu 1",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d046810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d2033d004000c00b4d10c000600b4000600b4000600b4",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_25",
- commandQualifier: 0x00,
+ iconSelfExplanatory: true,
+ icons: [BASIC_ICON],
+ items: [{identifier: 1, text: "Item 1"},
+ {identifier: 2, text: "Item 2"},
+ {identifier: 3, text: "Item 3"}]}},
+ {command: "D038" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "850C546F6F6C6B6974204D656E75" + // Alpha identifier
+ "8F07014974656D2031" + // Item
+ "8F07024974656D2032" + // Item
+ "8F07034974656D2033" + // Item
+ "9F0400030303", // Item icon identifier list
+ expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
- items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
- {command: "d0819c8103012500820281828519800417041404200410041204210422041204230419042204158f1c018004170414042004100412042104220412042304190422041500318f1c028004170414042004100412042104220412042304190422041500328f1c038004170414042004100412042104220412042304190422041500338f1c04800417041404200410041204210422041204230419042204150034",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_26",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [COLOR_ICON]},
+ {identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [COLOR_ICON]},
+ {identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [COLOR_ICON]}]}},
+ {command: "D0819C" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "851980041704140420041004120421042204120423041904220415" + // Alpha identifier
+ "8F1C01800417041404200410041204210422041204230419042204150031" + // Item
+ "8F1C02800417041404200410041204210422041204230419042204150032" + // Item
+ "8F1C03800417041404200410041204210422041204230419042204150033" + // Item
+ "8F1C04800417041404200410041204210422041204230419042204150034", // Item
+ expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
- items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}, {identifier: 4, text: "ЗДРАВСТВУЙТЕ4"}]}},
- {command: "d0608103012500820281828519800417041404200410041204210422041204230419042204158f1c118004170414042004100412042104220412042304190422041500358f1c12800417041404200410041204210422041204230419042204150036",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_27",
- commandQualifier: 0x00,
- title: "ЗДРАВСТВУЙТЕ",
- items: [{identifier: 17, text: "ЗДРАВСТВУЙТЕ5"}, {identifier: 18, text: "ЗДРАВСТВУЙТЕ6"}]}},
- {command: "d03c8103012500820281828509805de551777bb153558f080180987976ee4e008f080280987976ee4e8c8f080380987976ee4e098f080480987976ee56db",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_28",
- commandQualifier: 0x00,
- title: "工具箱单",
- items: [{identifier: 1, text: "项目一"}, {identifier: 2, text: "项目二"}, {identifier: 3, text: "项目三"}, {identifier: 4, text: "项目四"}]}},
- {command: "d0208103012500820281828509805de551777bb153558f0411804e008f0412804e8c",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_29",
- commandQualifier: 0x00,
+ items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"},
+ {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"},
+ {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"},
+ {identifier: 4, text: "ЗДРАВСТВУЙТЕ4"}]}},
+ {command: "D03C" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "8509805DE551777BB15355" + // Alpha identifier
+ "8F080180987976EE4E00" + // Item
+ "8F080280987976EE4E8C" + // Item
+ "8F080380987976EE4E09" + // Item
+ "8F080480987976EE56DB", // Item
+ expect: {commandQualifier: 0x00,
title: "工具箱单",
- items: [{identifier: 17, text: "一"}, {identifier: 18, text: "二"}]}},
- {command: "d0448103012500820281828509800038003030eb00308f0a01800038003030eb00318f0a02800038003030eb00328f0a03800038003030eb00338f0a04800038003030eb0034",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_30",
- commandQualifier: 0x00,
- title: "80ル0",
- items: [{identifier: 1, text: "80ル1"}, {identifier: 2, text: "80ル2"}, {identifier: 3, text: "80ル3"}, {identifier: 4, text: "80ル4"}]}},
- {command: "d02c8103012500820281828509800038003030eb00308f0a11800038003030eb00358f0a12800038003030eb0036",
- func: testSetupMenu,
- expect: {name: "setup_menu_cmd_31",
- commandQualifier: 0x00,
- title: "80ル0",
- items: [{identifier: 17, text: "80ル5"}, {identifier: 18, text: "80ル6"}]}}
+ items: [{identifier: 1, text: "项目一"},
+ {identifier: 2, text: "项目二"},
+ {identifier: 3, text: "项目三"},
+ {identifier: 4, text: "项目四"}]}},
+ // Test remove setup menu.
+ {command: "D00D" + // Length
+ "8103012500" + // Command details
+ "82028182" + // Device identities
+ "8500" + // Alpha identifier
+ "8F00", // Item
+ expect: {commandQualifier: 0x00,
+ title: "",
+ items: [null]}},
];
-let pendingEmulatorCmdCount = 0;
-function sendStkPduToEmulator(command, func, expect) {
- ++pendingEmulatorCmdCount;
+function testSetupMenu(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_MENU, "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+
+ // To ensure that 'presentationType' will only be available in SELECT_ITEM.
+ is(aCommand.options.presentationType, undefined, "presentationType");
+ is(aCommand.options.isHelpAvailable, !!(aCommand.commandQualifier & 0x80),
+ "isHelpAvailable");
+ is(aCommand.options.title, aExpect.title, "options.title");
- runEmulatorCmd(command, function (result) {
- --pendingEmulatorCmdCount;
- is(result[0], "OK");
- });
+ for (let index in aExpect.items) {
+ let item = aCommand.options.items[index];
+ let itemExpect = aExpect.items[index];
- icc.onstkcommand = function (evt) {
- func(evt.command, expect);
+ if (!itemExpect) {
+ is(item, itemExpect, "options.items[" + index + "]");
+ } else {
+ is(item.identifier, itemExpect.identifier,
+ "options.items[" + index + "].identifier");
+ is(item.text, itemExpect.text,
+ "options.items[" + index + "].text");
+
+ if (itemExpect.icons) {
+ isIcons(item.icons, itemExpect.icons);
+ is(item.iconSelfExplanatory, itemExpect.iconSelfExplanatory,
+ "options.items[" + index + "].iconSelfExplanatory");
+ }
+ }
}
-}
-function runNextTest() {
- let test = tests.pop();
- if (!test) {
- cleanUp();
- return;
+ // icons is optional.
+ if ("icons" in aExpect) {
+ isIcons(aCommand.options.icons, aExpect.icons);
+ is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
+ "options.iconSelfExplanatory");
}
- let command = "stk pdu " + test.command;
- sendStkPduToEmulator(command, test.func, test.expect)
+ // nextActionList is optional.
+ if ("nextActionList" in aExpect) {
+ for (let index in aExpect.nextActionList) {
+ is(aCommand.options.nextActionList[index], aExpect.nextActionList[index],
+ "options.nextActionList[" + index + "]");
+ }
+ }
}
-function cleanUp() {
- if (pendingEmulatorCmdCount) {
- window.setTimeout(cleanUp, 100);
- return;
- }
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("setup_menu_cmd: " + data.command);
- SpecialPowers.removePermission("mobileconnection", document);
- finish();
-}
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testSetupMenu(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testSetupMenu(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
-runNextTest();
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/marionette/test_stk_timer_management.js b/dom/icc/tests/marionette/test_stk_timer_management.js
new file mode 100644
index 000000000..b5003e21c
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_timer_management.js
@@ -0,0 +1,76 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = "head.js";
+
+const TEST_DATA = [
+ // Start
+ {command: "D011" + // Length
+ "8103012700" + // Command details
+ "82028182" + // Device identities
+ "A40101" + // Timer identifier
+ "A503102030", // Timer value
+ expect: {commandQualifier: MozIccManager.STK_TIMER_START,
+ timerAction: MozIccManager.STK_TIMER_START,
+ timerId: 0x01,
+ timerValue: (0x01 * 60 * 60) + (0x02 * 60) + 0x03}},
+ // Deactivate
+ {command: "D00C" + // Length
+ "8103012701" + // Command details
+ "82028182" + // Device identities
+ "A40104", // Timer identifier
+ expect: {commandQualifier: MozIccManager.STK_TIMER_DEACTIVATE,
+ timerAction: MozIccManager.STK_TIMER_DEACTIVATE,
+ timerId: 0x04}},
+ // Get current value
+ {command: "D00C" + // Length
+ "8103012702" + // Command details
+ "82028182" + // Device identities
+ "A40108", // Timer identifier
+ expect: {commandQualifier: MozIccManager.STK_TIMER_GET_CURRENT_VALUE,
+ timerAction: MozIccManager.STK_TIMER_GET_CURRENT_VALUE,
+ timerId: 0x08}},
+];
+
+function testTimerManagement(aCommand, aExpect) {
+ is(aCommand.commandNumber, 0x01, "commandNumber");
+ is(aCommand.typeOfCommand, MozIccManager.STK_CMD_TIMER_MANAGEMENT,
+ "typeOfCommand");
+ is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
+
+ is(aCommand.options.timerAction, aExpect.timerAction, "options.timerAction");
+ is(aCommand.options.timerId, aExpect.timerId, "options.timerId");
+
+ if ("timerValue" in aExpect) {
+ is(aCommand.options.timerValue, aExpect.timerValue, "options.timerValue");
+ }
+}
+
+// Start tests
+startTestCommon(function() {
+ let icc = getMozIcc();
+ let promise = Promise.resolve();
+ for (let i = 0; i < TEST_DATA.length; i++) {
+ let data = TEST_DATA[i];
+ promise = promise.then(() => {
+ log("timer_management_cmd: " + data.command);
+
+ let promises = [];
+ // Wait onstkcommand event.
+ promises.push(waitForTargetEvent(icc, "stkcommand")
+ .then((aEvent) => testTimerManagement(aEvent.command, data.expect)));
+ // Wait icc-stkcommand system message.
+ promises.push(waitForSystemMessage("icc-stkcommand")
+ .then((aMessage) => {
+ is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
+ testTimerManagement(aMessage.command, data.expect);
+ }));
+ // Send emulator command to generate stk unsolicited event.
+ promises.push(sendEmulatorStkPdu(data.command));
+
+ return Promise.all(promises);
+ });
+ }
+ return promise;
+});
diff --git a/dom/icc/tests/moz.build b/dom/icc/tests/moz.build
deleted file mode 100644
index 4aedcd703..000000000
--- a/dom/icc/tests/moz.build
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-MODULE = 'test_dom_icc'
-