dom/telephony/test/marionette/test_outgoing_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;
     5 MARIONETTE_HEAD_JS = 'head.js';
     7 let number = "5555552368";
     8 let outgoing;
     9 let calls;
    11 function dial() {
    12   log("Make an outgoing call.");
    14   telephony.dial(number).then(call => {
    15     outgoing = call;
    16     ok(outgoing);
    17     is(outgoing.number, number);
    18     is(outgoing.state, "dialing");
    19     is(outgoing, telephony.active);
    20     //ok(telephony.calls === calls); // bug 717414
    21     is(telephony.calls.length, 1);
    22     is(telephony.calls[0], outgoing);
    24     outgoing.onalerting = function onalerting(event) {
    25       log("Received 'onalerting' call event.");
    26       is(outgoing, event.call);
    27       is(outgoing.state, "alerting");
    29       emulator.run("gsm list", function(result) {
    30         log("Call list is now: " + result);
    31         is(result[0], "outbound to  " + number + " : ringing");
    32         is(result[1], "OK");
    33         answer();
    34       });
    35     };
    36   });
    37 }
    39 function answer() {
    40   log("Answering the outgoing call.");
    42   // We get no "connecting" event when the remote party answers the call.
    44   outgoing.onconnected = function onconnected(event) {
    45     log("Received 'connected' call event.");
    46     is(outgoing, event.call);
    47     is(outgoing.state, "connected");
    49     is(outgoing, telephony.active);
    51     emulator.run("gsm list", function(result) {
    52       log("Call list is now: " + result);
    53       is(result[0], "outbound to  " + number + " : active");
    54       is(result[1], "OK");
    55       hold();
    56     });
    57   };
    58   emulator.run("gsm accept " + number);
    59 }
    61 function hold() {
    62   log("Holding the outgoing call.");
    64   outgoing.onholding = function onholding(event) {
    65     log("Received 'holding' call event.");
    66     is(outgoing, event.call);
    67     is(outgoing.state, "holding");
    69     is(outgoing, telephony.active);
    70   };
    72   outgoing.onheld = function onheld(event) {
    73     log("Received 'held' call event.");
    74     is(outgoing, event.call);
    75     is(outgoing.state, "held");
    77     is(telephony.active, null);
    78     is(telephony.calls.length, 1);
    80     emulator.run("gsm list", function(result) {
    81       log("Call list is now: " + result);
    82       is(result[0], "outbound to  " + number + " : held");
    83       is(result[1], "OK");
    84       hangUp();
    85     });
    86   };
    87   outgoing.hold();
    88 }
    90 function hangUp() {
    91   log("Hanging up the outgoing call.");
    93   let gotDisconnecting = false;
    94   outgoing.ondisconnecting = function ondisconnecting(event) {
    95     log("Received disconnecting call event.");
    96     is(outgoing, event.call);
    97     is(outgoing.state, "disconnecting");
    98     gotDisconnecting = true;
    99   };
   101   outgoing.ondisconnected = function ondisconnected(event) {
   102     log("Received 'disconnected' call event.");
   103     is(outgoing, event.call);
   104     is(outgoing.state, "disconnected");
   105     ok(gotDisconnecting);
   107     is(telephony.active, null);
   108     is(telephony.calls.length, 0);
   110     emulator.run("gsm list", function(result) {
   111       log("Call list is now: " + result);
   112       is(result[0], "OK");
   113       cleanUp();
   114     });
   115   };
   117   outgoing.hangUp();
   118 }
   120 function cleanUp() {
   121   finish();
   122 }
   124 startTest(function() {
   125   dial();
   126 });

mercurial