1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/icc/tests/marionette/test_icc_access_invalid_object.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 30000; 1.8 +MARIONETTE_HEAD_JS = "icc_header.js"; 1.9 + 1.10 +function setRadioEnabled(enabled) { 1.11 + let connection = navigator.mozMobileConnections[0]; 1.12 + ok(connection); 1.13 + 1.14 + let request = connection.setRadioEnabled(enabled); 1.15 + 1.16 + request.onsuccess = function onsuccess() { 1.17 + log('setRadioEnabled: ' + enabled); 1.18 + }; 1.19 + 1.20 + request.onerror = function onerror() { 1.21 + ok(false, "setRadioEnabled should be ok"); 1.22 + }; 1.23 +} 1.24 + 1.25 +/* Test access invalid icc object */ 1.26 +taskHelper.push(function testAccessRemovedIccObject() { 1.27 + setRadioEnabled(false); 1.28 + iccManager.addEventListener("iccundetected", function oniccundetected(evt) { 1.29 + log("got icc undetected event"); 1.30 + iccManager.removeEventListener("iccundetected", oniccundetected); 1.31 + is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected"); 1.32 + 1.33 + // Test access iccInfo. 1.34 + try { 1.35 + is(icc.iccInfo, null, "iccInfo: expect to get null"); 1.36 + } catch(e) { 1.37 + ok(false, "access iccInfo should not get exception"); 1.38 + } 1.39 + 1.40 + // Test access cardState. 1.41 + try { 1.42 + is(icc.cardState, null, "cardState: expect to get null"); 1.43 + } catch(e) { 1.44 + ok(false, "access cardState should not get exception"); 1.45 + } 1.46 + 1.47 + // Test STK related function. 1.48 + try { 1.49 + icc.sendStkResponse({}, {}); 1.50 + ok(false, "sendStkResponse() should get exception"); 1.51 + } catch(e) {} 1.52 + try { 1.53 + icc.sendStkMenuSelection(0, false); 1.54 + ok(false, "sendStkMenuSelection() should get exception"); 1.55 + } catch(e) {} 1.56 + try { 1.57 + icc.sendStkTimerExpiration({}); 1.58 + ok(false, "sendStkTimerExpiration() should get exception"); 1.59 + } catch(e) {} 1.60 + try { 1.61 + icc.sendStkEventDownload({}); 1.62 + ok(false, "sendStkEventDownload() should get exception"); 1.63 + } catch(e) {} 1.64 + 1.65 + // Test card lock related function. 1.66 + try { 1.67 + icc.getCardLock(""); 1.68 + ok(false, "getCardLock() should get exception"); 1.69 + } catch(e) {} 1.70 + try { 1.71 + icc.unlockCardLock({}); 1.72 + ok(false, "unlockCardLock() should get exception"); 1.73 + } catch(e) {} 1.74 + try { 1.75 + icc.setCardLock({}); 1.76 + ok(false, "setCardLock() should get exception"); 1.77 + } catch(e) {} 1.78 + try { 1.79 + icc.getCardLockRetryCount(""); 1.80 + ok(false, "getCardLockRetryCount() should get exception"); 1.81 + } catch(e) {} 1.82 + 1.83 + // Test contact related function. 1.84 + try { 1.85 + icc.readContacts(""); 1.86 + ok(false, "readContacts() should get exception"); 1.87 + } catch(e) {} 1.88 + try { 1.89 + icc.updateContact("", {}); 1.90 + ok(false, "updateContact() should get exception"); 1.91 + } catch(e) {} 1.92 + 1.93 + // Test secure element related function. 1.94 + try { 1.95 + icc.iccOpenChannel(""); 1.96 + ok(false, "iccOpenChannel() should get exception"); 1.97 + } catch(e) {} 1.98 + try { 1.99 + icc.iccExchangeAPDU(0, {}); 1.100 + ok(false, "iccExchangeAPDU() should get exception"); 1.101 + } catch(e) {} 1.102 + try { 1.103 + icc.iccCloseChannel(0); 1.104 + ok(false, "iccCloseChannel() should get exception"); 1.105 + } catch(e) {} 1.106 + 1.107 + // We should restore the radio status. 1.108 + setRadioEnabled(true); 1.109 + iccManager.addEventListener("iccdetected", function oniccdetected(evt) { 1.110 + iccManager.removeEventListener("iccdetected", oniccdetected); 1.111 + taskHelper.runNext(); 1.112 + }); 1.113 + }); 1.114 +}); 1.115 + 1.116 +// Start test 1.117 +taskHelper.runNext();