dom/mobileconnection/tests/marionette/test_mobile_data_state.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 const INITIAL_STATES = {
     8   state: "registered",
     9   connected: false,
    10   emergencyCallsOnly: false,
    11   roaming: false,
    12   signalStrength: -99,
    13   relSignalStrength: 44,
    15   cell: {
    16     gsmLocationAreaCode: 65535,
    17     gsmCellId: 268435455,
    18     cdmaBaseStationId: -1,
    19     cdmaBaseStationLatitude: -2147483648,
    20     cdmaBaseStationLongitude: -2147483648,
    21     cdmaSystemId: -1,
    22     cdmaNetworkId: -1,
    23   }
    24 };
    26 const TEST_DATA = [{
    27     // Test state becomes to "unregistered"
    28     state: "unregistered",
    29     expected: {
    30       state: "notSearching",
    31       connected: false,
    32       emergencyCallsOnly: true,
    33       roaming: false,
    34       signalStrength: null,
    35       relSignalStrength: null,
    36       cell: null
    37     }
    38   }, {
    39     // Test state becomes to "searching"
    40     state: "searching",
    41     expected: {
    42       state: "searching",
    43       connected: false,
    44       emergencyCallsOnly: true,
    45       roaming: false,
    46       signalStrength: null,
    47       relSignalStrength: null,
    48       cell: null
    49     }
    50   }, {
    51     // Test state becomes to "denied"
    52     state: "denied",
    53     expected: {
    54       state: "denied",
    55       connected: false,
    56       emergencyCallsOnly: true,
    57       roaming: false,
    58       signalStrength: null,
    59       relSignalStrength: null,
    60       cell: null
    61     }
    62   }, {
    63     // Test state becomes to "roaming"
    64     // Set emulator's data state to "roaming" won't change the operator's
    65     // long_name/short_name/mcc/mnc, so that the |data.roaming| will still
    66     // report false. Please see bug 787967.
    67     state: "roaming",
    68     expected: {
    69       state: "registered",
    70       connected: false,
    71       emergencyCallsOnly: false,
    72       roaming: false,
    73       signalStrength: -99,
    74       relSignalStrength: 44,
    75       cell: {
    76         gsmLocationAreaCode: 65535,
    77         gsmCellId: 268435455
    78       }
    79     }
    80   }, {
    81     // Reset state to default value.
    82     state: "home",
    83     expected: {
    84       state: "registered",
    85       connected: false,
    86       emergencyCallsOnly: false,
    87       roaming: false,
    88       signalStrength: -99,
    89       relSignalStrength: 44,
    90       cell: {
    91         gsmLocationAreaCode: 65535,
    92         gsmCellId: 268435455
    93       }
    94     }
    95   }
    96 ];
    98 function compareTo(aPrefix, aFrom, aTo) {
    99   for (let field in aTo) {
   100     let fullName = aPrefix + field;
   102     let lhs = aFrom[field];
   103     let rhs = aTo[field];
   104     ok(true, "lhs=" + JSON.stringify(lhs) + ", rhs=" + JSON.stringify(rhs));
   105     if (typeof rhs !== "object") {
   106       is(lhs, rhs, fullName);
   107     } else if (rhs) {
   108       ok(lhs, fullName);
   109       compareTo(fullName + ".", lhs, rhs);
   110     } else {
   111       is(lhs, null, fullName);
   112     }
   113   }
   114 }
   116 function verifyDataInfo(aExpected) {
   117   compareTo("data.", mobileConnection.data, aExpected);
   118 }
   120 /* Test Data State Changed */
   121 function testDataStateUpdate(aNewState, aExpected) {
   122   log("Test data info with state='" + aNewState + "'");
   124   // Set emulator's lac/cid and wait for 'ondatachange' event.
   125   return setEmulatorVoiceDataStateAndWait("data", aNewState)
   126     .then(() => verifyDataInfo(aExpected));
   127 }
   129 startTestCommon(function() {
   130   log("Test initial data connection info");
   132   verifyDataInfo(INITIAL_STATES);
   134   let promise = Promise.resolve();
   135   for (let i = 0; i < TEST_DATA.length; i++) {
   136     let entry = TEST_DATA[i];
   137     promise =
   138       promise.then(testDataStateUpdate.bind(null, entry.state, entry.expected));
   139   }
   141   return promise;
   142 });

mercurial