diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
commit | d25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch) | |
tree | 16ec27edc7d5f83986f16236d3a36a2682a0f37e /dom/icc | |
parent | a942906574671868daf122284a9c4689e6924f74 (diff) | |
download | palemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz |
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'dom/icc')
34 files changed, 5343 insertions, 0 deletions
diff --git a/dom/icc/interfaces/Makefile.in b/dom/icc/interfaces/Makefile.in new file mode 100644 index 000000000..09c8567a7 --- /dev/null +++ b/dom/icc/interfaces/Makefile.in @@ -0,0 +1,14 @@ +# 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 new file mode 100644 index 000000000..b13b31aea --- /dev/null +++ b/dom/icc/interfaces/SimToolKit.idl @@ -0,0 +1,636 @@ +/* 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 new file mode 100644 index 000000000..caf6a9d6b --- /dev/null +++ b/dom/icc/interfaces/moz.build @@ -0,0 +1,21 @@ +# -*- 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/. + +XPIDL_SOURCES += [ + 'SimToolKit.idl', + 'nsIDOMIccCardLockErrorEvent.idl', + 'nsIDOMIccManager.idl', + 'nsIIccProvider.idl', + 'nsINavigatorIccManager.idl', +] + +XPIDL_MODULE = 'dom_icc' + +XPIDL_FLAGS += [ + '-I$(topsrcdir)/dom/interfaces/base', + '-I$(topsrcdir)/dom/interfaces/events', +] + diff --git a/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl b/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl new file mode 100644 index 000000000..50fb98aec --- /dev/null +++ b/dom/icc/interfaces/nsIDOMIccCardLockErrorEvent.idl @@ -0,0 +1,24 @@ +/* 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 new file mode 100644 index 000000000..540ee1038 --- /dev/null +++ b/dom/icc/interfaces/nsIDOMIccManager.idl @@ -0,0 +1,490 @@ +/* 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/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl new file mode 100644 index 000000000..3c42f9a7d --- /dev/null +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -0,0 +1,78 @@ +/* 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 nsIDOMWindow; +interface nsIDOMDOMRequest; +interface nsIDOMContact; + +[scriptable, uuid(dca08580-a25a-11e2-9e96-0800200c9a66)] +interface nsIIccListener : nsISupports +{ + void notifyStkCommand(in DOMString aMessage); + void notifyStkSessionEnd(); + void notifyIccCardLockError(in DOMString lockType, + in unsigned long retryCount); +}; + +/** + * XPCOM component (in the content process) that provides the ICC information. + */ +[scriptable, uuid(e60ec460-a25a-11e2-9e96-0800200c9a66)] +interface nsIIccProvider : nsISupports +{ + /** + * 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); + + /** + * STK interfaces. + */ + void sendStkResponse(in nsIDOMWindow window, + in jsval command, + in jsval response); + void sendStkMenuSelection(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); + + /** + * 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); + + /** + * Phonebook interfaces. + */ + nsIDOMDOMRequest readContacts(in nsIDOMWindow window, + in DOMString contactType); + + nsIDOMDOMRequest updateContact(in nsIDOMWindow window, + in DOMString contactType, + in nsIDOMContact contact, + in DOMString pin2); + + /** + * Secure Card Icc communication channel + */ + nsIDOMDOMRequest iccOpenChannel(in nsIDOMWindow window, + in DOMString aid); + + nsIDOMDOMRequest iccExchangeAPDU(in nsIDOMWindow window, + in long channel, + in jsval apdu); + + nsIDOMDOMRequest iccCloseChannel(in nsIDOMWindow window, + in long channel); +}; diff --git a/dom/icc/interfaces/nsINavigatorIccManager.idl b/dom/icc/interfaces/nsINavigatorIccManager.idl new file mode 100644 index 000000000..71f427b5a --- /dev/null +++ b/dom/icc/interfaces/nsINavigatorIccManager.idl @@ -0,0 +1,16 @@ +/* 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 new file mode 100644 index 000000000..6834f77cb --- /dev/null +++ b/dom/icc/moz.build @@ -0,0 +1,8 @@ +# -*- 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/. + +PARALLEL_DIRS += ['interfaces', 'src'] +TEST_DIRS += ['tests'] diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp new file mode 100644 index 000000000..31a561ac2 --- /dev/null +++ b/dom/icc/src/IccManager.cpp @@ -0,0 +1,249 @@ +/* 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 new file mode 100644 index 000000000..893a01e6a --- /dev/null +++ b/dom/icc/src/IccManager.h @@ -0,0 +1,49 @@ +/* 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 new file mode 100644 index 000000000..a2fed7497 --- /dev/null +++ b/dom/icc/src/Makefile.in @@ -0,0 +1,25 @@ +# 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 new file mode 100644 index 000000000..d4a0ea765 --- /dev/null +++ b/dom/icc/src/StkCommandEvent.cpp @@ -0,0 +1,51 @@ +/* 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 new file mode 100644 index 000000000..30ac05d87 --- /dev/null +++ b/dom/icc/src/StkCommandEvent.h @@ -0,0 +1,78 @@ +/* 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 new file mode 100644 index 000000000..e5e527fd4 --- /dev/null +++ b/dom/icc/src/moz.build @@ -0,0 +1,15 @@ +# -*- 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/manifest.ini b/dom/icc/tests/marionette/manifest.ini new file mode 100644 index 000000000..1d9afb0b4 --- /dev/null +++ b/dom/icc/tests/marionette/manifest.ini @@ -0,0 +1,23 @@ +[DEFAULT] +b2g = true +browser = false +qemu = true + +[test_stk_proactive_command.js] +[test_icc_contact.js] +[test_icc_card_lock.js] +[test_stk_refresh.js] +[test_stk_poll_off.js] +[test_stk_setup_event_list.js] +[test_stk_setup_call.js] +[test_stk_send_ss.js] +[test_stk_send_ussd.js] +[test_stk_send_sms.js] +[test_stk_send_dtmf.js] +[test_stk_launch_browser.js] +[test_stk_display_text.js] +[test_stk_get_inkey.js] +[test_stk_get_input.js] +[test_stk_select_item.js] +[test_stk_setup_menu.js] +[test_stk_setup_idle_mode_text.js] diff --git a/dom/icc/tests/marionette/test_icc_card_lock.js b/dom/icc/tests/marionette/test_icc_card_lock.js new file mode 100644 index 000000000..561229d55 --- /dev/null +++ b/dom/icc/tests/marionette/test_icc_card_lock.js @@ -0,0 +1,115 @@ +/* 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_contact.js b/dom/icc/tests/marionette/test_icc_contact.js new file mode 100644 index 000000000..e242d49ac --- /dev/null +++ b/dom/icc/tests/marionette/test_icc_contact.js @@ -0,0 +1,116 @@ +/* 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"); +} + +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 cleanUp() { + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_display_text.js b/dom/icc/tests/marionette/test_stk_display_text.js new file mode 100644 index 000000000..27aa7bef4 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_display_text.js @@ -0,0 +1,118 @@ +/* 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 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, + text: "Toolkit Test 1", + userClear: true}}, + {command: "d01a8103012181820281028d0f04546f6f6c6b697420546573742032", + func: testDisplayText, + expect: {name: "display_text_cmd_2", + 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, + text: "<GO-BACKWARDS>", + userClear: true}}, + {command: "d0248103012180820281028d1908041704140420041004120421042204120423041904220415", + func: testDisplayText, + expect: {name: "display_text_cmd_7", + commandQualifier: 0x80, + text: "ЗДРАВСТВУЙТЕ", + userClear: true}}, + {command: "d0108103012180820281028d05084f60597d", + func: testDisplayText, + expect: {name: "display_text_cmd_8", + commandQualifier: 0x80, + text: "你好", + userClear: true}}, + {command: "d0128103012180820281028d07080038003030eb", + func: testDisplayText, + expect: {name: "display_text_cmd_9", + commandQualifier: 0x80, + text: "80ル", + userClear: true}}, +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_get_inkey.js b/dom/icc/tests/marionette/test_stk_get_inkey.js new file mode 100644 index 000000000..9368956eb --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_get_inkey.js @@ -0,0 +1,138 @@ +/* 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 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, + 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, + 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, + text: "<NO-ICON>"}}, +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_get_input.js b/dom/icc/tests/marionette/test_stk_get_input.js new file mode 100644 index 000000000..06c2be0ad --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_get_input.js @@ -0,0 +1,212 @@ +/* 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 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, + text: "Enter 12345", + minLength: 5, + maxLength: 5}}, + {command: "d01a8103012308820281828d0b004537bd2c07d96eaad10a91020505", + func: testGetInput, + expect: {name: "get_input_cmd_2", + commandQualifier: 0x08, + text: "Enter 67*#+", + minLength: 5, + maxLength: 5, + isPacked: true}}, + {command: "d01b8103012301820281828d0c04456e74657220416243644591020505", + func: testGetInput, + expect: {name: "get_input_cmd_3", + commandQualifier: 0x01, + text: "Enter AbCdE", + minLength: 5, + maxLength: 5, + isAlphabet: true}}, + {command: "d0278103012304820281828d180450617373776f726420313c53454e443e3233343536373891020408", + func: testGetInput, + expect: {name: "get_input_cmd_4", + 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>", + 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###", + 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: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ", + 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, + 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, + 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, + text: "<NO-ICON>", + minLength: 0, + maxLength: 10}}, + {command: "d0208103012300820281828d0d043c42415349432d49434f4e3e9102000a1e020101", + func: testGetInput, + expect: {name: "get_input_cmd_18", + commandQualifier: 0x00, + text: "<BASIC-ICON>", + minLength: 0, + maxLength: 10}}, +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_launch_browser.js b/dom/icc/tests/marionette/test_stk_launch_browser.js new file mode 100644 index 000000000..5d20f0dfa --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_launch_browser.js @@ -0,0 +1,289 @@ +/* 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 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, + 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: "ル"}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_poll_off.js b/dom/icc/tests/marionette/test_stk_poll_off.js new file mode 100644 index 000000000..ca4b93bd2 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_poll_off.js @@ -0,0 +1,61 @@ +/* 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 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}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_proactive_command.js b/dom/icc/tests/marionette/test_stk_proactive_command.js new file mode 100644 index 000000000..08a0662c8 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_proactive_command.js @@ -0,0 +1,244 @@ +/* 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 new file mode 100644 index 000000000..c76e1459e --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_refresh.js @@ -0,0 +1,65 @@ +/* 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}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_select_item.js b/dom/icc/tests/marionette/test_stk_select_item.js new file mode 100644 index 000000000..69497aa68 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_select_item.js @@ -0,0 +1,350 @@ +/* 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 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, + 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, + 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, + 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: 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + title: "82ル0", + items: [{identifier: 1, text: "82ル1"}, {identifier: 2, text: "82ル2"}, {identifier: 3, text: "82ル3"}]}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_send_dtmf.js b/dom/icc/tests/marionette/test_stk_send_dtmf.js new file mode 100644 index 000000000..70436fb29 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_send_dtmf.js @@ -0,0 +1,230 @@ +/* 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 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, + text: "Send DTMF"}}, + {command: "d0138103011400820281838500ac06c1cccccccc2c", + func: testSendDTMF, + expect: {name: "send_dtmf_cmd_2", + 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, + 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, + 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, + 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"); + }); + + 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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_send_sms.js b/dom/icc/tests/marionette/test_stk_send_sms.js new file mode 100644 index 000000000..21c5af5a1 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_send_sms.js @@ -0,0 +1,280 @@ +/* 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 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"}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_send_ss.js b/dom/icc/tests/marionette/test_stk_send_ss.js new file mode 100644 index 000000000..6e914690e --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_send_ss.js @@ -0,0 +1,240 @@ +/* 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 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: "ル"}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_send_ussd.js b/dom/icc/tests/marionette/test_stk_send_ussd.js new file mode 100644 index 000000000..45ecc4c2a --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_send_ussd.js @@ -0,0 +1,245 @@ +/* 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 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: "ル"}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_setup_call.js b/dom/icc/tests/marionette/test_stk_setup_call.js new file mode 100644 index 000000000..5b90aedff --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_setup_call.js @@ -0,0 +1,284 @@ +/* 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 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"}}, +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_setup_event_list.js b/dom/icc/tests/marionette/test_stk_setup_event_list.js new file mode 100644 index 000000000..76cdaed80 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_setup_event_list.js @@ -0,0 +1,90 @@ +/* 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 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, + eventList: [4]}}, + {command: "d00d81030105008202818299020507", + func: testSetupEventList, + expect: {name: "setup_event_list_cmd_2", + commandQualifier: 0x00, + eventList: [5, 7]}}, + {command: "d00c810301050082028182990107", + func: testSetupEventList, + expect: {name: "setup_event_list_cmd_3", + commandQualifier: 0x00, + eventList: [7]}}, + {command: "d00c810301050082028182990107", + func: testSetupEventList, + expect: {name: "setup_event_list_cmd_4", + commandQualifier: 0x00, + eventList: [7]}}, + {command: "d00b8103010500820281829900", + func: testSetupEventList, + expect: {name: "setup_event_list_cmd_5", + commandQualifier: 0x00, + eventList: null}}, + {command: "d00c810301050082028182990107", + func: testSetupEventList, + expect: {name: "setup_event_list_cmd_6", + commandQualifier: 0x00, + eventList: [7]}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); 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 new file mode 100644 index 000000000..eb90f404a --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js @@ -0,0 +1,233 @@ +/* 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 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, + 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, + 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, + 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, + 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"); + }); + + 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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_setup_menu.js b/dom/icc/tests/marionette/test_stk_setup_menu.js new file mode 100644 index 000000000..ab59a96b0 --- /dev/null +++ b/dom/icc/tests/marionette/test_stk_setup_menu.js @@ -0,0 +1,248 @@ +/* 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 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, + 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, + 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: 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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"}]}} +]; + +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 cleanUp() { + if (pendingEmulatorCmdCount) { + window.setTimeout(cleanUp, 100); + return; + } + + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +runNextTest(); diff --git a/dom/icc/tests/moz.build b/dom/icc/tests/moz.build new file mode 100644 index 000000000..4aedcd703 --- /dev/null +++ b/dom/icc/tests/moz.build @@ -0,0 +1,8 @@ +# -*- 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' + |