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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 MARIONETTE_TIMEOUT = 60000;
5 MARIONETTE_HEAD_JS = 'head.js';
7 let connection;
9 function setRadioEnabled(enabled, callback) {
10 let request = connection.setRadioEnabled(enabled);
11 let desiredRadioState = enabled ? 'enabled' : 'disabled';
13 let pending = ['onradiostatechange', 'onsuccess'];
14 let done = callback;
16 connection.onradiostatechange = function() {
17 let state = connection.radioState;
18 log("Received 'radiostatechange' event, radioState: " + state);
20 if (state == desiredRadioState) {
21 gReceivedPending('onradiostatechange', pending, done);
22 }
23 };
25 request.onsuccess = function onsuccess() {
26 gReceivedPending('onsuccess', pending, done);
27 };
29 request.onerror = function onerror() {
30 ok(false, "setRadioEnabled should be ok");
31 };
32 }
34 function dial(number) {
35 // Verify initial state before dial.
36 ok(telephony);
37 is(telephony.active, null);
38 ok(telephony.calls);
39 is(telephony.calls.length, 0);
41 log("Make an outgoing call.");
43 telephony.dial(number).then(null, cause => {
44 log("Received promise 'reject'");
46 is(telephony.active, null);
47 is(telephony.calls.length, 0);
48 is(cause, "RadioNotAvailable");
50 emulator.run("gsm list", function(result) {
51 log("Initial call list: " + result);
52 is(result[0], "OK");
54 setRadioEnabled(true, cleanUp);
55 });
56 });
57 }
59 function cleanUp() {
60 finish();
61 }
63 startTestWithPermissions(['mobileconnection'], function() {
64 connection = navigator.mozMobileConnections[0];
65 ok(connection instanceof MozMobileConnection,
66 "connection is instanceof " + connection.constructor);
68 setRadioEnabled(false, function() {
69 dial("0912345678");
70 });
71 });