From 826315e43ef195540aeea9ccbc5676de54677a27 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Thu, 31 Oct 2013 12:14:45 +0800 Subject: [PATCH] Bug 814637 - Part 6: Marionette tests changes for new IccManager API. r=hsinyi --- dom/icc/tests/marionette/icc_header.js | 21 ++- dom/icc/tests/marionette/manifest.ini | 4 + dom/icc/tests/marionette/stk_helper.js | 20 ++- .../test_icc_access_invalid_object.js | 121 ++++++++++++++++++ .../tests/marionette/test_icc_card_state.js | 12 +- .../test_icc_detected_undetected_event.js | 72 +++++++++++ dom/icc/tests/marionette/test_icc_info.js | 12 +- .../tests/marionette/test_stk_display_text.js | 4 +- .../tests/marionette/test_stk_get_inkey.js | 4 +- .../tests/marionette/test_stk_get_input.js | 2 +- .../marionette/test_stk_launch_browser.js | 2 +- dom/icc/tests/marionette/test_stk_poll_off.js | 2 +- .../marionette/test_stk_proactive_command.js | 44 +++---- dom/icc/tests/marionette/test_stk_refresh.js | 2 +- .../tests/marionette/test_stk_select_item.js | 2 +- .../tests/marionette/test_stk_send_dtmf.js | 2 +- dom/icc/tests/marionette/test_stk_send_sms.js | 2 +- dom/icc/tests/marionette/test_stk_send_ss.js | 2 +- .../tests/marionette/test_stk_send_ussd.js | 2 +- .../tests/marionette/test_stk_setup_call.js | 6 +- .../marionette/test_stk_setup_event_list.js | 2 +- .../test_stk_setup_idle_mode_text.js | 2 +- .../tests/marionette/test_stk_setup_menu.js | 6 +- .../marionette/test_outgoing_radio_off.js | 15 +-- 24 files changed, 293 insertions(+), 70 deletions(-) create mode 100644 dom/icc/tests/marionette/test_icc_access_invalid_object.js create mode 100644 dom/icc/tests/marionette/test_icc_detected_undetected_event.js diff --git a/dom/icc/tests/marionette/icc_header.js b/dom/icc/tests/marionette/icc_header.js index 9b72ab68f02..670d624eae3 100644 --- a/dom/icc/tests/marionette/icc_header.js +++ b/dom/icc/tests/marionette/icc_header.js @@ -3,9 +3,24 @@ SpecialPowers.addPermission("mobileconnection", true, document); -let icc = navigator.mozIccManager; -ok(icc instanceof MozIccManager, - "icc is instanceof " + icc.constructor); +let iccManager = navigator.mozIccManager; +ok(iccManager instanceof MozIccManager, + "iccManager is instanceof " + iccManager.constructor); + +// TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for +// multi-sim +// In single sim scenario, there is only one sim card, we can use below way to +// check iccId and get icc object. But in multi-sim, the index of iccIds may +// not map to sim slot directly, we should have a better way to handle this. +let iccIds = iccManager.iccIds; +ok(Array.isArray(iccIds), "iccIds is an array"); +is(iccIds.length, 1, "iccIds.length is " + iccIds.length); + +let iccId = iccIds[0]; +is(iccId, "89014103211118510720", "iccId is " + iccId); + +let icc = iccManager.getIccById(iccId); +ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor); /* Remove permission and execute finish() */ let cleanUp = function () { diff --git a/dom/icc/tests/marionette/manifest.ini b/dom/icc/tests/marionette/manifest.ini index 480ce3b3bd7..f336e0cb22b 100644 --- a/dom/icc/tests/marionette/manifest.ini +++ b/dom/icc/tests/marionette/manifest.ini @@ -22,3 +22,7 @@ qemu = true [test_stk_select_item.js] [test_stk_setup_menu.js] [test_stk_setup_idle_mode_text.js] +[test_icc_access_invalid_object.js] +disabled = Bug 933654 +[test_icc_detected_undetected_event.js] +disabled = Bug 933654 diff --git a/dom/icc/tests/marionette/stk_helper.js b/dom/icc/tests/marionette/stk_helper.js index f29f153d8fb..09f20f64d71 100644 --- a/dom/icc/tests/marionette/stk_helper.js +++ b/dom/icc/tests/marionette/stk_helper.js @@ -5,8 +5,24 @@ MARIONETTE_TIMEOUT = 30000; SpecialPowers.addPermission("mobileconnection", true, document); -let icc = navigator.mozIccManager; -ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor); +let iccManager = navigator.mozIccManager; +ok(iccManager instanceof MozIccManager, + "iccManager is instanceof " + iccManager.constructor); + +// TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for +// multi-sim +// In single sim scenario, there is only one sim card, we can use below way to +// check iccId and get icc object. But in multi-sim, the index of iccIds may +// not map to sim slot directly, we should have a better way to handle this. +let iccIds = iccManager.iccIds; +ok(Array.isArray(iccIds), "iccIds is an array"); +is(iccIds.length, 1, "iccIds.length is " + iccIds.length); + +let iccId = iccIds[0]; +is(iccId, "89014103211118510720", "iccId is " + iccId); + +let icc = iccManager.getIccById(iccId); +ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor); let pendingEmulatorCmdCount = 0; function sendStkPduToEmulator(command, func, expect) { diff --git a/dom/icc/tests/marionette/test_icc_access_invalid_object.js b/dom/icc/tests/marionette/test_icc_access_invalid_object.js new file mode 100644 index 00000000000..98628ac2196 --- /dev/null +++ b/dom/icc/tests/marionette/test_icc_access_invalid_object.js @@ -0,0 +1,121 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 30000; +MARIONETTE_HEAD_JS = "icc_header.js"; + +function setRadioEnabled(enabled) { + SpecialPowers.addPermission("settings-write", true, document); + + // TODO: Bug 856553 - [B2G] RIL: need an API to enable/disable radio + let settings = navigator.mozSettings; + let setLock = settings.createLock(); + let obj = { + "ril.radio.disabled": !enabled + }; + let setReq = setLock.set(obj); + + setReq.addEventListener("success", function onSetSuccess() { + log("set 'ril.radio.disabled' to " + enabled); + }); + + setReq.addEventListener("error", function onSetError() { + ok(false, "cannot set 'ril.radio.disabled' to " + enabled); + }); + + SpecialPowers.removePermission("settings-write", document); +} + +/* Test access invalid icc object */ +taskHelper.push(function testAccessRemovedIccObject() { + setRadioEnabled(false); + iccManager.addEventListener("iccundetected", function oniccundetected(evt) { + log("got icc undetected event"); + iccManager.removeEventListener("iccundetected", oniccundetected); + is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected"); + + // Test access iccInfo. + try { + is(icc.iccInfo, null, "iccInfo: expect to get null"); + } catch(e) { + ok(false, "access iccInfo should not get exception"); + } + + // Test access cardState. + try { + is(icc.cardState, null, "cardState: expect to get null"); + } catch(e) { + ok(false, "access cardState should not get exception"); + } + + // Test STK related function. + try { + icc.sendStkResponse({}, {}); + ok(false, "sendStkResponse() should get exception"); + } catch(e) {} + try { + icc.sendStkMenuSelection(0, false); + ok(false, "sendStkMenuSelection() should get exception"); + } catch(e) {} + try { + icc.sendStkTimerExpiration({}); + ok(false, "sendStkTimerExpiration() should get exception"); + } catch(e) {} + try { + icc.sendStkEventDownload({}); + ok(false, "sendStkEventDownload() should get exception"); + } catch(e) {} + + // Test card lock related function. + try { + icc.getCardLock(""); + ok(false, "getCardLock() should get exception"); + } catch(e) {} + try { + icc.unlockCardLock({}); + ok(false, "unlockCardLock() should get exception"); + } catch(e) {} + try { + icc.setCardLock({}); + ok(false, "setCardLock() should get exception"); + } catch(e) {} + try { + icc.getCardLockRetryCount(""); + ok(false, "getCardLockRetryCount() should get exception"); + } catch(e) {} + + // Test contact related function. + try { + icc.readContacts(""); + ok(false, "readContacts() should get exception"); + } catch(e) {} + try { + icc.updateContact("", {}); + ok(false, "updateContact() should get exception"); + } catch(e) {} + + // Test secure element related function. + try { + icc.iccOpenChannel(""); + ok(false, "iccOpenChannel() should get exception"); + } catch(e) {} + try { + icc.iccExchangeAPDU(0, {}); + ok(false, "iccExchangeAPDU() should get exception"); + } catch(e) {} + try { + icc.iccCloseChannel(0); + ok(false, "iccCloseChannel() should get exception"); + } catch(e) {} + + // We should restore the radio status. + setRadioEnabled(true); + iccManager.addEventListener("iccdetected", function oniccdetected(evt) { + iccManager.removeEventListener("iccdetected", oniccdetected); + taskHelper.runNext(); + }); + }); +}); + +// Start test +taskHelper.runNext(); diff --git a/dom/icc/tests/marionette/test_icc_card_state.js b/dom/icc/tests/marionette/test_icc_card_state.js index 5524cea630f..adbed3346e7 100644 --- a/dom/icc/tests/marionette/test_icc_card_state.js +++ b/dom/icc/tests/marionette/test_icc_card_state.js @@ -41,14 +41,12 @@ taskHelper.push(function testCardStateChange() { // Expect to get card state changing to null. if (icc.cardState === null) { icc.removeEventListener("cardstatechange", oncardstatechange); - // We should restore radio status and wait for the cardstatechange event. + // We should restore radio status and expect to get iccdetected event. setRadioEnabled(true); - icc.addEventListener("cardstatechange", function oncardstatechange(evt) { - log("card state changes to " + icc.cardState); - if (icc.cardState === 'ready') { - icc.removeEventListener("cardstatechange", oncardstatechange); - taskHelper.runNext(); - } + iccManager.addEventListener("iccdetected", function oniccdetected(evt) { + log("icc iccdetected: " + evt.iccId); + iccManager.removeEventListener("iccdetected", oniccdetected); + taskHelper.runNext(); }); } }); diff --git a/dom/icc/tests/marionette/test_icc_detected_undetected_event.js b/dom/icc/tests/marionette/test_icc_detected_undetected_event.js new file mode 100644 index 00000000000..a8e270569c9 --- /dev/null +++ b/dom/icc/tests/marionette/test_icc_detected_undetected_event.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 30000; +MARIONETTE_HEAD_JS = "icc_header.js"; + +function setRadioEnabled(enabled) { + SpecialPowers.addPermission("settings-write", true, document); + + // TODO: Bug 856553 - [B2G] RIL: need an API to enable/disable radio + let settings = navigator.mozSettings; + let setLock = settings.createLock(); + let obj = { + "ril.radio.disabled": !enabled + }; + let setReq = setLock.set(obj); + + setReq.addEventListener("success", function onSetSuccess() { + log("set 'ril.radio.disabled' to " + enabled); + }); + + setReq.addEventListener("error", function onSetError() { + ok(false, "cannot set 'ril.radio.disabled' to " + enabled); + }); + + SpecialPowers.removePermission("settings-write", document); +} + +/* Test iccundetected event */ +taskHelper.push(function testIccUndetectedEvent() { + setRadioEnabled(false); + iccManager.addEventListener("iccundetected", function oniccundetected(evt) { + log("got icc undetected event"); + iccManager.removeEventListener("iccundetected", oniccundetected); + + // TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for + // multi-sim + // In single sim scenario, there is only one sim card, we can use below way + // to check iccIds. + is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected"); + is(iccManager.iccIds.length, 0, + "iccIds.length becomes to " + iccManager.iccIds.length); + is(iccManager.getIccById(evt.iccId), null, + "should not get a valid icc object here"); + + taskHelper.runNext(); + }); +}); + +/* Test iccdetected event */ +taskHelper.push(function testIccDetectedEvent() { + setRadioEnabled(true); + iccManager.addEventListener("iccdetected", function oniccdetected(evt) { + log("got icc detected event"); + iccManager.removeEventListener("iccdetected", oniccdetected); + + // TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for + // multi-sim + // In single sim scenario, there is only one sim card, we can use below way + // to check iccIds. + is(evt.iccId, iccId, "icc " + evt.iccId + " is detected"); + is(iccManager.iccIds.length, 1, + "iccIds.length becomes to " + iccManager.iccIds.length); + ok(iccManager.getIccById(evt.iccId) instanceof MozIcc, + "should get a valid icc object here"); + + taskHelper.runNext(); + }); +}); + +// Start test +taskHelper.runNext(); diff --git a/dom/icc/tests/marionette/test_icc_info.js b/dom/icc/tests/marionette/test_icc_info.js index 3940ccae2f3..16619bd6bad 100644 --- a/dom/icc/tests/marionette/test_icc_info.js +++ b/dom/icc/tests/marionette/test_icc_info.js @@ -96,14 +96,12 @@ taskHelper.push(function testCardIsNotReady() { // Expect iccInfo changes to null if (icc.iccInfo === null) { icc.removeEventListener("iccinfochange", oniccinfochange); - // We should restore radio status and wait for the cardstatechange event. + // We should restore radio status and expect to get iccdetected event. setRadioEnabled(true); - icc.addEventListener("cardstatechange", function oncardstatechange(evt) { - log("card state changes to " + icc.cardState); - if (icc.cardState === 'ready') { - icc.removeEventListener("cardstatechange", oncardstatechange); - taskHelper.runNext(); - } + iccManager.addEventListener("iccdetected", function oniccdetected(evt) { + log("icc detected: " + evt.iccId); + iccManager.removeEventListener("iccdetected", oniccdetected); + taskHelper.runNext(); }); } }); diff --git a/dom/icc/tests/marionette/test_stk_display_text.js b/dom/icc/tests/marionette/test_stk_display_text.js index d8ce3cf5033..61f76054f24 100644 --- a/dom/icc/tests/marionette/test_stk_display_text.js +++ b/dom/icc/tests/marionette/test_stk_display_text.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testDisplayText(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_DISPLAY_TEXT, expect.name); + is(command.typeOfCommand, iccManager.STK_CMD_DISPLAY_TEXT, expect.name); is(command.options.text, expect.text, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); is(command.options.userClear, expect.userClear, expect.name); @@ -87,7 +87,7 @@ let tests = [ commandQualifier: 0x80, text: "10 Second", userClear: true, - duration: {timeUnit: icc.STK_TIME_UNIT_SECOND, + duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND, timeInterval: 0x0A}}}, ]; diff --git a/dom/icc/tests/marionette/test_stk_get_inkey.js b/dom/icc/tests/marionette/test_stk_get_inkey.js index 7620262c0d1..f74f1075116 100644 --- a/dom/icc/tests/marionette/test_stk_get_inkey.js +++ b/dom/icc/tests/marionette/test_stk_get_inkey.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testGetInKey(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_GET_INKEY, expect.name); + is(command.typeOfCommand, iccManager.STK_CMD_GET_INKEY, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); is(command.options.text, expect.text, expect.name); is(command.options.isAlphabet, expect.isAlphabet, expect.name); @@ -98,7 +98,7 @@ let tests = [ expect: {name: "get_inkey_cmd_14", commandQualifier: 0x00, text: "Enter \"+\"", - duration: {timeUnit: icc.STK_TIME_UNIT_SECOND, + duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND, timeInterval: 0x0A}}}, ]; diff --git a/dom/icc/tests/marionette/test_stk_get_input.js b/dom/icc/tests/marionette/test_stk_get_input.js index 2de92e5fe14..ef44880776b 100644 --- a/dom/icc/tests/marionette/test_stk_get_input.js +++ b/dom/icc/tests/marionette/test_stk_get_input.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testGetInput(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_GET_INPUT, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_launch_browser.js b/dom/icc/tests/marionette/test_stk_launch_browser.js index 416b7112c30..0888f42ca75 100644 --- a/dom/icc/tests/marionette/test_stk_launch_browser.js +++ b/dom/icc/tests/marionette/test_stk_launch_browser.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testLaunchBrowser(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_LAUNCH_BROWSER, expect.name); + is(command.typeOfCommand, iccManager.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) { diff --git a/dom/icc/tests/marionette/test_stk_poll_off.js b/dom/icc/tests/marionette/test_stk_poll_off.js index 166007d9f9a..8f3d32abef3 100644 --- a/dom/icc/tests/marionette/test_stk_poll_off.js +++ b/dom/icc/tests/marionette/test_stk_poll_off.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testPollOff(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_POLL_OFF, expect.name); + is(command.typeOfCommand, iccManager.STK_CMD_POLL_OFF, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_proactive_command.js b/dom/icc/tests/marionette/test_stk_proactive_command.js index b10e2be0fe9..c78093327df 100644 --- a/dom/icc/tests/marionette/test_stk_proactive_command.js +++ b/dom/icc/tests/marionette/test_stk_proactive_command.js @@ -5,47 +5,47 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testLocalInfoLocation(cmd) { log("STK CMD " + JSON.stringify(cmd)); - is(cmd.typeOfCommand, icc.STK_CMD_PROVIDE_LOCAL_INFO); + is(cmd.typeOfCommand, iccManager.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); + is(cmd.commandQualifier, iccManager.STK_LOCAL_INFO_LOCATION_INFO); + is(cmd.options.localInfoType, iccManager.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.typeOfCommand, iccManager.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); + is(cmd.commandQualifier, iccManager.STK_LOCAL_INFO_IMEI); + is(cmd.options.localInfoType, iccManager.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.typeOfCommand, iccManager.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); + is(cmd.commandQualifier, iccManager.STK_LOCAL_INFO_DATE_TIME_ZONE); + is(cmd.options.localInfoType, iccManager.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.typeOfCommand, iccManager.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); + is(cmd.commandQualifier, iccManager.STK_LOCAL_INFO_LANGUAGE); + is(cmd.options.localInfoType, iccManager.STK_LOCAL_INFO_LANGUAGE); runNextTest(); } function testRefresh(cmd) { log("STK CMD " + JSON.stringify(cmd)); - is(cmd.typeOfCommand, icc.STK_CMD_REFRESH); + is(cmd.typeOfCommand, iccManager.STK_CMD_REFRESH); is(cmd.commandNumber, 0x01); is(cmd.commandQualifier, 0x01); is(cmd.options, null); @@ -55,10 +55,10 @@ function testRefresh(cmd) { function testTimerManagementStart(cmd) { log("STK CMD " + JSON.stringify(cmd)); - is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT); + is(cmd.typeOfCommand, iccManager.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.commandQualifier, iccManager.STK_TIMER_START); + is(cmd.options.timerAction, iccManager.STK_TIMER_START); is(cmd.options.timerId, 0x01); is(cmd.options.timerValue, (0x01 * 60 * 60) + (0x02 * 60) + 0x03); @@ -67,10 +67,10 @@ function testTimerManagementStart(cmd) { function testTimerManagementDeactivate(cmd) { log("STK CMD " + JSON.stringify(cmd)); - is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT); + is(cmd.typeOfCommand, iccManager.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.commandQualifier, iccManager.STK_TIMER_DEACTIVATE); + is(cmd.options.timerAction, iccManager.STK_TIMER_DEACTIVATE); is(cmd.options.timerId, 0x04); runNextTest(); @@ -78,10 +78,10 @@ function testTimerManagementDeactivate(cmd) { function testTimerManagementGetCurrentValue(cmd) { log("STK CMD " + JSON.stringify(cmd)); - is(cmd.typeOfCommand, icc.STK_CMD_TIMER_MANAGEMENT); + is(cmd.typeOfCommand, iccManager.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.commandQualifier, iccManager.STK_TIMER_GET_CURRENT_VALUE); + is(cmd.options.timerAction, iccManager.STK_TIMER_GET_CURRENT_VALUE); is(cmd.options.timerId, 0x08); runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_refresh.js b/dom/icc/tests/marionette/test_stk_refresh.js index 5a137a67227..bd1add02af1 100644 --- a/dom/icc/tests/marionette/test_stk_refresh.js +++ b/dom/icc/tests/marionette/test_stk_refresh.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testRefresh(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_REFRESH, expect.name); + is(command.typeOfCommand, iccManager.STK_CMD_REFRESH, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); runNextTest(); diff --git a/dom/icc/tests/marionette/test_stk_select_item.js b/dom/icc/tests/marionette/test_stk_select_item.js index 413b09c23a6..9150a8a6e45 100644 --- a/dom/icc/tests/marionette/test_stk_select_item.js +++ b/dom/icc/tests/marionette/test_stk_select_item.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSelectItem(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SELECT_ITEM, expect.name); + is(command.typeOfCommand, iccManager.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) { diff --git a/dom/icc/tests/marionette/test_stk_send_dtmf.js b/dom/icc/tests/marionette/test_stk_send_dtmf.js index f12e7cb540f..9760b5849bd 100644 --- a/dom/icc/tests/marionette/test_stk_send_dtmf.js +++ b/dom/icc/tests/marionette/test_stk_send_dtmf.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSendDTMF(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SEND_DTMF, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_send_sms.js b/dom/icc/tests/marionette/test_stk_send_sms.js index ec428cdc9fe..dd12cb9cf11 100644 --- a/dom/icc/tests/marionette/test_stk_send_sms.js +++ b/dom/icc/tests/marionette/test_stk_send_sms.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSendSMS(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SEND_SMS, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_send_ss.js b/dom/icc/tests/marionette/test_stk_send_ss.js index 8385d082f12..48dfcdc047d 100644 --- a/dom/icc/tests/marionette/test_stk_send_ss.js +++ b/dom/icc/tests/marionette/test_stk_send_ss.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSendSS(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SEND_SS, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_send_ussd.js b/dom/icc/tests/marionette/test_stk_send_ussd.js index b2cfa81b39a..41812a63056 100644 --- a/dom/icc/tests/marionette/test_stk_send_ussd.js +++ b/dom/icc/tests/marionette/test_stk_send_ussd.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSendUSSD(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SEND_USSD, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_setup_call.js b/dom/icc/tests/marionette/test_stk_setup_call.js index c4c278fdf7b..e70f1a76e6f 100644 --- a/dom/icc/tests/marionette/test_stk_setup_call.js +++ b/dom/icc/tests/marionette/test_stk_setup_call.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSetupCall(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SET_UP_CALL, expect.name); + is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_CALL, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); is(command.options.confirmMessage, expect.confirmMessage, expect.name); is(command.options.address, expect.address, expect.name); @@ -68,7 +68,7 @@ let tests = [ commandQualifier: 0x01, confirmMessage: "Duration", address: "+012340123456,1,2", - duration: {timeUnit: icc.STK_TIME_UNIT_SECOND, + duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND, timeInterval: 0x0A}}}, {command: "d028810301100082028183850c434f4e4649524d4154494f4e8609911032042143651c2c850443414c4c", func: testSetupCall, @@ -336,7 +336,7 @@ let tests = [ commandQualifier: 0x00, confirmMessage: "Not busy", address: "+012340123456,1,2", - duration: {timeUnit: icc.STK_TIME_UNIT_SECOND, + duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND, timeInterval: 0x0A}}}, ]; diff --git a/dom/icc/tests/marionette/test_stk_setup_event_list.js b/dom/icc/tests/marionette/test_stk_setup_event_list.js index 24eff85cfe4..ac3033776f0 100644 --- a/dom/icc/tests/marionette/test_stk_setup_event_list.js +++ b/dom/icc/tests/marionette/test_stk_setup_event_list.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSetupEventList(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SET_UP_EVENT_LIST, expect.name); + is(command.typeOfCommand, iccManager.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); diff --git a/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js b/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js index ae513cb1713..6e4b5c912a1 100644 --- a/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js +++ b/dom/icc/tests/marionette/test_stk_setup_idle_mode_text.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; 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.typeOfCommand, iccManager.STK_CMD_SET_UP_IDLE_MODE_TEXT, expect.name); is(command.commandQualifier, expect.commandQualifier, expect.name); is(command.options.text, expect.text, expect.name); diff --git a/dom/icc/tests/marionette/test_stk_setup_menu.js b/dom/icc/tests/marionette/test_stk_setup_menu.js index 11074590d0d..d42e9ff346a 100644 --- a/dom/icc/tests/marionette/test_stk_setup_menu.js +++ b/dom/icc/tests/marionette/test_stk_setup_menu.js @@ -5,7 +5,7 @@ MARIONETTE_HEAD_JS = "stk_helper.js"; function testSetupMenu(command, expect) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SET_UP_MENU, expect.name); + is(command.typeOfCommand, iccManager.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) { @@ -22,14 +22,14 @@ function isFirstMenuItemNull(command) { function testInitialSetupMenu(command) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SET_UP_MENU); + is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_MENU); is(isFirstMenuItemNull(command), false); runNextTest(); } function testRemoveSetupMenu(command) { log("STK CMD " + JSON.stringify(command)); - is(command.typeOfCommand, icc.STK_CMD_SET_UP_MENU); + is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_MENU); is(isFirstMenuItemNull(command), true); runNextTest(); diff --git a/dom/telephony/test/marionette/test_outgoing_radio_off.js b/dom/telephony/test/marionette/test_outgoing_radio_off.js index 28bd699e1ae..35faa87e2e9 100644 --- a/dom/telephony/test/marionette/test_outgoing_radio_off.js +++ b/dom/telephony/test/marionette/test_outgoing_radio_off.js @@ -26,14 +26,13 @@ function changeSetting(key, value, callback) { function setRadioEnabled(enabled, callback) { changeSetting("ril.radio.disabled", !enabled, function() { - icc.addEventListener("cardstatechange", function handler() { - // Wait until card state changes to "ready" after turning on radio. - // Wait until card state changes to "not-ready" after turning off radio. - if ((enabled && icc.cardState == "ready") || - (!enabled && icc.cardState != "ready")) { - icc.removeEventListener("cardstatechange", handler); - callback(); - } + // Wait for iccdetected event after turning on radio. + // Wait for iccundetected event after turning off radio. + let event = (enabled) ? "iccdetected" : "iccundetected"; + icc.addEventListener(event, function handler(evt) { + log(event + ": " + evt.iccId); + icc.removeEventListener(event, handler); + callback(); }); }); }