bug 887404 - Allow test_browserGlue_distribution.js to run parallel to other tests.

r=gavin
This commit is contained in:
Marco Bonardo 2013-07-05 18:44:18 +02:00
parent c7b77cbe6d
commit d4bf5ac8b8
2 changed files with 14 additions and 4 deletions

View File

@ -13,13 +13,21 @@ const DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC =
"distribution-customization-complete";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
this.DistributionCustomizer = function DistributionCustomizer() {
// For parallel xpcshell testing purposes allow loading the distribution.ini
// file from the profile folder through an hidden pref.
let loadFromProfile = false;
try {
loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile");
} catch(ex) {}
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let iniFile = dirSvc.get("XREExeF", Ci.nsIFile);
let iniFile = loadFromProfile ? dirSvc.get("ProfD", Ci.nsIFile)
: dirSvc.get("XREExeF", Ci.nsIFile);
iniFile.leafName = "distribution";
iniFile.append("distribution.ini");
if (iniFile.exists())

View File

@ -17,8 +17,10 @@ function run_test()
{
do_test_pending();
// Copy distribution.ini file to our app dir.
let distroDir = Services.dirsvc.get("XREExeF", Ci.nsIFile);
// Set special pref to load distribution.ini from the profile folder.
Services.prefs.setBoolPref("distribution.testing.loadFromProfile", true);
// Copy distribution.ini file to the profile dir.
let distroDir = gProfD.clone();
distroDir.leafName = "distribution";
let iniFile = distroDir.clone();
iniFile.append("distribution.ini");
@ -94,7 +96,7 @@ function onCustomizationComplete()
do_register_cleanup(function() {
// Remove the distribution file, even if the test failed, otherwise all
// next tests will import it.
let iniFile = Services.dirsvc.get("XREExeF", Ci.nsIFile);
let iniFile = gProfD.clone();
iniFile.leafName = "distribution";
iniFile.append("distribution.ini");
if (iniFile.exists())