Bug 1001948 - Attempt to remove files more than once in the Windows cleanup functions in toolkit/webapps/ tests. r=myk,Yoric,tabraldes
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Thu, 08 May 2014 20:06:26 +0200
changeset 182160 b64dbd20218430d4257a725f5e7936805452a766
parent 182159 4cff28c41a2f9c0fae6a1c0ced2c26f864de9f23
child 182161 2cc0d0171da6d49f7232748941eb02a3771fc373
push id43227
push usermar.castelluccio@studenti.unina.it
push dateThu, 08 May 2014 18:25:21 +0000
treeherdermozilla-inbound@b64dbd202184 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk, Yoric, tabraldes
bugs1001948
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1001948 - Attempt to remove files more than once in the Windows cleanup functions in toolkit/webapps/ tests. r=myk,Yoric,tabraldes
dom/system/OSFileConstants.cpp
toolkit/webapps/tests/test_hosted_launch.xul
toolkit/webapps/tests/test_hosted_launch_no_registry.xul
toolkit/webapps/tests/test_hosted_update_from_webapp_runtime.xul
toolkit/webapps/tests/test_packaged_launch.xul
toolkit/webapps/tests/test_packaged_launch_no_registry.xul
toolkit/webapps/tests/test_packaged_update_from_webapp_runtime.xul
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -732,25 +732,27 @@ static const dom::ConstantSpec gWinPrope
   INT_CONSTANT(INVALID_FILE_ATTRIBUTES),
 
   // GetNamedSecurityInfo and SetNamedSecurityInfo constants
   INT_CONSTANT(UNPROTECTED_DACL_SECURITY_INFORMATION),
   INT_CONSTANT(SE_FILE_OBJECT),
   INT_CONSTANT(DACL_SECURITY_INFORMATION),
 
   // Errors
+  INT_CONSTANT(ERROR_SUCCESS),
   INT_CONSTANT(ERROR_INVALID_HANDLE),
   INT_CONSTANT(ERROR_ACCESS_DENIED),
   INT_CONSTANT(ERROR_DIR_NOT_EMPTY),
   INT_CONSTANT(ERROR_FILE_EXISTS),
   INT_CONSTANT(ERROR_ALREADY_EXISTS),
   INT_CONSTANT(ERROR_FILE_NOT_FOUND),
   INT_CONSTANT(ERROR_NO_MORE_FILES),
   INT_CONSTANT(ERROR_PATH_NOT_FOUND),
   INT_CONSTANT(ERROR_BAD_ARGUMENTS),
+  INT_CONSTANT(ERROR_SHARING_VIOLATION),
   INT_CONSTANT(ERROR_NOT_SUPPORTED),
 
   PROP_END
 };
 #endif // defined(XP_WIN)
 
 
 /**
--- a/toolkit/webapps/tests/test_hosted_launch.xul
+++ b/toolkit/webapps/tests/test_hosted_launch.xul
@@ -112,20 +112,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_hosted_launch.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));
--- a/toolkit/webapps/tests/test_hosted_launch_no_registry.xul
+++ b/toolkit/webapps/tests/test_hosted_launch_no_registry.xul
@@ -112,20 +112,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_hosted_launch_no_registry.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));
--- a/toolkit/webapps/tests/test_hosted_update_from_webapp_runtime.xul
+++ b/toolkit/webapps/tests/test_hosted_update_from_webapp_runtime.xul
@@ -117,20 +117,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_hosted_launch.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));
--- a/toolkit/webapps/tests/test_packaged_launch.xul
+++ b/toolkit/webapps/tests/test_packaged_launch.xul
@@ -122,20 +122,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_packaged_launch.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));
--- a/toolkit/webapps/tests/test_packaged_launch_no_registry.xul
+++ b/toolkit/webapps/tests/test_packaged_launch_no_registry.xul
@@ -122,20 +122,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_packaged_launch_no_registry.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));
--- a/toolkit/webapps/tests/test_packaged_update_from_webapp_runtime.xul
+++ b/toolkit/webapps/tests/test_packaged_update_from_webapp_runtime.xul
@@ -130,20 +130,32 @@ if (LINUX) {
           uninstallKey.close();
         }
       }
 
       if (profileDir) {
         yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
       }
 
-      yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+      let removed = false;
+      do {
+        try {
+          yield OS.File.removeDir(installPath, { ignoreAbsent: true });
+
+          yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
+          yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
 
-      yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
-      yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
+          removed = true;
+        } catch (ex if ex instanceof OS.File.Error &&
+                 (ex.winLastError == OS.Constants.Win.ERROR_SUCCESS ||
+                  ex.winLastError == OS.Constants.Win.ERROR_SHARING_VIOLATION)) {
+          // Wait 100 ms before attempting to remove again.
+          yield wait(100);
+        }
+      } while (!removed);
     });
   };
 } else if (MAC) {
   installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_packaged_launch.app");
   exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
 
   let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
                                    WebappOSUtils.getUniqueName(app));