Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | MARIONETTE_TIMEOUT = 30000; |
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 | let pendingEmulatorCmdCount = 0; |
michael@0 | 28 | function sendStkPduToEmulator(command, func, expect) { |
michael@0 | 29 | ++pendingEmulatorCmdCount; |
michael@0 | 30 | |
michael@0 | 31 | runEmulatorCmd(command, function(result) { |
michael@0 | 32 | --pendingEmulatorCmdCount; |
michael@0 | 33 | is(result[0], "OK"); |
michael@0 | 34 | }); |
michael@0 | 35 | |
michael@0 | 36 | icc.onstkcommand = function(evt) { |
michael@0 | 37 | if (expect) { |
michael@0 | 38 | func(evt.command, expect); |
michael@0 | 39 | } else { |
michael@0 | 40 | func(evt.command); |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function runNextTest() { |
michael@0 | 46 | let test = tests.pop(); |
michael@0 | 47 | if (!test) { |
michael@0 | 48 | cleanUp(); |
michael@0 | 49 | return; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | let command = "stk pdu " + test.command; |
michael@0 | 53 | sendStkPduToEmulator(command, test.func, test.expect); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function cleanUp() { |
michael@0 | 57 | if (pendingEmulatorCmdCount) { |
michael@0 | 58 | window.setTimeout(cleanUp, 100); |
michael@0 | 59 | return; |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | SpecialPowers.removePermission("mobileconnection", document); |
michael@0 | 63 | finish(); |
michael@0 | 64 | } |