dom/telephony/test/marionette/test_incoming_onstatechange.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_HEAD_JS = 'head.js';
     5 MARIONETTE_TIMEOUT = 60000;
     7 let incomingCall;
     8 let inNumber = "5555551111";
    10 function simulateIncoming() {
    11   log("Simulating an incoming call.");
    13   telephony.onincoming = function onincoming(event) {
    14     log("Received 'incoming' call event.");
    15     incomingCall = event.call;
    16     ok(incomingCall);
    17     is(incomingCall.number, inNumber);
    18     is(incomingCall.state, "incoming");
    20     is(telephony.calls.length, 1);
    21     is(telephony.calls[0], incomingCall);
    23     emulator.run("gsm list", function(result) {
    24       log("Call list is now: " + result);
    25       is(result[0], "inbound from " + inNumber + " : incoming");
    26       is(result[1], "OK");
    27       answerIncoming();
    28     });
    29   };
    30   emulator.run("gsm call " + inNumber);
    31 }
    33 function answerIncoming() {
    34   log("Answering the incoming call.");
    36   gotConnecting = false;
    37   incomingCall.onstatechange = function statechangeconnect(event) {
    38     log("Received 'onstatechange' call event.");
    39     is(incomingCall, event.call);
    40     if(!gotConnecting){
    41       is(incomingCall.state, "connecting");
    42       gotConnecting = true;
    43     } else {
    44       is(incomingCall.state, "connected");
    45       is(telephony.active, incomingCall);
    46       is(telephony.calls.length, 1);
    47       is(telephony.calls[0], incomingCall);
    49       emulator.run("gsm list", function(result) {
    50         log("Call list is now: " + result);
    51         is(result[0], "inbound from " + inNumber + " : active");
    52         is(result[1], "OK");
    53         hold();
    54       });
    55     }
    56   };
    57   incomingCall.answer();
    58 }
    60 function hold() {
    61   log("Putting the call on hold.");
    63   let gotHolding = false;
    64   incomingCall.onstatechange = function onstatechangehold(event) {
    65     log("Received 'onstatechange' call event.");
    66     is(incomingCall, event.call);
    67     if(!gotHolding){
    68       is(incomingCall.state, "holding");
    69       gotHolding = true;
    70     } else {
    71       is(incomingCall.state, "held");
    72       is(telephony.active, null);
    73       is(telephony.calls.length, 1);
    74       is(telephony.calls[0], incomingCall);
    76       emulator.run("gsm list", function(result) {
    77         log("Call list is now: " + result);
    78         is(result[0], "inbound from " + inNumber + " : held");
    79         is(result[1], "OK");
    80         resume();
    81       });
    82     }
    83   };
    84   incomingCall.hold();
    85 }
    87 function resume() {
    88   log("Resuming the held call.");
    90   let gotResuming = false;
    91   incomingCall.onstatechange = function onstatechangeresume(event) {
    92     log("Received 'onstatechange' call event.");
    93     is(incomingCall, event.call);
    94     if(!gotResuming){
    95       is(incomingCall.state, "resuming");
    96       gotResuming = true;
    97     } else {
    98       is(incomingCall.state, "connected");
    99       is(telephony.active, incomingCall);
   100       is(telephony.calls.length, 1);
   101       is(telephony.calls[0], incomingCall);
   103       emulator.run("gsm list", function(result) {
   104         log("Call list is now: " + result);
   105         is(result[0], "inbound from " + inNumber + " : active");
   106         is(result[1], "OK");
   107         hangUp();
   108       });
   109     }
   110   };
   111   incomingCall.resume();
   112 }
   114 function hangUp() {
   115   log("Hanging up the incoming call (local hang-up).");
   117   let gotDisconnecting = false;
   118   incomingCall.onstatechange = function onstatechangedisconnect(event) {
   119     log("Received 'onstatechange' call event.");
   120     is(incomingCall, event.call);
   121     if(!gotDisconnecting){
   122       is(incomingCall.state, "disconnecting");
   123       gotDisconnecting = true;
   124     } else {
   125       is(incomingCall.state, "disconnected");
   126       is(telephony.active, null);
   127       is(telephony.calls.length, 0);
   129       emulator.run("gsm list", function(result) {
   130         log("Call list is now: " + result);
   131         is(result[0], "OK");
   132         cleanUp();
   133       });
   134     }
   135   };
   136   incomingCall.hangUp();
   137 }
   139 function cleanUp() {
   140   telephony.onincoming = null;
   141   finish();
   142 }
   144 startTest(function() {
   145   simulateIncoming();
   146 });

mercurial