summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul')
-rw-r--r--toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul112
1 files changed, 112 insertions, 0 deletions
diff --git a/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
new file mode 100644
index 000000000..a55263eb2
--- /dev/null
+++ b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!--
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * Removes files and preferences for previous application update tests in case
+ * any of them had a fatal error. The test name ensures that it will run after
+ * all other tests as long as the test naming uses the same format as the
+ * existing tests.
+ */
+-->
+
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<window title="Application Update test cleanup"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="runTest();">
+<script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script type="application/javascript"
+ src="utils.js"/>
+
+<script type="application/javascript">
+<![CDATA[
+
+/**
+ * If the application update tests left behind any of the files it uses it could
+ * be a very bad thing. The purpose of this test is to prevent that from
+ * happening.
+ */
+function runTest() {
+ debugDump("entering");
+
+ SimpleTest.waitForExplicitFinish();
+
+ if (DEBUG_AUS_TEST) {
+ Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true);
+ }
+
+ closeUpdateWindow();
+
+ // Always leave the app.update.enabled and app.update.staging.enabled
+ // preferences set to false when cleaning up.
+ Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, false);
+ Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false);
+
+ resetFiles();
+ removeUpdateDirsAndFiles();
+ reloadUpdateManagerData();
+
+ let file = getUpdatesXMLFile(true);
+ ok(!file.exists(), file.path + " should not exist");
+
+ file = getUpdatesXMLFile(false);
+ ok(!file.exists(), file.path + " should not exist");
+
+ let dir = getUpdatesDir();
+
+ file = dir.clone();
+ file.append(FILE_UPDATE_STATUS);
+ ok(!file.exists(), file.path + " should not exist");
+
+ file = dir.clone();
+ file.append(FILE_UPDATE_MAR);
+ ok(!file.exists(), file.path + " should not exist");
+
+ cleanupRestoreUpdaterBackup();
+}
+
+/**
+ * After all tests finish this will repeatedly attempt to restore the real
+ * updater if it exists and then call finishTest after the restore is
+ * successful.
+ */
+function cleanupRestoreUpdaterBackup() {
+ debugDump("entering");
+
+ try {
+ // Windows debug builds keep the updater file in use for a short period of
+ // time after the updater process exits.
+ restoreUpdaterBackup();
+ } catch (e) {
+ logTestInfo("Attempt to restore the backed up updater failed... " +
+ "will try again, Exception: " + e);
+ SimpleTest.executeSoon(cleanupRestoreUpdaterBackup);
+ return;
+ }
+
+ SimpleTest.executeSoon(finishTest);
+}
+
+function finishTest() {
+ debugDump("entering");
+
+ if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LOG)) {
+ Services.prefs.clearUserPref(PREF_APP_UPDATE_LOG);
+ }
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+ <p id="display"></p>
+ <div id="content" style="display: none"></div>
+ <pre id="test"></pre>
+</body>
+</window>