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

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

mercurial