dom/icc/tests/marionette/icc_header.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:fcb92cb0e5f8
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
5
6 SpecialPowers.addPermission("mobileconnection", true, document);
7
8 let iccManager = navigator.mozIccManager;
9 ok(iccManager instanceof MozIccManager,
10 "iccManager is instanceof " + iccManager.constructor);
11
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);
20
21 let iccId = iccIds[0];
22 is(iccId, "89014103211118510720", "iccId is " + iccId);
23
24 let icc = iccManager.getIccById(iccId);
25 ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor);
26
27 /* Remove permission and execute finish() */
28 let cleanUp = function() {
29 SpecialPowers.removePermission("mobileconnection", document);
30 finish();
31 };
32
33 /* Helper for tasks */
34 let taskHelper = {
35 tasks: [],
36
37 push: function(task) {
38 this.tasks.push(task);
39 },
40
41 runNext: function() {
42 let task = this.tasks.shift();
43 if (!task) {
44 cleanUp();
45 return;
46 }
47
48 if (typeof task === "function") {
49 task();
50 }
51 },
52 };
53
54 /* Helper for emulator console command */
55 let emulatorHelper = {
56 pendingCommandCount: 0,
57
58 sendCommand: function(cmd, callback) {
59 this.pendingCommandCount++;
60 runEmulatorCmd(cmd, function(result) {
61 this.pendingCommandCount--;
62 is(result[result.length - 1], "OK");
63
64 if (callback && typeof callback === "function") {
65 callback(result);
66 }
67 });
68 },
69 };

mercurial