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.

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

mercurial