mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
MARIONETTE_TIMEOUT = 30000;
|
|
|
|
SpecialPowers.addPermission("mobileconnection", true, document);
|
|
|
|
let icc = navigator.mozMobileConnection.icc;
|
|
ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
|
|
|
|
function testPollOff(command, expect) {
|
|
log("STK CMD " + JSON.stringify(command));
|
|
is(command.typeOfCommand, icc.STK_CMD_POLL_OFF, expect.name);
|
|
is(command.commandQualifier, expect.commandQualifier, expect.name);
|
|
|
|
runNextTest();
|
|
}
|
|
|
|
let tests = [
|
|
{command: "d009810301040082028182",
|
|
func: testPollOff,
|
|
expect: {name: "pull_off_cmd_1",
|
|
commandQualifier: 0x00}}
|
|
];
|
|
|
|
let pendingEmulatorCmdCount = 0;
|
|
function sendStkPduToEmulator(command, func, expect) {
|
|
++pendingEmulatorCmdCount;
|
|
|
|
runEmulatorCmd(command, function (result) {
|
|
--pendingEmulatorCmdCount;
|
|
is(result[0], "OK");
|
|
});
|
|
|
|
icc.onstkcommand = function (evt) {
|
|
func(evt.command, expect);
|
|
}
|
|
}
|
|
|
|
function runNextTest() {
|
|
let test = tests.pop();
|
|
if (!test) {
|
|
cleanUp();
|
|
return;
|
|
}
|
|
|
|
let command = "stk pdu " + test.command;
|
|
sendStkPduToEmulator(command, test.func, test.expect)
|
|
}
|
|
|
|
function cleanUp() {
|
|
if (pendingEmulatorCmdCount) {
|
|
window.setTimeout(cleanUp, 100);
|
|
return;
|
|
}
|
|
|
|
SpecialPowers.removePermission("mobileconnection", document);
|
|
finish();
|
|
}
|
|
|
|
runNextTest();
|