dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 60000;
     6 let outNumber = "5555551111";
     7 let outgoingCall;
     9 function dial() {
    10   log("Make an outgoing call.");
    12   telephony.dial(outNumber).then(call => {
    13     outgoingCall = call;
    14     ok(outgoingCall);
    15     is(outgoingCall.number, outNumber);
    16     is(outgoingCall.state, "dialing");
    18     is(outgoingCall, telephony.active);
    19     is(telephony.calls.length, 1);
    20     is(telephony.calls[0], outgoingCall);
    22     outgoingCall.onalerting = function onalerting(event) {
    23       log("Received 'alerting' call event.");
    25       is(outgoingCall, event.call);
    26       is(outgoingCall.state, "alerting");
    28       emulator.run("gsm list", function(result) {
    29         log("Call list is now: " + result);
    30         is(result[0], "outbound to  " + outNumber + " : ringing");
    31         is(result[1], "OK");
    32         answer();
    33       });
    34     };
    35   });
    36 }
    38 function answer() {
    39   log("Answering the outgoing call.");
    41   // We get no "connecting" event when the remote party answers the call.
    43   outgoingCall.onconnected = function onconnected(event) {
    44     log("Received 'connected' call event.");
    45     is(outgoingCall, event.call);
    46     is(outgoingCall.state, "connected");
    48     is(outgoingCall, telephony.active);
    50     emulator.run("gsm list", function(result) {
    51       log("Call list is now: " + result);
    52       is(result[0], "outbound to  " + outNumber + " : active");
    53       is(result[1], "OK");
    54       hold();
    55     });
    56   };
    57   emulator.run("gsm accept " + outNumber);
    58 }
    60 function hold() {
    61   log("Holding the outgoing call.");
    63   outgoingCall.onholding = function onholding(event) {
    64     log("Received 'holding' call event.");
    65     is(outgoingCall, event.call);
    66     is(outgoingCall.state, "holding");
    68     is(outgoingCall, telephony.active);
    69   };
    71   outgoingCall.onheld = function onheld(event) {
    72     log("Received 'held' call event.");
    73     is(outgoingCall, event.call);
    74     is(outgoingCall.state, "held");
    76     is(telephony.active, null);
    77     is(telephony.calls.length, 1);
    78     is(telephony.calls[0], outgoingCall);
    80     emulator.run("gsm list", function(result) {
    81       log("Call list is now: " + result);
    82       is(result[0], "outbound to  " + outNumber + " : held");
    83       is(result[1], "OK");
    84       hangUp();
    85     });
    86   };
    87   outgoingCall.hold();
    88 }
    90 function hangUp() {
    91   log("Hanging up the outgoing call (remotely).");
    93   // We get no 'disconnecting' event when remote party hangs-up the call
    95   outgoingCall.ondisconnected = function ondisconnected(event) {
    96     log("Received 'disconnected' call event.");
    97     is(outgoingCall, event.call);
    98     is(outgoingCall.state, "disconnected");
   100     is(telephony.active, null);
   101     is(telephony.calls.length, 0);
   103     emulator.run("gsm list", function(result) {
   104       log("Call list is now: " + result);
   105       is(result[0], "OK");
   106       cleanUp();
   107     });
   108   };
   109   emulator.run("gsm cancel " + outNumber);
   110 }
   112 function cleanUp() {
   113   finish();
   114 }
   116 startTest(function() {
   117   dial();
   118 });

mercurial