Bug 1322722: Ensure that the directory for the postSigningData file exists before attempting to write it. r=mhowell
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -300,30 +300,27 @@ function spoofPartnerInfo() {
// Spoof the preferences.
for (let pref in prefsToSpoof) {
Preferences.set(pref, prefsToSpoof[pref]);
}
}
function getAttributionFile() {
- let file = Services.dirsvc.get("LocalAppData", Ci.nsIFile);
- file.append("mozilla");
- file.append(AppConstants.MOZ_APP_NAME);
- file.append("postSigningData");
- return file;
+ return FileUtils.getFile("LocalAppData", ["mozilla", AppConstants.MOZ_APP_NAME, "postSigningData"]);
}
function spoofAttributionData() {
if (gIsWindows) {
AttributionCode._clearCache();
let stream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
stream.init(getAttributionFile(), -1, -1, 0);
stream.write(ATTRIBUTION_CODE, ATTRIBUTION_CODE.length);
+ stream.close();
}
}
function cleanupAttributionData() {
if (gIsWindows) {
getAttributionFile().remove(false);
AttributionCode._clearCache();
}