2012-11-26 18:27:46 -08:00
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-10-13 13:33:22 -07:00
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
var Cc = SpecialPowers.Cc;
|
|
|
|
|
var Ci = SpecialPowers.Ci;
|
|
|
|
|
var Cr = SpecialPowers.Cr;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setup any Mochitest for WebRTC by enabling the preference for
|
|
|
|
|
* peer connections. As by bug 797979 it will also enable mozGetUserMedia().
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} aCallback Test method to execute after initialization
|
2012-11-26 18:27:46 -08:00
|
|
|
|
* @param {Boolean} desktopSupportedOnly specifies if the test currently
|
|
|
|
|
* is known to work on desktop only
|
2012-10-13 13:33:22 -07:00
|
|
|
|
*/
|
2012-11-26 18:27:46 -08:00
|
|
|
|
function runTest(aCallback, desktopSupportedOnly) {
|
2012-10-13 13:33:22 -07:00
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
2012-11-26 18:27:46 -08:00
|
|
|
|
// If this is a desktop supported test and we're on android or b2g,
|
|
|
|
|
// indicate that the test is not supported and skip the test
|
2012-12-12 13:40:57 -08:00
|
|
|
|
if(desktopSupportedOnly && (navigator.userAgent.indexOf('Android') > -1 ||
|
2012-11-26 18:27:46 -08:00
|
|
|
|
navigator.platform === '')) {
|
2012-12-12 13:40:57 -08:00
|
|
|
|
ok(true, navigator.userAgent + ' currently not supported');
|
2012-11-26 18:27:46 -08:00
|
|
|
|
SimpleTest.finish();
|
|
|
|
|
} else {
|
2012-12-27 12:55:52 -08:00
|
|
|
|
SpecialPowers.pushPrefEnv({'set': [['media.peerconnection.enabled', true]]}, function () {
|
|
|
|
|
try {
|
|
|
|
|
aCallback();
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
unexpectedCallbackAndFinish(err);
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-11-26 18:27:46 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A callback function fired only under unexpected circumstances while
|
|
|
|
|
* running the tests. Kills off the test as well gracefully.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} obj the object fired back from the callback
|
|
|
|
|
*/
|
|
|
|
|
function unexpectedCallbackAndFinish(obj) {
|
|
|
|
|
ok(false, "Unexpected error callback with " + obj);
|
|
|
|
|
SimpleTest.finish();
|
2012-10-13 13:33:22 -07:00
|
|
|
|
}
|