Bug 1322722: Ensure that the directory for the postSigningData file exists before attempting to write it. r=mhowell
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 23 Dec 2016 13:05:15 -0800
changeset 453604 f9ac48b9d76515da1f7a925c0fb0474cf7d03752
parent 453603 c618f28ab699f6973d24aa5fb8f3d385077ba7c9
child 453605 c95614dac02258038b5baf570ddec750c8d49f7f
push id39711
push userdmitchell@mozilla.com
push dateFri, 23 Dec 2016 21:59:47 +0000
reviewersmhowell
bugs1322722
milestone53.0a1
Bug 1322722: Ensure that the directory for the postSigningData file exists before attempting to write it. r=mhowell
toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
--- 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();
   }