dom/telephony/test/marionette/test_emergency_label.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;
     8 let emergency;
     9 let outgoing;
    11 let testCase = 0;
    12 let expectedResults = [
    13   ["112", true],
    14   ["911", true],
    15   ["0912345678", false],
    16   ["777", false],
    17 ];
    19 function createGoldenCallListResult0(number, state) {
    20   //  "outbound to  xxxxxxxxxx : ringing"
    21   let padPattern = "          ";
    22   let pad = padPattern.substring(0, padPattern.length - number.length);
    23   return "outbound to  " + number + pad + " : " + state;
    24 }
    26 function dial() {
    27   log("Make an outgoing call.");
    29   telephony.dial(number).then(call => {
    30     outgoing = call;
    31     ok(outgoing);
    32     is(outgoing.number, number);
    33     is(outgoing.state, "dialing");
    35     is(outgoing, telephony.active);
    36     is(telephony.calls.length, 1);
    37     is(telephony.calls[0], outgoing);
    39     outgoing.onalerting = function onalerting(event) {
    40       log("Received 'onalerting' call event.");
    41       is(outgoing, event.call);
    42       is(outgoing.state, "alerting");
    43       is(outgoing.emergency, emergency);
    45       emulator.run("gsm list", function(result) {
    46         log("Call list is now: " + result);
    47         is(result[0], createGoldenCallListResult0(number, "ringing"));
    48         is(result[1], "OK");
    49         answer();
    50       });
    51     };
    52   });
    53 }
    55 function answer() {
    56   log("Answering the call.");
    58   // We get no "connecting" event when the remote party answers the call.
    60   outgoing.onconnected = function onconnected(event) {
    61     log("Received 'connected' call event.");
    62     is(outgoing, event.call);
    63     is(outgoing.state, "connected");
    64     is(outgoing.emergency, emergency);
    66     is(outgoing, telephony.active);
    68     emulator.run("gsm list", function(result) {
    69       log("Call list is now: " + result);
    70       is(result[0], createGoldenCallListResult0(number, "active"));
    71       is(result[1], "OK");
    72       hangUp();
    73     });
    74   };
    75   emulator.run("gsm accept " + number);
    76 }
    78 function hangUp() {
    79   log("Hanging up the call.");
    81   // We get no "disconnecting" event when the remote party terminates the call.
    83   outgoing.ondisconnected = function ondisconnected(event) {
    84     log("Received 'disconnected' call event.");
    85     is(outgoing, event.call);
    86     is(outgoing.state, "disconnected");
    87     is(outgoing.emergency, emergency);
    89     is(telephony.active, null);
    90     is(telephony.calls.length, 0);
    92     emulator.run("gsm list", function(result) {
    93       log("Call list is now: " + result);
    94       is(result[0], "OK");
    95       verifyNextEmergencyLabel();
    96     });
    97   };
    98   emulator.run("gsm cancel " + number);
    99 }
   101 function cleanUp() {
   102   finish();
   103 }
   105 function verifyNextEmergencyLabel() {
   106   if (testCase >= expectedResults.length) {
   107     cleanUp();
   108   } else {
   109     log("Running test case: " + testCase + "/" + expectedResults.length);
   110     number = expectedResults[testCase][0];
   111     emergency = expectedResults[testCase][1];
   112     testCase++;
   114     // No more calls in the list; give time for emulator to catch up
   115     waitFor(dial, function() {
   116       return (telephony.calls.length === 0);
   117     });
   118   }
   119 }
   121 startTest(function() {
   122   verifyNextEmergencyLabel();
   123 });

mercurial