dom/icc/tests/marionette/stk_helper.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 30000;
     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 let pendingEmulatorCmdCount = 0;
    28 function sendStkPduToEmulator(command, func, expect) {
    29   ++pendingEmulatorCmdCount;
    31   runEmulatorCmd(command, function(result) {
    32     --pendingEmulatorCmdCount;
    33     is(result[0], "OK");
    34   });
    36   icc.onstkcommand = function(evt) {
    37     if (expect) {
    38       func(evt.command, expect);
    39     } else {
    40       func(evt.command);
    41     }
    42   }
    43 }
    45 function runNextTest() {
    46   let test = tests.pop();
    47   if (!test) {
    48     cleanUp();
    49     return;
    50   }
    52   let command = "stk pdu " + test.command;
    53   sendStkPduToEmulator(command, test.func, test.expect);
    54 }
    56 function cleanUp() {
    57   if (pendingEmulatorCmdCount) {
    58     window.setTimeout(cleanUp, 100);
    59     return;
    60   }
    62   SpecialPowers.removePermission("mobileconnection", document);
    63   finish();
    64 }

mercurial