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: michael@0: SpecialPowers.addPermission("mobileconnection", true, document); michael@0: michael@0: let iccManager = navigator.mozIccManager; michael@0: ok(iccManager instanceof MozIccManager, michael@0: "iccManager is instanceof " + iccManager.constructor); michael@0: michael@0: // TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for michael@0: // multi-sim michael@0: // In single sim scenario, there is only one sim card, we can use below way to michael@0: // check iccId and get icc object. But in multi-sim, the index of iccIds may michael@0: // not map to sim slot directly, we should have a better way to handle this. michael@0: let iccIds = iccManager.iccIds; michael@0: ok(Array.isArray(iccIds), "iccIds is an array"); michael@0: ok(iccIds.length > 0, "iccIds.length is " + iccIds.length); michael@0: michael@0: let iccId = iccIds[0]; michael@0: is(iccId, "89014103211118510720", "iccId is " + iccId); michael@0: michael@0: let icc = iccManager.getIccById(iccId); michael@0: ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor); michael@0: michael@0: let pendingEmulatorCmdCount = 0; michael@0: function sendStkPduToEmulator(command, func, expect) { michael@0: ++pendingEmulatorCmdCount; michael@0: michael@0: runEmulatorCmd(command, function(result) { michael@0: --pendingEmulatorCmdCount; michael@0: is(result[0], "OK"); michael@0: }); michael@0: michael@0: icc.onstkcommand = function(evt) { michael@0: if (expect) { michael@0: func(evt.command, expect); michael@0: } else { michael@0: func(evt.command); michael@0: } michael@0: } michael@0: } michael@0: michael@0: function runNextTest() { michael@0: let test = tests.pop(); michael@0: if (!test) { michael@0: cleanUp(); michael@0: return; michael@0: } michael@0: michael@0: let command = "stk pdu " + test.command; michael@0: sendStkPduToEmulator(command, test.func, test.expect); michael@0: } michael@0: michael@0: function cleanUp() { michael@0: if (pendingEmulatorCmdCount) { michael@0: window.setTimeout(cleanUp, 100); michael@0: return; michael@0: } michael@0: michael@0: SpecialPowers.removePermission("mobileconnection", document); michael@0: finish(); michael@0: }