Bug 1173320 - patch 8/8 - Fix e10s tests for DeviceStorage API, r=smaug

This commit is contained in:
Andrea Marchesini 2016-03-20 11:56:11 +01:00
parent 8d3c72ef64
commit 1e2dc533d6
3 changed files with 19 additions and 12 deletions

View File

@ -582,7 +582,16 @@ DeviceStorageStatics::ResetOverrideRootDir()
nsCOMPtr<nsIFile> f;
DS_LOG_INFO("");
if (Preferences::GetBool(kPrefTesting, false)) {
// For users running on desktop, it's convenient to be able to override
// all of the directories to point to a single tree, much like what happens
// on a real device.
const nsAdoptingString& overrideRootDir =
mozilla::Preferences::GetString(kPrefOverrideRootDir);
if (overrideRootDir && !overrideRootDir.IsEmpty()) {
NS_NewLocalFile(overrideRootDir, false, getter_AddRefs(f));
}
if (!f && Preferences::GetBool(kPrefTesting, false)) {
DS_LOG_INFO("temp");
nsCOMPtr<nsIProperties> dirService
= do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
@ -592,15 +601,6 @@ DeviceStorageStatics::ResetOverrideRootDir()
f->AppendRelativeNativePath(
NS_LITERAL_CSTRING("device-storage-testing"));
}
} else {
// For users running on desktop, it's convenient to be able to override
// all of the directories to point to a single tree, much like what happens
// on a real device.
const nsAdoptingString& overrideRootDir =
mozilla::Preferences::GetString(kPrefOverrideRootDir);
if (overrideRootDir && !overrideRootDir.IsEmpty()) {
NS_NewLocalFile(overrideRootDir, false, getter_AddRefs(f));
}
}
if (f) {

View File

@ -20,12 +20,20 @@ Object.defineProperty(Array.prototype, "remove", {
function devicestorage_setup(callback) {
SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
var directoryService = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
var f = directoryService.get("TmpD", Ci.nsIFile);
f.appendRelativePath("device-storage-testing");
let script = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('remove_testing_directory.js'));
script.addMessageListener('directory-removed', function listener () {
script.removeMessageListener('directory-removed', listener);
var prefs = [["device.storage.enabled", true],
["device.storage.testing", true],
["device.storage.overrideRootDir", f.path],
["device.storage.prompt.testing", true]];
SpecialPowers.pushPrefEnv({"set": prefs}, callback);
});

View File

@ -149,8 +149,7 @@ try {
// The remove will fail if the directory doesn't exist, which is fine.
f.remove(true);
} catch (e) {}
SpecialPowers.pushPrefEnv({'set': [["device.storage.overrideRootDir", f.path],
["device.storage.testing", false]]},
SpecialPowers.pushPrefEnv({'set': [["device.storage.overrideRootDir", f.path]]},
function() {
startTest();
});