michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers; 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: /* Remove permission and execute finish() */ michael@0: let cleanUp = function() { michael@0: SpecialPowers.removePermission("mobileconnection", document); michael@0: finish(); michael@0: }; michael@0: michael@0: /* Helper for tasks */ michael@0: let taskHelper = { michael@0: tasks: [], michael@0: michael@0: push: function(task) { michael@0: this.tasks.push(task); michael@0: }, michael@0: michael@0: runNext: function() { michael@0: let task = this.tasks.shift(); michael@0: if (!task) { michael@0: cleanUp(); michael@0: return; michael@0: } michael@0: michael@0: if (typeof task === "function") { michael@0: task(); michael@0: } michael@0: }, michael@0: }; michael@0: michael@0: /* Helper for emulator console command */ michael@0: let emulatorHelper = { michael@0: pendingCommandCount: 0, michael@0: michael@0: sendCommand: function(cmd, callback) { michael@0: this.pendingCommandCount++; michael@0: runEmulatorCmd(cmd, function(result) { michael@0: this.pendingCommandCount--; michael@0: is(result[result.length - 1], "OK"); michael@0: michael@0: if (callback && typeof callback === "function") { michael@0: callback(result); michael@0: } michael@0: }); michael@0: }, michael@0: };