зеркало из https://github.com/mozilla/gecko-dev.git
Bug 939038 - [DSDS] Follow-up to Bug 814629: add test case for iccchange event. r=hsinyi
This commit is contained in:
Родитель
91aadf00ed
Коммит
4cb590d2bb
|
@ -20,4 +20,5 @@ disabled = Bug 808783
|
|||
[test_call_barring_change_password.js]
|
||||
[test_mobile_set_radio.js]
|
||||
[test_mobile_last_known_network.js]
|
||||
[test_mobile_icc_change.js]
|
||||
[test_mobile_connections_array_uninitialized.js]
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 30000;
|
||||
|
||||
SpecialPowers.addPermission("mobileconnection", true, document);
|
||||
|
||||
// Permission changes can't change existing Navigator.prototype
|
||||
// objects, so grab our objects from a new Navigator
|
||||
let ifr = document.createElement("iframe");
|
||||
let connection;
|
||||
ifr.onload = function() {
|
||||
connection = ifr.contentWindow.navigator.mozMobileConnections[0];
|
||||
ok(connection instanceof ifr.contentWindow.MozMobileConnection,
|
||||
"connection is instanceof " + connection.constructor);
|
||||
|
||||
// The emulator's hard coded iccid value.
|
||||
// See it here {B2G_HOME}/external/qemu/telephony/sim_card.c.
|
||||
is(connection.iccId, 89014103211118510720);
|
||||
|
||||
runNextTest();
|
||||
};
|
||||
document.body.appendChild(ifr);
|
||||
|
||||
function waitForIccChange(callback) {
|
||||
connection.addEventListener("iccchange", function handler() {
|
||||
connection.removeEventListener("iccchange", handler);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function setRadioEnabled(enabled) {
|
||||
let request = connection.setRadioEnabled(enabled);
|
||||
|
||||
request.onsuccess = function onsuccess() {
|
||||
log('setRadioEnabled: ' + enabled);
|
||||
};
|
||||
|
||||
request.onerror = function onerror() {
|
||||
ok(false, "setRadioEnabled should be ok");
|
||||
};
|
||||
}
|
||||
|
||||
function testIccChangeOnRadioPowerOff() {
|
||||
// Turn off radio
|
||||
setRadioEnabled(false);
|
||||
|
||||
waitForIccChange(function() {
|
||||
is(connection.iccId, null);
|
||||
runNextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function testIccChangeOnRadioPowerOn() {
|
||||
// Turn on radio
|
||||
setRadioEnabled(true);
|
||||
|
||||
waitForIccChange(function() {
|
||||
// The emulator's hard coded iccid value.
|
||||
is(connection.iccId, 89014103211118510720);
|
||||
runNextTest();
|
||||
});
|
||||
}
|
||||
|
||||
let tests = [
|
||||
testIccChangeOnRadioPowerOff,
|
||||
testIccChangeOnRadioPowerOn
|
||||
];
|
||||
|
||||
function runNextTest() {
|
||||
let test = tests.shift();
|
||||
if (!test) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
test();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.removePermission("mobileconnection", document);
|
||||
|
||||
finish();
|
||||
}
|
Загрузка…
Ссылка в новой задаче