|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 30000; |
|
5 MARIONETTE_HEAD_JS = "icc_header.js"; |
|
6 |
|
7 function setRadioEnabled(enabled) { |
|
8 let connection = navigator.mozMobileConnections[0]; |
|
9 ok(connection); |
|
10 |
|
11 let request = connection.setRadioEnabled(enabled); |
|
12 |
|
13 request.onsuccess = function onsuccess() { |
|
14 log('setRadioEnabled: ' + enabled); |
|
15 }; |
|
16 |
|
17 request.onerror = function onerror() { |
|
18 ok(false, "setRadioEnabled should be ok"); |
|
19 }; |
|
20 } |
|
21 |
|
22 /* Test access invalid icc object */ |
|
23 taskHelper.push(function testAccessRemovedIccObject() { |
|
24 setRadioEnabled(false); |
|
25 iccManager.addEventListener("iccundetected", function oniccundetected(evt) { |
|
26 log("got icc undetected event"); |
|
27 iccManager.removeEventListener("iccundetected", oniccundetected); |
|
28 is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected"); |
|
29 |
|
30 // Test access iccInfo. |
|
31 try { |
|
32 is(icc.iccInfo, null, "iccInfo: expect to get null"); |
|
33 } catch(e) { |
|
34 ok(false, "access iccInfo should not get exception"); |
|
35 } |
|
36 |
|
37 // Test access cardState. |
|
38 try { |
|
39 is(icc.cardState, null, "cardState: expect to get null"); |
|
40 } catch(e) { |
|
41 ok(false, "access cardState should not get exception"); |
|
42 } |
|
43 |
|
44 // Test STK related function. |
|
45 try { |
|
46 icc.sendStkResponse({}, {}); |
|
47 ok(false, "sendStkResponse() should get exception"); |
|
48 } catch(e) {} |
|
49 try { |
|
50 icc.sendStkMenuSelection(0, false); |
|
51 ok(false, "sendStkMenuSelection() should get exception"); |
|
52 } catch(e) {} |
|
53 try { |
|
54 icc.sendStkTimerExpiration({}); |
|
55 ok(false, "sendStkTimerExpiration() should get exception"); |
|
56 } catch(e) {} |
|
57 try { |
|
58 icc.sendStkEventDownload({}); |
|
59 ok(false, "sendStkEventDownload() should get exception"); |
|
60 } catch(e) {} |
|
61 |
|
62 // Test card lock related function. |
|
63 try { |
|
64 icc.getCardLock(""); |
|
65 ok(false, "getCardLock() should get exception"); |
|
66 } catch(e) {} |
|
67 try { |
|
68 icc.unlockCardLock({}); |
|
69 ok(false, "unlockCardLock() should get exception"); |
|
70 } catch(e) {} |
|
71 try { |
|
72 icc.setCardLock({}); |
|
73 ok(false, "setCardLock() should get exception"); |
|
74 } catch(e) {} |
|
75 try { |
|
76 icc.getCardLockRetryCount(""); |
|
77 ok(false, "getCardLockRetryCount() should get exception"); |
|
78 } catch(e) {} |
|
79 |
|
80 // Test contact related function. |
|
81 try { |
|
82 icc.readContacts(""); |
|
83 ok(false, "readContacts() should get exception"); |
|
84 } catch(e) {} |
|
85 try { |
|
86 icc.updateContact("", {}); |
|
87 ok(false, "updateContact() should get exception"); |
|
88 } catch(e) {} |
|
89 |
|
90 // Test secure element related function. |
|
91 try { |
|
92 icc.iccOpenChannel(""); |
|
93 ok(false, "iccOpenChannel() should get exception"); |
|
94 } catch(e) {} |
|
95 try { |
|
96 icc.iccExchangeAPDU(0, {}); |
|
97 ok(false, "iccExchangeAPDU() should get exception"); |
|
98 } catch(e) {} |
|
99 try { |
|
100 icc.iccCloseChannel(0); |
|
101 ok(false, "iccCloseChannel() should get exception"); |
|
102 } catch(e) {} |
|
103 |
|
104 // We should restore the radio status. |
|
105 setRadioEnabled(true); |
|
106 iccManager.addEventListener("iccdetected", function oniccdetected(evt) { |
|
107 iccManager.removeEventListener("iccdetected", oniccdetected); |
|
108 taskHelper.runNext(); |
|
109 }); |
|
110 }); |
|
111 }); |
|
112 |
|
113 // Start test |
|
114 taskHelper.runNext(); |