dom/telephony/test/marionette/test_incoming_answer_hangup.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 incoming;
     9 let calls;
    11 function simulateIncoming() {
    12   log("Simulating an incoming call.");
    14   telephony.onincoming = function onincoming(event) {
    15     log("Received 'incoming' call event.");
    16     incoming = event.call;
    17     ok(incoming);
    18     is(incoming.number, number);
    19     is(incoming.state, "incoming");
    21     //ok(telephony.calls === calls); // bug 717414
    22     is(telephony.calls.length, 1);
    23     is(telephony.calls[0], incoming);
    25     emulator.run("gsm list", function(result) {
    26       log("Call list is now: " + result);
    27       is(result[0], "inbound from " + number + " : incoming");
    28       is(result[1], "OK");
    29       answer();
    30     });
    31   };
    32   emulator.run("gsm call " + number);
    33 }
    35 function answer() {
    36   log("Answering the incoming call.");
    38   let gotConnecting = false;
    39   incoming.onconnecting = function onconnecting(event) {
    40     log("Received 'connecting' call event.");
    41     is(incoming, event.call);
    42     is(incoming.state, "connecting");
    43     gotConnecting = true;
    44   };
    46   incoming.onconnected = function onconnected(event) {
    47     log("Received 'connected' call event.");
    48     is(incoming, event.call);
    49     is(incoming.state, "connected");
    50     ok(gotConnecting);
    52     is(incoming, telephony.active);
    54     emulator.run("gsm list", function(result) {
    55       log("Call list is now: " + result);
    56       is(result[0], "inbound from " + number + " : active");
    57       is(result[1], "OK");
    58       hangUp();
    59     });
    60   };
    61   incoming.answer();
    62 }
    64 function hangUp() {
    65   log("Hanging up the incoming call.");
    67   let gotDisconnecting = false;
    68   incoming.ondisconnecting = function ondisconnecting(event) {
    69     log("Received 'disconnecting' call event.");
    70     is(incoming, event.call);
    71     is(incoming.state, "disconnecting");
    72     gotDisconnecting = true;
    73   };
    75   incoming.ondisconnected = function ondisconnected(event) {
    76     log("Received 'disconnected' call event.");
    77     is(incoming, event.call);
    78     is(incoming.state, "disconnected");
    79     ok(gotDisconnecting);
    81     is(telephony.active, null);
    82     is(telephony.calls.length, 0);
    84     emulator.run("gsm list", function(result) {
    85       log("Call list is now: " + result);
    86       is(result[0], "OK");
    87       cleanUp();
    88     });
    89   };
    90   incoming.hangUp();
    91 }
    93 function cleanUp() {
    94   telephony.onincoming = null;
    95   finish();
    96 }
    98 startTest(function() {
    99   simulateIncoming();
   100 });

mercurial