Bug 1129173 - Properly detect B2G for workers interface tests. r=bent

Make use of SpecialPowers.isB2G to do the proper detection, and fix
mochitest execution for Mulet to include some B2G-specific prefs.
This commit is contained in:
Alexandre Lissy 2015-02-10 06:51:00 +01:00
parent f57c1e7fd1
commit 1f778d301f
4 changed files with 43 additions and 9 deletions

View File

@ -35,7 +35,7 @@ var ecmaGlobals =
"Int32Array",
"Int8Array",
"InternalError",
{name: "Intl", desktop: true},
{name: "Intl", b2g: false, android: false},
"Iterator",
"JSON",
"Map",
@ -167,11 +167,11 @@ var interfaceNamesInGlobalScope =
];
// IMPORTANT: Do not change the list above without review from a DOM peer!
function createInterfaceMap(prefMap, permissionMap, version, userAgent) {
function createInterfaceMap(prefMap, permissionMap, version, userAgent, isB2G) {
var isNightly = version.endsWith("a1");
var isRelease = !version.contains("a");
var isDesktop = !/Mobile|Tablet/.test(userAgent);
var isB2G = !isDesktop && !userAgent.contains("Android");
var isAndroid = !!navigator.userAgent.contains("Android");
var interfaceMap = {};
@ -182,6 +182,7 @@ function createInterfaceMap(prefMap, permissionMap, version, userAgent) {
interfaceMap[entry] = true;
} else if ((entry.nightly === !isNightly) ||
(entry.desktop === !isDesktop) ||
(entry.android === !isAndroid) ||
(entry.b2g === !isB2G) ||
(entry.release === !isRelease) ||
(entry.pref && !prefMap[entry.pref]) ||
@ -199,8 +200,8 @@ function createInterfaceMap(prefMap, permissionMap, version, userAgent) {
return interfaceMap;
}
function runTest(prefMap, permissionMap, version, userAgent) {
var interfaceMap = createInterfaceMap(prefMap, permissionMap, version, userAgent);
function runTest(prefMap, permissionMap, version, userAgent, isB2G) {
var interfaceMap = createInterfaceMap(prefMap, permissionMap, version, userAgent, isB2G);
for (var name of Object.getOwnPropertyNames(self)) {
// An interface name should start with an upper case character.
if (!/^[A-Z]/.test(name)) {
@ -252,8 +253,10 @@ workerTestGetPrefs(prefs, function(prefMap) {
workerTestGetPermissions(permissions, function(permissionMap) {
workerTestGetVersion(function(version) {
workerTestGetUserAgent(function(userAgent) {
runTest(prefMap, permissionMap, version, userAgent);
workerTestDone();
workerTestGetIsB2G(function(isB2G) {
runTest(prefMap, permissionMap, version, userAgent, isB2G);
workerTestDone();
});
});
});
});

View File

@ -76,6 +76,11 @@ function workerTestExec(script) {
type: 'returnOSCPU',
result: navigator.oscpu
});
} else if (event.data.type == 'getIsB2G') {
worker.postMessage({
type: 'returnIsB2G',
result: SpecialPowers.isB2G
});
}
}

View File

@ -99,6 +99,19 @@ function workerTestGetOSCPU(cb) {
});
}
function workerTestGetIsB2G(cb) {
addEventListener('message', function workerTestGetIsB2GCB(e) {
if (e.data.type !== 'returnIsB2G') {
return;
}
removeEventListener('message', workerTestGetIsB2GCB);
cb(e.data.result);
});
postMessage({
type: 'getIsB2G'
});
}
addEventListener('message', function workerWrapperOnMessage(e) {
removeEventListener('message', workerWrapperOnMessage);
var data = e.data;

View File

@ -1202,12 +1202,25 @@ class Mochitest(MochitestUtilsMixin):
apps = None
# preferences
prefsPath = os.path.join(SCRIPT_DIR, 'profile_data', 'prefs_general.js')
prefs = dict(Preferences.read_prefs(prefsPath))
preferences = [ os.path.join(SCRIPT_DIR, 'profile_data', 'prefs_general.js') ]
# TODO: Let's include those prefs until bug 1072443 is fixed
if mozinfo.info.get('buildapp') == 'mulet':
preferences += [ os.path.join(SCRIPT_DIR, 'profile_data', 'prefs_b2g_unittest.js') ]
prefs = {}
for path in preferences:
prefs.update(Preferences.read_prefs(path))
prefs.update(self.extraPrefs(options.extraPrefs))
# interpolate preferences
interpolation = {"server": "%s:%s" % (options.webServer, options.httpPort)}
# TODO: Remove OOP once bug 1072443 is fixed
if mozinfo.info.get('buildapp') == 'mulet':
interpolation["OOP"] = "false"
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])