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 number = "5555552368"; |
michael@0 | 8 | let outgoing; |
michael@0 | 9 | |
michael@0 | 10 | function dial() { |
michael@0 | 11 | log("Make an outgoing call."); |
michael@0 | 12 | |
michael@0 | 13 | telephony.oncallschanged = function oncallschanged(event) { |
michael@0 | 14 | log("Received 'callschanged' call event."); |
michael@0 | 15 | |
michael@0 | 16 | if (!event.call) { |
michael@0 | 17 | log("Notifying calls array is loaded. No call information accompanies."); |
michael@0 | 18 | return; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | let expected_states = ["dialing", "disconnected"]; |
michael@0 | 22 | ok(expected_states.indexOf(event.call.state) != -1, |
michael@0 | 23 | "Unexpected call state: " + event.call.state); |
michael@0 | 24 | |
michael@0 | 25 | if (event.call.state == "dialing") { |
michael@0 | 26 | outgoing = event.call; |
michael@0 | 27 | ok(outgoing); |
michael@0 | 28 | is(outgoing.number, number); |
michael@0 | 29 | |
michael@0 | 30 | is(outgoing, telephony.active); |
michael@0 | 31 | is(telephony.calls.length, 1); |
michael@0 | 32 | is(telephony.calls[0], outgoing); |
michael@0 | 33 | |
michael@0 | 34 | checkCallList(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | if (event.call.state == "disconnected") { |
michael@0 | 38 | is(outgoing.state, "disconnected"); |
michael@0 | 39 | is(telephony.active, null); |
michael@0 | 40 | is(telephony.calls.length, 0); |
michael@0 | 41 | cleanUp(); |
michael@0 | 42 | } |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | telephony.dial(number); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function checkCallList() { |
michael@0 | 49 | emulator.run("gsm list", function(result) { |
michael@0 | 50 | log("Call list is now: " + result); |
michael@0 | 51 | if ((result[0] == "outbound to " + number + " : unknown") && (result[1] == "OK")) { |
michael@0 | 52 | answer(); |
michael@0 | 53 | } else { |
michael@0 | 54 | window.setTimeout(checkCallList, 100); |
michael@0 | 55 | } |
michael@0 | 56 | }); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | function answer() { |
michael@0 | 60 | log("Answering the outgoing call."); |
michael@0 | 61 | |
michael@0 | 62 | // We get no "connecting" event when the remote party answers the call. |
michael@0 | 63 | |
michael@0 | 64 | outgoing.onconnected = function onconnected(event) { |
michael@0 | 65 | log("Received 'connected' call event."); |
michael@0 | 66 | is(outgoing, event.call); |
michael@0 | 67 | is(outgoing.state, "connected"); |
michael@0 | 68 | |
michael@0 | 69 | is(outgoing, telephony.active); |
michael@0 | 70 | |
michael@0 | 71 | emulator.run("gsm list", function(result) { |
michael@0 | 72 | log("Call list (after 'connected' event) is now: " + result); |
michael@0 | 73 | is(result[0], "outbound to " + number + " : active"); |
michael@0 | 74 | is(result[1], "OK"); |
michael@0 | 75 | hangUp(); |
michael@0 | 76 | }); |
michael@0 | 77 | }; |
michael@0 | 78 | emulator.run("gsm accept " + number); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function hangUp() { |
michael@0 | 82 | log("Hanging up the outgoing call."); |
michael@0 | 83 | |
michael@0 | 84 | emulator.run("gsm cancel " + number); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | function cleanUp() { |
michael@0 | 88 | telephony.oncallschanged = null; |
michael@0 | 89 | finish(); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | startTest(function() { |
michael@0 | 93 | dial(); |
michael@0 | 94 | }); |