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