mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
7576dae8e6
--HG-- rename : dom/network/interfaces/nsIDOMMobileConnection.idl => dom/mobileconnection/interfaces/nsIDOMMobileConnection.idl rename : dom/network/interfaces/nsIMobileConnectionProvider.idl => dom/mobileconnection/interfaces/nsIMobileConnectionProvider.idl rename : dom/network/tests/marionette/manifest.ini => dom/mobileconnection/tests/marionette/manifest.ini rename : dom/network/tests/marionette/test_call_barring_change_password.js => dom/mobileconnection/tests/marionette/test_call_barring_change_password.js rename : dom/network/tests/marionette/test_call_barring_get_option.js => dom/mobileconnection/tests/marionette/test_call_barring_get_option.js rename : dom/network/tests/marionette/test_call_barring_set_error.js => dom/mobileconnection/tests/marionette/test_call_barring_set_error.js rename : dom/network/tests/marionette/test_mobile_connections_array_uninitialized.js => dom/mobileconnection/tests/marionette/test_mobile_connections_array_uninitialized.js rename : dom/network/tests/marionette/test_mobile_data_connection.js => dom/mobileconnection/tests/marionette/test_mobile_data_connection.js rename : dom/network/tests/marionette/test_mobile_data_location.js => dom/mobileconnection/tests/marionette/test_mobile_data_location.js rename : dom/network/tests/marionette/test_mobile_data_state.js => dom/mobileconnection/tests/marionette/test_mobile_data_state.js rename : dom/network/tests/marionette/test_mobile_icc_change.js => dom/mobileconnection/tests/marionette/test_mobile_icc_change.js rename : dom/network/tests/marionette/test_mobile_last_known_network.js => dom/mobileconnection/tests/marionette/test_mobile_last_known_network.js rename : dom/network/tests/marionette/test_mobile_mmi.js => dom/mobileconnection/tests/marionette/test_mobile_mmi.js rename : dom/network/tests/marionette/test_mobile_networks.js => dom/mobileconnection/tests/marionette/test_mobile_networks.js rename : dom/network/tests/marionette/test_mobile_operator_names.js => dom/mobileconnection/tests/marionette/test_mobile_operator_names.js rename : dom/network/tests/marionette/test_mobile_preferred_network_type.js => dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type.js rename : dom/network/tests/marionette/test_mobile_preferred_network_type_by_setting.js => dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type_by_setting.js rename : dom/network/tests/marionette/test_mobile_roaming_preference.js => dom/mobileconnection/tests/marionette/test_mobile_roaming_preference.js rename : dom/network/tests/marionette/test_mobile_set_radio.js => dom/mobileconnection/tests/marionette/test_mobile_set_radio.js rename : dom/network/tests/marionette/test_mobile_voice_state.js => dom/mobileconnection/tests/marionette/test_mobile_voice_state.js
108 lines
2.9 KiB
JavaScript
108 lines
2.9 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
MARIONETTE_TIMEOUT = 20000;
|
|
|
|
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 mobileConnection;
|
|
ifr.onload = function() {
|
|
mobileConnection = ifr.contentWindow.navigator.mozMobileConnections[0];
|
|
|
|
tasks.run();
|
|
};
|
|
document.body.appendChild(ifr);
|
|
|
|
let tasks = {
|
|
// List of test functions. Each of them should call |tasks.next()| when
|
|
// completed or |tasks.abort()| to jump to the last one.
|
|
_tasks: [],
|
|
_nextTaskIndex: 0,
|
|
|
|
push: function(func) {
|
|
this._tasks.push(func);
|
|
},
|
|
|
|
next: function() {
|
|
let index = this._nextTaskIndex++;
|
|
let task = this._tasks[index];
|
|
try {
|
|
task();
|
|
} catch (ex) {
|
|
ok(false, "test task[" + index + "] throws: " + ex);
|
|
// Run last task as clean up if possible.
|
|
if (index != this._tasks.length - 1) {
|
|
this.abort();
|
|
}
|
|
}
|
|
},
|
|
|
|
abort: function() {
|
|
this._tasks[this._tasks.length - 1]();
|
|
},
|
|
|
|
run: function() {
|
|
this.next();
|
|
}
|
|
};
|
|
|
|
tasks.push(function verifyInitialState() {
|
|
log("Verifying initial state.");
|
|
|
|
ok(mobileConnection instanceof ifr.contentWindow.MozMobileConnection,
|
|
"mobileConnection is instanceof " + mobileConnection.constructor);
|
|
|
|
tasks.next();
|
|
});
|
|
|
|
tasks.push(function testGettingIMEI() {
|
|
log("Test *#06# ...");
|
|
|
|
let request = mobileConnection.sendMMI("*#06#");
|
|
ok(request instanceof DOMRequest,
|
|
"request is instanceof " + request.constructor);
|
|
|
|
request.onsuccess = function onsuccess(event) {
|
|
ok(true, "request success");
|
|
is(typeof event.target.result, "object", "typeof result object");
|
|
ok(event.target.result instanceof Object, "result instanceof Object");
|
|
is(event.target.result.statusMessage, "000000000000000", "Emulator IMEI");
|
|
is(event.target.result.serviceCode, "scImei", "Service code IMEI");
|
|
is(event.target.result.additionalInformation, undefined,
|
|
"No additional information");
|
|
tasks.next();
|
|
}
|
|
request.onerror = function onerror() {
|
|
ok(false, "request should not error");
|
|
tasks.abort();
|
|
};
|
|
});
|
|
|
|
tasks.push(function testInvalidMMICode(){
|
|
log("Test invalid MMI code ...");
|
|
|
|
let request = mobileConnection.sendMMI("InvalidMMICode");
|
|
ok(request instanceof DOMRequest,
|
|
"request is instanceof " + request.constructor);
|
|
|
|
request.onsuccess = function onsuccess(event) {
|
|
ok(false, "request should not success");
|
|
tasks.abort();
|
|
};
|
|
|
|
request.onerror = function onerror() {
|
|
ok(true, "request error");
|
|
is(request.error.name, "emMmiError", "MMI error name");
|
|
tasks.next();
|
|
};
|
|
});
|
|
|
|
// WARNING: All tasks should be pushed before this!!!
|
|
tasks.push(function cleanUp() {
|
|
SpecialPowers.removePermission("mobileconnection", document);
|
|
finish();
|
|
});
|