Bug 1159632 - Fix failure in toolkit/components/jsdownloads/test/unit/test_DownloadImport.js when browser.helperApps.deleteTempFileOnExit true. r=paolo, a=test-only
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 25 May 2015 21:16:22 +0300
changeset 266254 acaf3ba8f4e4
parent 266253 4304c0383035
child 266255 04059bd01b9b
push id4804
push userryanvm@gmail.com
push date2015-06-15 15:02 +0000
treeherdermozilla-beta@05b522f50491 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, test-only
bugs1159632
milestone39.0
Bug 1159632 - Fix failure in toolkit/components/jsdownloads/test/unit/test_DownloadImport.js when browser.helperApps.deleteTempFileOnExit true. r=paolo, a=test-only
toolkit/components/jsdownloads/test/unit/head.js
--- a/toolkit/components/jsdownloads/test/unit/head.js
+++ b/toolkit/components/jsdownloads/test/unit/head.js
@@ -130,18 +130,29 @@ function getTempFile(aLeafName)
   let leafName = base + "-" + gFileCounter + ext;
   gFileCounter++;
 
   // Get a file reference under the temporary directory for this test file.
   let file = FileUtils.getFile("TmpD", [leafName]);
   do_check_false(file.exists());
 
   do_register_cleanup(function () {
-    if (file.exists()) {
-      file.remove(false);
+    try {
+      file.remove(false)
+    } catch (e) {
+      if (!(e instanceof Components.Exception &&
+            (e.result == Cr.NS_ERROR_FILE_ACCESS_DENIED ||
+             e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ||
+             e.result == Cr.NS_ERROR_FILE_NOT_FOUND))) {
+        throw e;
+      }
+      // On Windows, we may get an access denied error if the file existed before,
+      // and was recently deleted.
+      // Don't bother checking file.exists() as that may also cause an access
+      // denied error.
     }
   });
 
   return file;
 }
 
 /**
  * Waits for pending events to be processed.