dom/icc/tests/marionette/test_icc_access_invalid_object.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial