dom/telephony/test/marionette/test_outgoing_radio_off.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 connection;
     9 function setRadioEnabled(enabled, callback) {
    10   let request  = connection.setRadioEnabled(enabled);
    11   let desiredRadioState = enabled ? 'enabled' : 'disabled';
    13   let pending = ['onradiostatechange', 'onsuccess'];
    14   let done = callback;
    16   connection.onradiostatechange = function() {
    17     let state = connection.radioState;
    18     log("Received 'radiostatechange' event, radioState: " + state);
    20     if (state == desiredRadioState) {
    21       gReceivedPending('onradiostatechange', pending, done);
    22     }
    23   };
    25   request.onsuccess = function onsuccess() {
    26     gReceivedPending('onsuccess', pending, done);
    27   };
    29   request.onerror = function onerror() {
    30     ok(false, "setRadioEnabled should be ok");
    31   };
    32 }
    34 function dial(number) {
    35   // Verify initial state before dial.
    36   ok(telephony);
    37   is(telephony.active, null);
    38   ok(telephony.calls);
    39   is(telephony.calls.length, 0);
    41   log("Make an outgoing call.");
    43   telephony.dial(number).then(null, cause => {
    44     log("Received promise 'reject'");
    46     is(telephony.active, null);
    47     is(telephony.calls.length, 0);
    48     is(cause, "RadioNotAvailable");
    50     emulator.run("gsm list", function(result) {
    51       log("Initial call list: " + result);
    52       is(result[0], "OK");
    54       setRadioEnabled(true, cleanUp);
    55     });
    56   });
    57 }
    59 function cleanUp() {
    60   finish();
    61 }
    63 startTestWithPermissions(['mobileconnection'], function() {
    64   connection = navigator.mozMobileConnections[0];
    65   ok(connection instanceof MozMobileConnection,
    66      "connection is instanceof " + connection.constructor);
    68   setRadioEnabled(false, function() {
    69     dial("0912345678");
    70   });
    71 });

mercurial