Bug 995844: retrieve mozMobileConnection from 'workingFrame' in mobileconnect marionette tests. r=echen

This commit is contained in:
Vicamo Yang 2014-04-17 11:22:38 +08:00
parent fc2b50e7a1
commit 0cad46c745
3 changed files with 18 additions and 9 deletions

View File

@ -74,6 +74,8 @@ function wrapDomRequestAsPromise(aRequest) {
return deferred.promise;
}
let workingFrame;
/**
* Get mozSettings value specified by @aKey.
*
@ -93,7 +95,8 @@ function wrapDomRequestAsPromise(aRequest) {
* @return A deferred promise.
*/
function getSettings(aKey, aAllowError) {
let request = navigator.mozSettings.createLock().get(aKey);
let request =
workingFrame.contentWindow.navigator.mozSettings.createLock().get(aKey);
return wrapDomRequestAsPromise(request)
.then(function resolve(aEvent) {
ok(true, "getSettings(" + aKey + ") - success");
@ -120,7 +123,8 @@ function getSettings(aKey, aAllowError) {
* @return A deferred promise.
*/
function setSettings(aSettings, aAllowError) {
let request = navigator.mozSettings.createLock().set(aSettings);
let request =
workingFrame.contentWindow.navigator.mozSettings.createLock().set(aSettings);
return wrapDomRequestAsPromise(request)
.then(function resolve() {
ok(true, "setSettings(" + JSON.stringify(aSettings) + ")");
@ -195,7 +199,6 @@ function setDataApnSettings(aApnSettings, aAllowError) {
return setSettings1(SETTINGS_KEY_DATA_APN_SETTINGS, aApnSettings, aAllowError);
}
let workingFrame;
let mobileConnection;
/**
@ -282,7 +285,8 @@ function waitForManagerEvent(aEventName, aServiceId) {
let mobileConn = mobileConnection;
if (aServiceId !== undefined) {
mobileConn = navigator.mozMobileConnections[aServiceId];
mobileConn =
workingFrame.contentWindow.navigator.mozMobileConnections[aServiceId];
}
mobileConn.addEventListener(aEventName, function onevent(aEvent) {
@ -407,7 +411,8 @@ function setDataEnabledAndWait(aEnabled, aServiceId) {
Promise.all(promises).then(function keepWaiting() {
let mobileConn = mobileConnection;
if (aServiceId !== undefined) {
mobileConn = navigator.mozMobileConnections[aServiceId];
mobileConn =
workingFrame.contentWindow.navigator.mozMobileConnections[aServiceId];
}
// To ignore some transient states, we only resolve that deferred promise
// when the |connected| state equals to the expected one and never rejects.
@ -467,7 +472,8 @@ function setEmulatorRoamingAndWait(aRoaming, aServiceId) {
.then(() => {
let mobileConn = mobileConnection;
if (aServiceId !== undefined) {
mobileConn = navigator.mozMobileConnections[aServiceId];
mobileConn =
workingFrame.contentWindow.navigator.mozMobileConnections[aServiceId];
}
is(mobileConn[aWhich].roaming, aRoaming,
aWhich + ".roaming")

View File

@ -6,8 +6,8 @@ MARIONETTE_HEAD_JS = "head.js";
const SETTINGS_KEY_DATA_DEFAULT_ID = "ril.data.defaultServiceId";
let connections = window.navigator.mozMobileConnections;
let numOfRadioInterfaces = getNumOfRadioInterfaces();
let connections;
let numOfRadioInterfaces;
let currentDataDefaultId = 0;
function muxModem(id) {
@ -142,6 +142,9 @@ function testDisableData() {
}
startDSDSTestCommon(function() {
connections = workingFrame.contentWindow.navigator.mozMobileConnections;
numOfRadioInterfaces = getNumOfRadioInterfaces();
return testEnableData()
.then(testSwitchDefaultDataToSimTwo)
.then(testDisableDataRoamingWhileRoaming)

View File

@ -8,6 +8,6 @@ startTestCommon(function() {
let connections =
workingFrame.contentWindow.navigator.mozMobileConnections;
let num = SpecialPowers.getIntPref("ril.numRadioInterfaces");
let num = getNumOfRadioInterfaces();
is(connections.length, num, "ril.numRadioInterfaces");
});