dom/mobileconnection/tests/marionette/test_dsds_mobile_data_connection.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 SETTINGS_KEY_DATA_DEFAULT_ID = "ril.data.defaultServiceId";
michael@0 8
michael@0 9 let connections;
michael@0 10 let numOfRadioInterfaces;
michael@0 11 let currentDataDefaultId = 0;
michael@0 12
michael@0 13 function muxModem(id) {
michael@0 14 return runEmulatorCmdSafe("mux modem " + id);
michael@0 15 }
michael@0 16
michael@0 17 function switchDataDefaultId(defaultId) {
michael@0 18 return Promise.resolve()
michael@0 19 .then(() => setSettings1(SETTINGS_KEY_DATA_DEFAULT_ID, defaultId))
michael@0 20 .then(() => {
michael@0 21 log("Data default id switched to: " + defaultId);
michael@0 22 currentDataDefaultId = defaultId;
michael@0 23 });
michael@0 24 }
michael@0 25
michael@0 26 function setDataRoamingSettings(enableDataRoammingIds) {
michael@0 27 let dataRoamingSettings = [];
michael@0 28 for (let i = 0; i < numOfRadioInterfaces; i++) {
michael@0 29 dataRoamingSettings.push(false);
michael@0 30 }
michael@0 31
michael@0 32 for (let i = 0; i < enableDataRoammingIds.length; i++) {
michael@0 33 log("Enable data roaming for id: " + enableDataRoammingIds[i]);
michael@0 34 dataRoamingSettings[enableDataRoammingIds[i]] = true;
michael@0 35 }
michael@0 36
michael@0 37 return setDataRoamingEnabled(dataRoamingSettings);
michael@0 38 }
michael@0 39
michael@0 40 function setApnSettings() {
michael@0 41 let apn = [{
michael@0 42 "carrier":"T-Mobile US",
michael@0 43 "apn":"epc.tmobile.com",
michael@0 44 "mmsc":"http://mms.msg.eng.t-mobile.com/mms/wapenc",
michael@0 45 "types":["default","supl","mms"]
michael@0 46 }];
michael@0 47
michael@0 48 // Use the same APN for all sims for now.
michael@0 49 let apns = [];
michael@0 50 for (let i = 0; i < numOfRadioInterfaces; i++) {
michael@0 51 apns.push(apn);
michael@0 52 }
michael@0 53
michael@0 54 return setDataApnSettings(apns);
michael@0 55
michael@0 56 }
michael@0 57
michael@0 58 function waitForDataState(clientId, connected) {
michael@0 59 let deferred = Promise.defer();
michael@0 60
michael@0 61 let connection = connections[clientId];
michael@0 62 if (connection.data.connected === connected) {
michael@0 63 log("data connection for client " + clientId + " is now " +
michael@0 64 connection.data.connected);
michael@0 65 deferred.resolve();
michael@0 66 return;
michael@0 67 }
michael@0 68
michael@0 69 return Promise.resolve()
michael@0 70 .then(() => waitForManagerEvent("datachange", clientId))
michael@0 71 .then(() => waitForDataState(clientId, connected));
michael@0 72 }
michael@0 73
michael@0 74 function restoreTestEnvironment() {
michael@0 75 return Promise.resolve()
michael@0 76 .then(() => setEmulatorRoamingAndWait(false, currentDataDefaultId))
michael@0 77 .then(() => setDataRoamingSettings([]))
michael@0 78 .then(() => switchDataDefaultId(0))
michael@0 79 .then(() => muxModem(0));
michael@0 80 }
michael@0 81
michael@0 82 function testEnableData() {
michael@0 83 log("Turn data on.");
michael@0 84
michael@0 85 let connection = connections[currentDataDefaultId];
michael@0 86 is(connection.data.connected, false);
michael@0 87
michael@0 88 return Promise.resolve()
michael@0 89 .then(() => setApnSettings())
michael@0 90 .then(() => setDataEnabledAndWait(true, currentDataDefaultId));
michael@0 91 }
michael@0 92
michael@0 93 function testSwitchDefaultDataToSimTwo() {
michael@0 94 log("Switch data connection to sim 2.");
michael@0 95
michael@0 96 is(currentDataDefaultId, 0);
michael@0 97 let connection = connections[currentDataDefaultId];
michael@0 98 is(connection.data.connected, true);
michael@0 99
michael@0 100 return Promise.resolve()
michael@0 101 .then(() => switchDataDefaultId(1))
michael@0 102 .then(() => {
michael@0 103 is(currentDataDefaultId, 1);
michael@0 104 })
michael@0 105 .then(() => waitForDataState(currentDataDefaultId, true));
michael@0 106 }
michael@0 107
michael@0 108 function testDisableDataRoamingWhileRoaming() {
michael@0 109 log("Disable data roaming setting while roaming.");
michael@0 110
michael@0 111 let connection = connections[currentDataDefaultId];
michael@0 112 is(connection.data.connected, true);
michael@0 113 is(connection.data.roaming, false);
michael@0 114
michael@0 115 return Promise.resolve()
michael@0 116 .then(() => setDataRoamingSettings([]))
michael@0 117 .then(() => muxModem(currentDataDefaultId))
michael@0 118 .then(() => setEmulatorRoamingAndWait(true, currentDataDefaultId))
michael@0 119 .then(() => waitForDataState(currentDataDefaultId, false));
michael@0 120 }
michael@0 121
michael@0 122 function testEnableDataRoamingWhileRoaming() {
michael@0 123 log("Enable data roaming setting while roaming.");
michael@0 124
michael@0 125 let connection = connections[currentDataDefaultId];
michael@0 126 is(connection.data.connected, false);
michael@0 127 is(connection.data.roaming, true);
michael@0 128
michael@0 129 return Promise.resolve()
michael@0 130 .then(() => setDataRoamingSettings([currentDataDefaultId]))
michael@0 131 .then(() => waitForDataState(currentDataDefaultId, true));
michael@0 132 }
michael@0 133
michael@0 134 function testDisableData() {
michael@0 135 log("Turn data off.");
michael@0 136
michael@0 137 let connection = connections[currentDataDefaultId];
michael@0 138 is(connection.data.connected, true);
michael@0 139
michael@0 140 return Promise.resolve()
michael@0 141 .then(() => setDataEnabledAndWait(false, currentDataDefaultId));
michael@0 142 }
michael@0 143
michael@0 144 startDSDSTestCommon(function() {
michael@0 145 connections = workingFrame.contentWindow.navigator.mozMobileConnections;
michael@0 146 numOfRadioInterfaces = getNumOfRadioInterfaces();
michael@0 147
michael@0 148 return testEnableData()
michael@0 149 .then(testSwitchDefaultDataToSimTwo)
michael@0 150 .then(testDisableDataRoamingWhileRoaming)
michael@0 151 .then(testEnableDataRoamingWhileRoaming)
michael@0 152 .then(testDisableData)
michael@0 153 .then(restoreTestEnvironment);
michael@0 154 }, ["settings-read", "settings-write"]);

mercurial