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 function muxModem(id) {
8 let deferred = Promise.defer();
10 emulator.run("mux modem " + id, function() {
11 deferred.resolve();
12 });
14 return deferred.promise;
15 }
17 function testOutgoingCallForServiceId(number, serviceId) {
18 let outCall;
19 let outInfo = gOutCallStrPool(number);
21 return Promise.resolve()
22 .then(() => gDial(number, serviceId))
23 .then(call => {
24 outCall = call;
25 is(outCall.serviceId, serviceId);
26 })
27 .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.ringing]))
28 .then(() => gRemoteAnswer(outCall))
29 .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.active]))
30 .then(() => gRemoteHangUp(outCall))
31 .then(() => gCheckAll(null, [], '', [], []));
32 }
34 function testIncomingCallForServiceId(number, serviceId) {
35 let inCall;
36 let inInfo = gInCallStrPool(number);
38 return Promise.resolve()
39 .then(() => gRemoteDial(number))
40 .then(call => {
41 inCall = call;
42 is(inCall.serviceId, serviceId);
43 })
44 .then(() => gCheckAll(null, [inCall], '', [], [inInfo.incoming]))
45 .then(() => gAnswer(inCall))
46 .then(() => gCheckAll(inCall, [inCall], '', [], [inInfo.active]))
47 .then(() => gRemoteHangUp(inCall))
48 .then(() => gCheckAll(null, [], '', [], []));
49 }
51 function testOutgoingCall() {
52 log("= testOutgoingCall =");
54 return Promise.resolve()
55 .then(() => muxModem(0))
56 .then(() => testOutgoingCallForServiceId("0912345000", 0))
57 .then(() => muxModem(1))
58 .then(() => testOutgoingCallForServiceId("0912345001", 1))
59 .then(() => muxModem(0));
60 }
62 function testIncomingCall() {
63 log("= testIncomingCall =");
65 return Promise.resolve()
66 .then(() => muxModem(0))
67 .then(() => testIncomingCallForServiceId("0912345000", 0))
68 .then(() => muxModem(1))
69 .then(() => testIncomingCallForServiceId("0912345001", 1))
70 .then(() => muxModem(0));
71 }
73 startDSDSTest(function() {
74 testOutgoingCall()
75 .then(testIncomingCall)
76 .then(null, () => {
77 ok(false, "promise rejects during test.");
78 })
79 .then(finish);
80 });