michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 30000; michael@0: MARIONETTE_HEAD_JS = "icc_header.js"; michael@0: michael@0: function setRadioEnabled(enabled) { michael@0: let connection = navigator.mozMobileConnections[0]; michael@0: ok(connection); michael@0: michael@0: let request = connection.setRadioEnabled(enabled); michael@0: michael@0: request.onsuccess = function onsuccess() { michael@0: log('setRadioEnabled: ' + enabled); michael@0: }; michael@0: michael@0: request.onerror = function onerror() { michael@0: ok(false, "setRadioEnabled should be ok"); michael@0: }; michael@0: } michael@0: michael@0: /* Test access invalid icc object */ michael@0: taskHelper.push(function testAccessRemovedIccObject() { michael@0: setRadioEnabled(false); michael@0: iccManager.addEventListener("iccundetected", function oniccundetected(evt) { michael@0: log("got icc undetected event"); michael@0: iccManager.removeEventListener("iccundetected", oniccundetected); michael@0: is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected"); michael@0: michael@0: // Test access iccInfo. michael@0: try { michael@0: is(icc.iccInfo, null, "iccInfo: expect to get null"); michael@0: } catch(e) { michael@0: ok(false, "access iccInfo should not get exception"); michael@0: } michael@0: michael@0: // Test access cardState. michael@0: try { michael@0: is(icc.cardState, null, "cardState: expect to get null"); michael@0: } catch(e) { michael@0: ok(false, "access cardState should not get exception"); michael@0: } michael@0: michael@0: // Test STK related function. michael@0: try { michael@0: icc.sendStkResponse({}, {}); michael@0: ok(false, "sendStkResponse() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.sendStkMenuSelection(0, false); michael@0: ok(false, "sendStkMenuSelection() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.sendStkTimerExpiration({}); michael@0: ok(false, "sendStkTimerExpiration() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.sendStkEventDownload({}); michael@0: ok(false, "sendStkEventDownload() should get exception"); michael@0: } catch(e) {} michael@0: michael@0: // Test card lock related function. michael@0: try { michael@0: icc.getCardLock(""); michael@0: ok(false, "getCardLock() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.unlockCardLock({}); michael@0: ok(false, "unlockCardLock() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.setCardLock({}); michael@0: ok(false, "setCardLock() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.getCardLockRetryCount(""); michael@0: ok(false, "getCardLockRetryCount() should get exception"); michael@0: } catch(e) {} michael@0: michael@0: // Test contact related function. michael@0: try { michael@0: icc.readContacts(""); michael@0: ok(false, "readContacts() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.updateContact("", {}); michael@0: ok(false, "updateContact() should get exception"); michael@0: } catch(e) {} michael@0: michael@0: // Test secure element related function. michael@0: try { michael@0: icc.iccOpenChannel(""); michael@0: ok(false, "iccOpenChannel() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.iccExchangeAPDU(0, {}); michael@0: ok(false, "iccExchangeAPDU() should get exception"); michael@0: } catch(e) {} michael@0: try { michael@0: icc.iccCloseChannel(0); michael@0: ok(false, "iccCloseChannel() should get exception"); michael@0: } catch(e) {} michael@0: michael@0: // We should restore the radio status. michael@0: setRadioEnabled(true); michael@0: iccManager.addEventListener("iccdetected", function oniccdetected(evt) { michael@0: iccManager.removeEventListener("iccdetected", oniccdetected); michael@0: taskHelper.runNext(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Start test michael@0: taskHelper.runNext();