dom/icc/tests/marionette/icc_header.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
michael@0 5
michael@0 6 SpecialPowers.addPermission("mobileconnection", true, document);
michael@0 7
michael@0 8 let iccManager = navigator.mozIccManager;
michael@0 9 ok(iccManager instanceof MozIccManager,
michael@0 10 "iccManager is instanceof " + iccManager.constructor);
michael@0 11
michael@0 12 // TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for
michael@0 13 // multi-sim
michael@0 14 // In single sim scenario, there is only one sim card, we can use below way to
michael@0 15 // check iccId and get icc object. But in multi-sim, the index of iccIds may
michael@0 16 // not map to sim slot directly, we should have a better way to handle this.
michael@0 17 let iccIds = iccManager.iccIds;
michael@0 18 ok(Array.isArray(iccIds), "iccIds is an array");
michael@0 19 ok(iccIds.length > 0, "iccIds.length is " + iccIds.length);
michael@0 20
michael@0 21 let iccId = iccIds[0];
michael@0 22 is(iccId, "89014103211118510720", "iccId is " + iccId);
michael@0 23
michael@0 24 let icc = iccManager.getIccById(iccId);
michael@0 25 ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor);
michael@0 26
michael@0 27 /* Remove permission and execute finish() */
michael@0 28 let cleanUp = function() {
michael@0 29 SpecialPowers.removePermission("mobileconnection", document);
michael@0 30 finish();
michael@0 31 };
michael@0 32
michael@0 33 /* Helper for tasks */
michael@0 34 let taskHelper = {
michael@0 35 tasks: [],
michael@0 36
michael@0 37 push: function(task) {
michael@0 38 this.tasks.push(task);
michael@0 39 },
michael@0 40
michael@0 41 runNext: function() {
michael@0 42 let task = this.tasks.shift();
michael@0 43 if (!task) {
michael@0 44 cleanUp();
michael@0 45 return;
michael@0 46 }
michael@0 47
michael@0 48 if (typeof task === "function") {
michael@0 49 task();
michael@0 50 }
michael@0 51 },
michael@0 52 };
michael@0 53
michael@0 54 /* Helper for emulator console command */
michael@0 55 let emulatorHelper = {
michael@0 56 pendingCommandCount: 0,
michael@0 57
michael@0 58 sendCommand: function(cmd, callback) {
michael@0 59 this.pendingCommandCount++;
michael@0 60 runEmulatorCmd(cmd, function(result) {
michael@0 61 this.pendingCommandCount--;
michael@0 62 is(result[result.length - 1], "OK");
michael@0 63
michael@0 64 if (callback && typeof callback === "function") {
michael@0 65 callback(result);
michael@0 66 }
michael@0 67 });
michael@0 68 },
michael@0 69 };

mercurial